Ride the Waves!
In the last article, I changed the players ammo display to include the max amount of ammo. Today, I’m going to be continuing the second, and final, phase of the GameDevHQ 2D Game Development Certification track. In this article, I’ll be implementing a wave system allowing for multiple waves of increasing enemy numbers! The requirement reads as follows:
- Implement wave sequencing of enemies with more enemies coming each wave
Defining a wave
For this requirement, I started by defining what a wave consisted of and what it controlled. In this case the wave holds an assignable references to which enemy belongs in the wave, the path that the enemy will follow in the wave, how many enemies there are, how fast they move and the amount of time between enemy spawns. I exposed read-only accessor functions for the data above and included a flag for whether or not the wave was pathed or not. I placed all of this into a ScriptableObject which will allow me to use it as a blue print to create multiple waves with differing parameter values.
Defining a Group of Waves
Now that I knew what a wave consisted of I needed a way to keep track of multiple waves of enemies. For this I created another ScriptableObject that contained a list of wave objects, the time between waves, and the index of the wave to start on from the list. Like with the Wave object I provided read-only accessor methods for the data.
After adding the new Wave system classes I realized that my enemy pathing was going to need to be modified to work with the way points stored in a path inside of the Wave instead of directly having a Path attached.
SpawnManager class changes
Like the EnemyPathing class the SpawnManager class needed to have modifications to handle operating over a Group of Waves instead of just a list of enemy prefabs. This meant looping over the Waves in a WaveConfig and then spawning the waves attached enemies.
Testing it out
With everything in place I created a few Wave objects with increasing numbers of enemies, Created a WaveConfig and added the waves to it. I assigned the WaveConfig to the SpawnManager, and fired it up!
In this article, I Implemented a wave system allowing for multiple waves of increasing enemy numbers. Next time, I'll be adding a powerup with a negative affect for the player. If you enjoyed this article, or want to come along with me as I progress on my journey, follow me at gamedevchris.medium.com.