Game Development Reference
In-Depth Information
If there is a collision, processing the collision by calling ApplyLinearImpulse() to
apply action reaction forces to the arena object and the weapon's ammunition
3.
4.
Starting the explosion graphic and sound associated with the arena object
involved in the collision
Processing the damage to the arena object by calling the TakeDamage()
function
5.
6.
Checking the health of the arena object and, if it is 0 or less, updating the
total kill value, which is the total value of all the objects destroyed by the
weapon's ammunition, and destroying the arena object by setting its active
status to false and its visibility to false
7.
Returning the total kill value
Listing 10-11. Collision Detection Between a Weapon's Ammunition and the ArenaObject Set
int ProcessCollisionsWeapon(Weapon iWeapon)
{
int TotalKillValue = 0;
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if ((m_ArenaObjectSet[i] != null) && (m_Active[i] == true))
{
Object3d CollisionObj = iWeapon.CheckAmmoCollision(m_ArenaObjectSet[i]);
if (CollisionObj != null)
{
CollisionObj.ApplyLinearImpulse(m_ArenaObjectSet[i]);
SphericalPolygonExplosion Exp = m_ArenaObjectSet[i].GetExplosion(0);
Exp.StartExplosion(m_ArenaObjectSet[i].m_Orientation.GetPosition(),
m_ExplosionMaxVelocity, m_ExplosionMinVelocity);
m_ArenaObjectSet[i].PlayExplosionSFX();
// Process Damage
m_ArenaObjectSet[i].TakeDamage(CollisionObj);
int Health = m_ArenaObjectSet[i].GetObjectStats().GetHealth();
if (Health <= 0)
{
int KillValue =
m_ArenaObjectSet[i].GetObjectStats().GetKillValue();
TotalKillValue = TotalKillValue + KillValue;
m_Active[i] = false;
m_ArenaObjectSet[i].SetVisibility(false);
}
}
}
}
return TotalKillValue;
}
 
Search WWH ::




Custom Search