Game Development Reference
In-Depth Information
Velocity.Set(VelX, 0, VelZ);
return Velocity;
}
The AddNewArenaObject() function adds an arena object to the playfield. (See Listing 10-26.)
The function does the following:
1.
Tries to retrieve a new available arena object by calling the
GetRandomAvailableArenaObject() function
2.
If an arena object is available, it
a. Sets its visibility to true and its health to 100
b. Creates a location vector called Max that holds the maximum location of the arena
object along the x and z axes
c. Creates a location vector called Min that holds the minimum location of the arena
object along the x and z axes
d. Calls the GenerateGridLocationRestricted() function with the Max and Min locations
to retrieve a random location within the bounds of Max and Min
e.
Sets the position of the new arena object to the location generated from the
previous step
3.
Returns true if a new arena object has been added to the game and false
otherwise
Listing 10-26. Adding a New Arena Object
boolean AddNewArenaObject()
{
boolean result = false;
ArenaObject3d AO = m_ArenaObjectsSet.GetRandomAvailableArenaObject();
if (AO != null)
{
// Respawn
AO.SetVisibility(true);
AO.GetObjectStats().SetHealth(100);
Vector3 Max = new Vector3(m_Grid.GetXMaxBoundary(), DROP_HEIGHT, -5.0f);
Vector3 Min = new Vector3(m_Grid.GetXMinBoundary(), DROP_HEIGHT, m_Grid.
GetZMinBoundary());
Vector3 Position = GenerateGridLocationRestricted(Max, Min);
AO.m_Orientation.GetPosition().Set(Position.x, Position.y, Position.z);
result = true;
}
return result;
}
The CreatePatrolAttackTankCommand() function creates a new patrol/attack tank command and
returns it. (See Listing 10-27.)
 
Search WWH ::




Custom Search