In this tutorial we are going to create the class that will handle the creation of our waves, update our waves, and then move the player onto the next wave when the previous one has finished.
This will be one of the most important classes in our game. We are going to store all our waves in one big queue, and just move through them one by one with a short period of time in-between waves so the player has time to breath and make new towers. This class will also determine how many enemies we create per wave, so we can make the waves harder as time progresses.
So, let’s get started, start off by creating a new class called “WaveManager.cs” and add the following fields and properties :
Here we just check if there is a wave to start, and if there is we start it, and reset our timer. We need to add a call to this method in our constructor otherwise our waves will never start! At the bottom of the constructor add this :
All that is left to do now is to update our waves and then draw them, let’s start by updating them :
Then in our LoadContent() method instead of initializing a single wave, initialize our wave manager :
And we are finished, we now have multiple waves!!