Project 1: Space Shooter
The Boss part 3
Spawning the boss wave, victory screen and the help menu
All there is to do for the boss enemy is to make the boss wave. Once this is done the game is ready, although I will be adding a victory screen if the player wins and a help menu to aid the player.
The same code that spawns the other waves is used for spawning the enemies in the boss wave, the only difference is that when the enemies are killed then the boss will be spawned. In the code the total number of waves is increased to six from five, which means that the boss wave will have 35 normal enemies in total.
Once all these enemies have been killed, the wave counter is seven which will end the while loop and enable the boss to be spawned. Before the boss is spawned there is a six second wait. When that is over the SpawnBoss method is called, this will instantiate the boss and start the coroutine for spawning the power ups.
If the player defeats the boss, the boss’s OnDeath (shown in part 1) starts the coroutine called the DeathRoutine, which instantiates the explosions and calls the UIManager’s method GameOver with the Boolean argument true.
This method will then call the GameOverSequence method with the same argument to begin the game over scene. As a default the method assumes that the player has lost, but in case of winning the game the victory scene will be shown instead. Both the defeat’s game over scene and the victory scene will have the same flicker action.
Then the last item is the help menu, this is just a text shown at the lower right side of the screen, this can be easily triggered on or off with pressing the H-key. The UIManager keeps track of this in its Update method when it’s pressed.