Game Development Reference
In-Depth Information
The key data fields for this command are
The Command variable, which is set to AIVehicleCommand.Patrol
1.
The DeltaAmount variable, which is set to the number of rounds for the tank
to fire in one burst
2.
The DeltaIncrement variable, which is set to the time delay in milliseconds
between the tank's bursts of fire
3.
Listing 10-27. Creating a Patrol/Attack Tank 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 SetTankOrder() function creates a new tank patrol/attack order and gives the order to the tank.
(See Listing 10-28.)
The SetTankOrder() function does the following:
1.
Sets the tank route index to cycle through all the available routes
2.
Retrieves the selected tank route
3.
Retrieves the tank's waypoints from the route
4.
Retrieves the number of waypoints from the route
5.
Sets up the tank's patrol/attack command to fire three-round bursts of
ammunition at the target located at the origin every five seconds
6.
Creates the tank's patrol/attack command and sets this command for the
input TankVehicle
 
Search WWH ::




Custom Search