Game Development Reference
In-Depth Information
The
m_InService
variable array holds a value of true for an element if the corresponding tank in the
m_TankFleet
array is active and needs to be updated and rendered.
private boolean[] m_InService = new boolean[MAX_TANKS];
The TankFleet( ) constructor initializes the tank fleet and is similar to the way the ArenaObjectSet
class was initialized. (See Listing 10-17.)
Listing 10-17. The TankFleet Constructor
TankFleet(Context iContext)
{
m_Context = iContext;
Init();
}
The
ResetSet()
function (see Listing 10-18) resets the tank fleet by
Setting existing tanks to inactive,
m_InService = false
1.
2.
Setting the main body and the turret to invisible
3.
Resetting the tank's finite state machine and weapons
Listing 10-18. Resetting the Tank Set
void ResetSet()
{
// Sets all objects to inactive and invisible
for (int i = 0; i < MAX_TANKS; i++)
{
if (m_TankFleet[i] != null)
{
m_InService[i] = false;
m_TankFleet[i].GetMainBody().SetVisibility(false);
m_TankFleet[i].GetTurret().SetVisibility(false);
m_TankFleet[i].Reset();
}
}
}
The
SetSoundOnOff()
function turns on/off the sound effects for the tank fleet. (See Listing 10-19.)
The sound effects are turned on or off for the components of the tank, which are
1.
The tank's main body
2.
The tank's turret
3.
The tank's weapons