Day 42 | Wave Manager (Part 2): 2D Space Shooter Series 10

Ted Lim
2 min readJun 4, 2021

Previously, I broadly explained how to build a 2D Space Shooter Wave Manager with Unity Events. In this article, I’ll cover some of the specific information the Wave Manager needs to do its job.

WaveInfo Class

The Wave Manager needs information about each enemy wave. Each wave needs to track the current number of destroyed enemies, the total number of enemies needed to end the wave, and an event to start spawning the wave.

I set up a WaveInfo Class to hold this information:

Each attribute has getter and setter methods. The totalEnemies and waveEvent variables are serialized so that users may alter them from the editor. We can then create an array of WaveInfo classes to store multiple waves at once.

Update WaveInfo

Since WaveInfo is tracking the number of enemies destroyed, we need to update every time an enemy dies. Therefore, once the number of destroyed enemies reaches the target number of enemies, we can stop the spawn enemy process and clean up the remainders of the enemy wave.

Intermediary Text

Lastly, we want to give players context as to when and why enemies are spawning or not spawning. We’ll add a method called UpdateWaveStatus. This method will put notification text on when a wave is complete and when a wave starts. It’s called at the beginning of each wave and the end when the wave is cleaned up.

Having an array of Unity Events and other parameters accessible in the editor gives incredible flexibility for you and designers to edit the game quickly.

--

--