The Boss Enemy, Part 1
Objective: Create a special enemy wave that includes only a single, very tough boss enemy. This wave includes special announcement text and its own health bar.
There’s quite a few features I’d like for the final boss of Galaxy Quest. First, it will have it’s own wave all to itself. This will be the final wave, and if the boss is defeated, the game will complete with the player victorious.
The boss itself require many shots to defeat and have its own health bar. This boss will have multiple attacks that it uses one after the other, such as barrages of lasers, charging beam attacks, and even its own missiles that seek the player. Not only that, it will have two phases; after losing all of its life, the boss ship will have some parts of it explode, but the remaining ship will have another life bar, move faster, and have even more dangerous attacks!
We’ll begin with implementing the boss wave, the boss’ basic attributes, and the necessary UI elements. This new method in SpawnManager has a new option to create a boss wave instead of a normal wave. This will happen when the wave number reaches _bossWaveNumber, which is an integer set in the inspector.
The new coroutine BossWave will tell the UI Manager to display special text. Then after a short delay, we instantiate the boss and tell the UI Manager again, so we can also display the boss’s health bar.
The boss will have it’s own lives component. We will eventually use this to modify behavior relating to the boss having to switch phases. For now we can just override the OnTakeDamage method so it tells the UI to update the boss health bar, and also override OnDeath to tell the UI that the boss has been defeated.
When the boss is arriving, the UI should display special text and have it change colors, just like the normal wave announcement. In fact, we can even re-use the same coroutine that we use for the normal waves.
Now the boss wave will use the same coroutine, but with boss-specific text and colors that are set in the inspector.
When the boss itself appears, we start another coroutine that makes the health bar gradually appear. We get both the background and fill colors of the slider and linear interpolate from a fully transparent color to its usual color.
Here’s how things look so far when the boss wave starts. We get red/orange warning text, and the boss health bar appears on the right side of the screen. In this case, we can just use one of the normal enemy behaviors for the boss. We’ll change that next time!
As the boss takes damage, the slider value is updated so the health bar is depleted over time. This allows the player to know how much damage he’s doing.
Finally, when the boss is destroyed, the game ends and we show some victory text that changes colors using linear interpolation.
He’s the victory screen after everything is done. The health bar on the right is depleted, the boss explodes, and the game ends with a nice victory screen. There’s still a lot more work to be done with the boss behavior and visual effects, but this is a good start.