Objective: Our next feature will be a homing missile for the player with a powerup to pick up.
I will have the player hold a maximum of three missiles with each powerup they collect, providing one. Also, I’ll have the player fire a missile by pressing the “x” key.
First, I need to add some new variables to the UIManager script.
Next, in the UIManager, I create a UpdateMissileCount() method to update the missile count on the UI. This also checks if the missile count is below 0 or above 3 and resets to those min or max values.
Objective: The latest goal for the game is to add an aggressive enemy that will ram the player when within a certain range.
And with a new enemy type come a new enemy graphic. For the ramming enemy, I’ll be using the one below.
It’s a little pixelated-looking, but I’ll be replacing it and most of the others before the final release.
So, like the ones before, this one will inherit from the BaseEnemy class. I’ll also be using an override on a couple of methods and adding the following variables.
Objective: The objective today is pretty straightforward. We want a new enemy type that will detect powerups in front of them and will fire at and destroy them to keep the player from getting them.
This objective builds very nicely with some of the previous ones since it involves detecting an object in front of the enemy and performing an action when it is detected.
First, I’m going to create a new enemy, and in its script, it will inherit from the BaseEnemy class. I’m going to name it the EnemyXPowerup and will use the sprite below.
The script for…
In this article, I’ll cover setting up a new enemy that can dodge a single shot fired from the player.
Objective: Create an enemy type that can avoid the player’s weapon.
Since I’m creating new enemies, I decided to start using some different sprites for the ships. So first, I got myself a nice selection of ship sprites to choose from. For the enemy that can dodge, I’m using the below sprite.
This enemy will inherit from my BaseEnemy class, and the only modification will be its ability to dodge. I added two new variables shown below.
This article is about how I set up a new, smarter enemy to challenge the player.
Objective: Create a new enemy that detects when the player is behind them and fires a shot at them.
As I discussed in my previous article on Refactoring my Code, adding new enemies with additional functionality is much easier now.
First, I created a SmartEnemy script and set it to inherit from the BaseEnemy class. This allows it to have all of the functionality and a basic normal enemy.
I then added a private float _revFireTime = 0.0f; …
Doing a bit of refactoring before fully going on to the next feature in the Phase II articles.
First I modified the Spawnmanger script by adding a GameObject array that will hold the different enemy Prefabs that can be spawned. I also added a private int _enemyID which will be randomized to decide which enemy to initialize.
Then I drag the prefabs into the Inspector for the enemies. Currently, it’s just 2, Enemy and SmartEnemy.
Objective: Implement wave sequencing of enemies with more enemies coming in each wave.
As stated above, the latest added feature will have the enemies spawn in waves. There will be a short delay between waves and an on-screen display announcing the next wave.
First, I created a few more variables which I will explain.
Objective: When the player presses the ‘C’ key, pickups quickly move to the player.
In the heat of battle, it can be dangerous for the player to fly across the screen to grab a pickup, especially when it can be very near enemies. So I’m going to give the player the ability to “tractor” the pickups toward them.
There are two options I’m going to explore. The first is for pickups to move towards the player only while the “C” key is held down and then resume their original direction if released. …
Objective: Provide some enemies the ability to have shields that allow them to take one extra hit.
If the player has shields, then I’m sure the enemy can figure out that technology too. So I’m going to give random enemies a shield that allows them to take an extra hit as per the objective.
The first thing was to add a few more variables to the EnemyBehaviour script.
Today I’m going to throw a little misfortune into the mix for the player with a collectible with negative effects.
Objective: Create a powerup that negatively affects the player.
The collectible I created for this will slow the player’s speed and temporarily set their ammo to zero. Both will return to normal once the negative effect wears off. I created a new Sprite to use for this and gave it a Particle effect as well.
I had to make adjustments in the SpawnManager, Powerup, and Player scripts. First, I started with the SpawnManager. I am using a PowerUpSelector() method to…