Game Development Reference
In-Depth Information
Beefing up the enemy
At the moment,
Goblin
is just a sprite drawn on the screen with an AI system that just
sits idle in the background. So, let's expand on this and give our Goblins some muscle
power. Player, be warned!
As stated previously, to keep the player engaged, you need to have a varied amount of en-
emies in the battle, and they need to be challenging enough to make the player think and
apply tactics.
The enemy profile/controller
First, we'll create a new profile for the enemies, starting off with a new enumeration for
the enemy class. Create a new C# script named
EnemyClass
in
As-
sets\Scripts\Classes
and replace its contents with the following code:
public enum EnemyClass
{
Goblin,
Ork,
NastyPeiceOfWork
}
I've used just a couple of examples, as we will only be using the
Goblin
for now. Next,
create a new
Enemy
C# script in the same folder, as follows:
public class Enemy : Entity
{
public EnemyClass Class;
}
The preceding code just extends the base
Entity
class for our enemies and adds the
EnemyClass
enumeration we just created.
Now that we have a profile for the enemy, we need a controller to make the enemy per-
form actions in a controlled way. So, create another C# script named
EnemyControl-
ler
in
Assets\Scripts
, starting with the following variables: