Game Development Reference
In-Depth Information
// Main Body
String MainBodyHandle = Handle + "MainBody";
m_MainBody.LoadObjectState(MainBodyHandle);
// Turret
String TurretHandle = Handle + "Turret";
m_Turret.LoadObjectState(TurretHandle);
}
The Reset() function resets the tank's driver and the tank's weapons. (See Listing 8-54.)
Listing 8-54. Resetting the Tank
void Reset()
{
// Reset Driver
if (m_Driver != null)
{
m_Driver.DriverReset();
}
// Reset Weapons
for (int i = 0; i < m_NumberWeapons; i++)
{
Weapon TempWeapon = m_Weapons[i];
TempWeapon.ResetWeapon();
}
}
The AddWeapon() function adds the weapon iWeapon to the tank's set of weapons, if there is more
room available. The function returns true if successful and false if not successful. (See Listing 8-55.)
Listing 8-55. Adding a Weapon to the Tank
boolean AddWeapon(Weapon iWeapon)
{
boolean result = false;
if (m_NumberWeapons < MAX_WEAPONS)
{
m_Weapons[m_NumberWeapons] = iWeapon;
m_NumberWeapons++;
result = true;
}
return result;
}
The FireWeapon() function fires the tank's weapon number WeaponNumber in the direction Direction
with the weapon's projectile starting at the tank's turret position. The function returns true if the
weapon has been fired and false otherwise. (See Listing 8-56.)
 
Search WWH ::




Custom Search