Repository navigation
Enemy Waves
Enemies come in waves during which enemies will spawn in quick succession. After each wave, the player has 30 seconds to take a break or buy items in the shop. This break time can also be skipped.
A wave usually goes as such:
graph TD;
start([Start])--> spawntime{Is it time to<br>spawn an enemy?}
spawntime-->|Yes| spawnenemy[Fetch enemy<br>and spawn it]
spawntime-->|No| wait[Wait]
wait --> spawntime
spawnenemy-->allspawned{Is there any<br>enemy left to fetch?}
allspawned-->|Yes| spawntime
allspawned-->|No| alldead{Is there any enemy<br>left on the field?}
alldead-->|No| eee([End<br>Start of break time])
alldead-->|Yes| wait2[Wait]
wait2-->alldead
The "Fetch enemy and spawn it" node has 2 separate scenarios:
- Pre-entered waves
- Generated waves
Pre-entered waves are here as a way of introducing the player to the game, or to a specific enemy. They are saved in a DataTable with rows containing a list of enemies and a minimum and maximum time between enemy spawns, like so:

In this scenario, 3 green slimes will spawn in that wave, and there will be a random waiting time between 1.5 seconds and 5 seconds between each spawn.
When a wave does not exist in the list (e.g. we are at wave 12, but row 12 is missing), the wave gets generated using the following system:
- First, the wave gets assigned points.
- A wave gets 25 points times the number of the wave
- e.g. at wave 12, the wave gets 12x25 = 300 points assigned to it.
- Then, a suitable enemy is picked based on the remaining points.
- This is done by looking into a list of enemies with points associated. As an example, there can be a basic enemy worth 10 point and a bigger one worth 50 points.
- If multiple enemies are suitable, one is picked at random
- We spawn the enemy, if it's time. The cooldown between spawns is random between 1.5 and 5 seconds.
- We substract the enemy's points to the wave's points, then we repeat step 2 until no suitable enemy can be found.
- The wave ends and break time starts.