Ride the Wave
Friday was a combination of work and learning. We’ll start with the work. The final two items on my checklist for the Phase II: Core Programing course material here at GameDevHQ are making a boss fight and a wave system for spawning enemies. These spawn waves need to make more enemies each wave. I was online Thursday evening watching the first part of a two part Brackey’s tutorial on making a wave spawner. It looked fairly involved, as this is easily the longest tutorial I have seen from them. I mentally prepared myself for a long day Friday trying to work through this.
Friday morning I sat for a while just staring at my Spawn Manager script and thinking about the possibility of something less time consuming than following some tutorials. I have referenced a lot of online information through the end of this course material, and I really just wanted to try and do something all by myself. I had an idea that seemed simple enough, yet would just barely check the box for what is being asked. I need waves that increase the amount of enemies produced each wave. While I know this “wave manager” is a bit crude and lacking concerning flexibility outside of the code, I also really want to move on to the final boss fight, and then the cinematography course. While I do plan on coming back to make a more refined and customizable wave spawner, this is what I came up with for now.
My enemies randomly spawn from an array every 5 seconds. They start spawning when the asteroid at the beginning is destroyed, and stop spawning when the player dies. The first thing I did is jump into my asteroid script and replace my StartSpawning() method with a new SpawnFirstEnemyWave() method. I then needed to add a SpawnFirstEnemyWave() method into my Spawn Manager, and of course the first thing I do is call StartSpawning(). I decided to control everything through timing, which of course involves a Coroutine. I essentially set the first wave to be 20 seconds, with the second and third waves doubling into 40 and 60 seconds respectively. This lets more enemies per wave be generated, being the duration of the wave is steadily increasing. The spawning is also based on a bool and a while loop. While _stopSpawning = false, spawn enemies. I can change that bool to be true or false with some timing, to control when enemies are spawning. I basically keep telling my Spawn Manager to wait before performing operations. Start spawning for 20 seconds, stop spawning for 10 seconds. Start spawning for 40 seconds, and then stop for another 10.
At least for the appearance of a legitimate wave effect, I added some text to my UI manager that I setActive during the 10 second cool down, reflective of which wave we are on.
I would like to add some if statements to check for enemies, that way I can delay the following wave if enemies are still active aka != null. Then again, I do plan on revisiting this to implement a more sophisticated wave system. I am too eager right now to get to the boss and the next course section, so this will have to suffice for now.
To end the day, we had a long afternoon session that was both very informative and inspirational. Firstly, a team of our collogues released a game that they have been working on and gave us a nice overview of what their challenges and successes were. You can go play it here! https://gamedevhq.itch.io/nova-star
Jonathan then gave us a great run down of how to treat our websites, resumes and social media accounts to say the least.
I hope we get some good news this week regarding the potential continuation of this incredible opportunity put before us, but for now, on the the boss fight!