The cure

Game jam: A&B Jam IV – Black plague

Description: A single-level tower defense game with hand-drawn aesthetics

Date: October – 2021

Link: https://gamejolt.com/games/torresvsratos/534488

I’ve lost this project (not really lost but my last accessible version was quite behind the actual last one), but as it was a nice result I tried to show some features with what I have

Follow path

Problem: We need a path to monsters follow, it need to be creatable/modifiable though editor and must not be unique

Solution for path create/modification: I created a script that treats its children transform as nodes in a path and exposes a list of nodes through an API. For visual/debug I overwrote the OnDrawGizmos to allow us to see the lines and nodes during the editor and added a line color. And to simplify the process added it to a prefab.

Enemy follows solution: Giving the previous feature, I coded a coroutine that makes the enemy walk through each node, and if reaches the last node will cause damage. This is set inside an abstraction method to simplify the process of creating a debug button to make the enemy to follow the path.


Enemies

Problem: We must have enemies that could have similar behavior and also could have different sprites and/or status

Solution for unique behaviors/status: using scriptable objects as behaviors and the editor as the injector, we could change what happens when the enemy achieves something like reaching at last node in the path, when killed, and so on… by just dragging and dropping in the inspector. Using this approach together with nested prefab is enough to enable us to separate into many groups that we could need

Note: It was quite an overengineering, so I would avoid this approach again for a game jam, but it`s quite awesome for bigger projects

Note 2: The tower creator is pretty similar


Tower placement

Problem: Tower should just allow click when money is enough.
Problem: When selecting a tower in UI, the tower icon should follow the mouse.
Problem: possible placements should be highlighted.

Money validation: Each button tower will vinculate itself on a OnMoneyChange event in a load step, and will enable/disable interaction based on tower cost and current money.

Note: It’s great because we can easily test it through the editor ->

Mouse following: Quite simple approach, each tower has its icon, it raises an event passing this information and a listener will start to make it follow the mouse position until something makes it stop (another tower was clicked or ESC is pressed)

Placement highlight: Again, quite a simple event/listener approach, an placement is a prefab that registers itself on an OnChangeTower event and will change its settings making it visible or not (based on having or not a tower already condition)

Note: Today I would make it pass through some kind of space controller, this new layer will simplify if at some point I wish to do things like limiting the number of placements, or some other random condition.