Game Development Reference
In-Depth Information
VehicleCommand Command = CreatePatrolAttackTankCommand(ObjectsAffected, NumberWayPoints,
WayPoints, Target,TargetObj, NumberRoundToFire,FiringDelay);
TankVehicle.GetDriver().SetOrder(Command);
boolean result = m_TankFleet.AddNewTankVehicle(TankVehicle);
// Tank 2
TankVehicle = CreateTankType2(iContext);
// Set Material
TankVehicle.GetMainBody().GetMaterial().SetEmissive(0, 0.5f, 0.5f);
TankVehicle.GetTurret().GetMaterial().SetEmissive(0.5f, 0, 0.5f);
// Tank ID
TankVehicle.SetVehicleID("tank2");
// Set Patrol Order
WayPoints = new Vector3[MAX_WAYPOINTS];
NumberWayPoints = GenerateTankWayPoints2(WayPoints);
Target = new Vector3(0,0,0);
TargetObj = null;
NumberRoundToFire = 3;
FiringDelay = 3000;
Command = CreatePatrolAttackTankCommand(ObjectsAffected, NumberWayPoints, WayPoints, Target,
TargetObj, NumberRoundToFire, FiringDelay);
TankVehicle.GetDriver().SetOrder(Command);
result = m_TankFleet.AddNewTankVehicle(TankVehicle);
}
The CreateTankRoute1() function creates a route object that consists of waypoints that the tank is
to move toward and then returns it. The Route class is very basic, and to save space here, I decided
not to include it. Please refer to the full source code in the Source Code/Download area located on
apress.com for more information on the Route class. (See Listing 10-45.)
Listing 10-45. Creating a Tank Route
Route CreateTankRoute1()
{
// Around Pyramid
Route TankRoute = null;
int NumberWayPoints = 4;
Vector3[] WayPoints = new Vector3[NumberWayPoints];
WayPoints[0] = new Vector3( 7, 0, -10);
WayPoints[1] = new Vector3( -7, 0, -10);
WayPoints[2] = new Vector3( -7, 0, 5);
WayPoints[3] = new Vector3( 7, 0, 5);
TankRoute = new Route(NumberWayPoints, WayPoints);
return TankRoute;
}
 
Search WWH ::




Custom Search