Game Development Reference
In-Depth Information
Listing 8-65. Creating the Patrol/Attack Command
VehicleCommand CreatePatrolAttackTankCommand(AIVehicleObjectsAffected ObjectsAffected,int
NumberWayPoints,Vector3[] WayPoints, Vector3 Target, Object3d TargetObj, int NumberRoundToFire,int
FiringDelay)
{
VehicleCommand TankCommand = null;
AIVehicleCommand Command = AIVehicleCommand.Patrol;
Int NumberObjectsAffected = 0;
Int DeltaAmount = NumberRoundToFire;
Int DeltaIncrement = FiringDelay;
Int MaxValue = 0;
Int MinValue = 0;
TankCommand = new VehicleCommand(m_Context,Command,ObjectsAffected,NumberObjectsAffected,
DeltaAmount,DeltaIncrement,MaxValue,MinValue,NumberWayPoints,WayPoints,Target,TargetObj);
return TankCommand;
}
The CreateTanks() function (see Listing 8-66) creates the enemy tank by
Creating the tank object and assigning it to m_Tank .
1.
2.
Setting the tank main body material to emit a green glow.
3.
Setting the tank turret material to emit a red glow.
4.
Setting the tank id to “tank1”.
5.
Creating the patrol/attack tank command by calling the
CreatePatrolAttackTankCommand() function. The tank is ordered to fire three
rounds of projectiles at the player's pyramid, then pause for five seconds,
then repeat the firing sequence.
6.
Sending the Patrol/Attack command to the Driver of the tank by calling the
SetOrder() function.
Listing 8-66. Creating the Tank
void CreateTanks()
{
m_Tank= CreateTankType1(m_Context);
// Set Material
m_Tank.GetMainBody().GetMaterial().SetEmissive(0.0f, 0.5f, 0f);
m_Tank.GetTurret().GetMaterial().SetEmissive(0.5f, 0, 0.0f);
// Tank ID
m_Tank.SetVehicleID("tank1");
 
Search WWH ::




Custom Search