Game Development Reference
In-Depth Information
Listing 10-19. Setting the Sound Effects for the Tanks
void SetSoundOnOff(boolean Value)
{
for (int i = 0; i < MAX_TANKS; i++)
{
if (m_TankFleet[i] != null)
{
m_TankFleet[i].GetMainBody().SetSFXOnOff(Value);
m_TankFleet[i].GetTurret().SetSFXOnOff(Value);
int NumberWeapons = m_TankFleet[i].GetNumberWeapons();
for (int j = 0; j < NumberWeapons; j++)
{
m_TankFleet[i].GetWeapon(j).TurnOnOffSFX(Value);
}
}
}
}
The AddTankFleetToGravityGrid() function adds all the active tanks in the fleet to the input
parameter gravity grid iGrid . More specifically, the tank's main body and the tank's active
ammunition from its weapons are all added to the gravity grid. (See Listing 10-20.)
Listing 10-20. Adding the Tank Fleet to the Gravity Grid
// Add in all the Air vehicles in the fleet to the gravity grid
void AddTankFleetToGravityGrid(GravityGridEx iGrid)
{
Object3d[] Masses = new Object3d[50];
int NumberMasses = 0;
for (int i = 0; i < MAX_TANKS; i++)
{
if ((m_TankFleet[i] != null) && (m_InService[i] == true))
{
// Add Mass of AirVehicle to grid
iGrid.AddMass(m_TankFleet[i].GetMainBody());
// Add Weapons Fire from AirVehicle to grid
int NumberWeapons = m_TankFleet[i].GetNumberWeapons();
for (int j = 0; j < NumberWeapons; j++)
{
NumberMasses = m_TankFleet[i].GetWeapon(j).GetActiveAmmo(0, Masses);
iGrid.AddMasses(NumberMasses, Masses);
}
}
}
}
The ProcessWeaponAmmoCollisionObject() function processes the collision between the live
ammunition from the tanks in the tank fleet and the input object Obj . (See Listing 10-21.)
 
Search WWH ::




Custom Search