Game Development Reference
In-Depth Information
public EnemyDef()
{
EnemyType
¼
"cannon_fodder";
StartPosition
¼
new Vector(300, 0, 0);
LaunchTime
¼
0;
}
public EnemyDef(string enemyType, Vector startPosition, double
launchTime)
{
EnemyType
¼
enemyType;
StartPosition
¼
startPosition;
LaunchTime
¼
launchTime;
}
}
}
There is a string that describes the enemy type. In the code, we might provide
several different types of enemies: small fast ones, big slow ones, etc. The default
enemy type is cannon fodder, and that's what we've got now. The start position is
off the right of the screen. The launch time is the time at which the enemy will
appear in the level. The level time counts down from some large number to 0. If
the
gameTime
goes lower than the launch time, then an
enemy
object will be
created and it will be launched into the level.
The
EnemyManager
is the class that will handle the enemy spawning. This
means the constructor needs to be modified, and a list of upcoming enemies
needs to be added.
List
<
EnemyDef
>
_upComingEnemies
¼
new List
<
EnemyDef
>
();
public EnemyManager(TextureManager textureManager, EffectsManager
effectsManager, int leftBound)
{
_textureManager
¼
textureManager;
_effectsManager
¼
effectsManager;
_leftBound
¼
leftBound;
_upComingEnemies.Add(new EnemyDef("cannon_fodder", new Vector(300,
300, 0), 25));
_upComingEnemies.Add(new EnemyDef("cannon_fodder", new Vector(300,
-300, 0), 30));
Search WWH ::
Custom Search