Game Development Reference
In-Depth Information
The
m_TimeLastTankOnGrid
variable holds the time that a tank enemy was last added to the playfield.
private long m_TimeLastTankOnGrid = 0;
The
m_MaxTanksOnPlayField
variable holds the maximum number of tanks allowed on the playfield at
one time.
private int m_MaxTanksOnPlayField = 2;
The
m_NumberTankRoutes
variable holds the total number of tank routes available to select from.
private int m_NumberTankRoutes = 0;
The
m_TankRouteIndex
variable holds the current index into the available tank routes, which is the
m_TankRoutes
array variable.
private int m_TankRouteIndex = 0;
The
m_TankRoutes
array variable holds the tank routes consisting of groups of waypoints.
private Route[] m_TankRoutes = null;
The GamePlayController( ) constructor initializes the GamePlayController class by setting key class
member variables, such as the arena objects set, the tank fleet, the gravity grid, and the available
tank routes. (See Listing 10-22.)
Listing 10-22. GamePlayController Constructor
GamePlayController(Context iContext,ArenaObjectSet ArenaObjectsSet,TankFleet TankFleet,
GravityGridEx Grid,int NumberTankRoutes,Route[] TankRoutes)
{
m_Context = iContext;
m_ArenaObjectsSet = ArenaObjectsSet;
m_TankFleet = TankFleet;
m_Grid = Grid;
m_NumberTankRoutes = NumberTankRoutes;
m_TankRoutes = TankRoutes;
}
The
GenerateRandomGridLocation()
generates and returns a random location on the gravity grid.
(See Listing 10-23.)
The function does the following:
1.
Gets the minimum x boundary for the gravity grid
2.
Gets the maximum x boundary for the gravity grid
3.
Finds the difference between the maximum x boundary and the minimum x
boundary