Game Development Reference
In-Depth Information
// Set Patrol Order
int MAX_WAYPOINTS = 10;
Vector3[] WayPoints = new Vector3[MAX_WAYPOINTS];
int NumberWayPoints = GenerateTankWayPoints(WayPoints);
AIVehicleObjectsAffected ObjectsAffected = AIVehicleObjectsAffected.PrimaryWeapon;
Vector3 Target = new Vector3(0,0,0);
Object3d TargetObj = null;
int NumberRoundToFire = 3;
int FiringDelay = 5000;
VehicleCommand Command = CreatePatrolAttackTankCommand(ObjectsAffected,NumberWayPoints,
WayPoints, Target,TargetObj,NumberRoundToFire,FiringDelay);
m_Tank.GetDriver().SetOrder(Command);
}
The ProcessTankCollisions() function processes collisions between the tank and the player's
ammunition and the tank weapon's ammunition and the player's power pyramid. (See Listing 8-67.)
Listing 8-67. Processing the Tank Collisions
void ProcessTankCollisions()
{
float ExplosionMinVelocity = 0.02f;
float ExplosionMaxVelocity = 0.4f;
if (!m_Tank.GetMainBody().IsVisible())
{
return;
}
// Check Collisions between Tank and Player's Ammunition
Object3d CollisionObj = m_Weapon.CheckAmmoCollision(m_Tank.GetMainBody());
if (CollisionObj != null)
{
CollisionObj.ApplyLinearImpulse(m_Tank.GetMainBody());
m_Tank.GetMainBody().ExplodeObject(ExplosionMaxVelocity, ExplosionMinVelocity);
m_Tank.PlayExplosionSFX();
// Process Damage
m_Tank.GetMainBody().TakeDamage(CollisionObj);
int Health = m_Tank.GetMainBody().GetObjectStats().GetHealth();
if (Health <= 0)
{
int KillValue = m_Tank.GetMainBody().GetObjectStats().GetKillValue();
m_Score = m_Score + KillValue;
m_Tank.GetMainBody().SetVisibility(false);
m_Tank.GetTurret().SetVisibility(false);
}
}
 
Search WWH ::




Custom Search