Game Development Reference
In-Depth Information
of the arena object is less than or equal to 0, it adds the kill value of the arena
object to the total kill value. The arena object is destroyed by setting the
active status to false and the visible status to false.
3.
The total kill value that equals the total of all the kill values of the destroyed
arena objects that have just been destroyed by a collision with the input
object Obj is returned.
Listing 10-14. Processing Collisions Between an Object and the ArenaObject Set
int ProcessCollisionWithObject(Object3d Obj)
{
int TotalKillValue = 0;
for (int i = 0; i < MAX_ARENA_OBJECTS; i++)
{
if ((m_ArenaObjectSet[i] != null) && (m_Active[i] == true))
{
Physics.CollisionStatus result = Obj.CheckCollision(m_ArenaObjectSet[i]);
if ((result == Physics.CollisionStatus.COLLISION) ||
(result == Physics.CollisionStatus.PENETRATING_COLLISION))
{
// Process Collision
Obj.ApplyLinearImpulse(m_ArenaObjectSet[i]);
// Arena Object Explosion
SphericalPolygonExplosion Exp = m_ArenaObjectSet[i].GetExplosion(0);
if (Exp != null)
{
Exp.StartExplosion(m_ArenaObjectSet[i].m_Orientation.
GetPosition(), m_ExplosionMaxVelocity, m_ExplosionMinVelocity);
m_ArenaObjectSet[i].PlayExplosionSFX();
}
// Pyramid Explosion
Exp = Obj.GetExplosion(0);
if (Exp != null)
{
Exp.StartExplosion(Obj.m_Orientation.GetPosition(),
m_ExplosionMaxVelocity, m_ExplosionMinVelocity);
}
// Process Damage
Obj.TakeDamage(m_ArenaObjectSet[i]);
m_ArenaObjectSet[i].TakeDamage(Obj);
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);
}
 
Search WWH ::




Custom Search