void CComStation::PossibleCollision(CInterval*& aInterval) { //go through all objects and check if care to collide with them if(iAlive) { CPointerArray<CGameObject>* lGameObjects = aInterval->GetGameObjectsByType(EObjectTypesPlane); for(TInt lCurrentObjectIndex = 0; lCurrentObjectIndex < lGameObjects->GetCount(); lCurrentObjectIndex++) { CGameObject* lCurrentGameObject = lGameObjects->Get(lCurrentObjectIndex); //only collide with alive objects if(lCurrentGameObject->IsAlive())//don't compare to anything if already dead { //collide if(iHitBox->IntersectionL(lCurrentGameObject->GetHitBox())) { //make sure plane is dead SDamage lDamage; lDamage.Damage = KILL_ANY_AIRPLANE_DAMAGE; lDamage.ArmorPenetration = KILL_ANY_AIRPLANE_ARMOR_PENETRATION;//should kill any object lCurrentGameObject->TakeDamage(lDamage, EDamageTypeTankPlaneCollision); } } } //clean up delete lGameObjects; } //check if this object got captured CGameObject* lCaptureObject = CheckIfObjectGotCaptured(aInterval); if(lCaptureObject) { iFlagPole->ChangeFlagConflictSide(lCaptureObject->GetConflictSide()); iConflictSide = lCaptureObject->GetConflictSide(); } }
void CStandardRocket::PossibleCollision(CInterval*& aInterval) { //go through all objects and check if care to collide with them CPointerArray<CGameObject>* lGameObjects = aInterval->GetGameObjectsByType(EObjectTypesBuilding | EObjectTypesGroundUnit | EObjectTypesArmouredGroundUnit | EObjectTypesPlane | EObjectTypesShip | EObjectTypesFloor); if(iAlive) { for(TInt lCurrentObjectIndex = 0; lCurrentObjectIndex < lGameObjects->GetCount(); lCurrentObjectIndex++) { CGameObject* lCurrentGameObject = lGameObjects->Get(lCurrentObjectIndex); //only collide with alive objects if(lCurrentGameObject->IsAlive() && lCurrentGameObject != this) { //make sure the rocket doesn't collide with the object that created it if(lCurrentGameObject != iCreatorObject) { if(lCurrentGameObject->GetGameObjectType() & (EObjectTypesBuilding | EObjectTypesGroundUnit | EObjectTypesArmouredGroundUnit | EObjectTypesPlane | EObjectTypesShip)) { //special case, don't collide with Airport or Hangar buildings if(lCurrentGameObject->GetGameObjectIdentifier() != EGameObjectIdentifierAirport && lCurrentGameObject->GetGameObjectIdentifier() != EGameObjectIdentifierHangar) { TPointIntFloat* lCollisionPoint = iHitBox->IntersectionWithCollisionPointL(lCurrentGameObject->GetHitBox()); //collide if(lCollisionPoint) { //need to create an explosion here Destruct(lCollisionPoint);//alread centers the explosion relative to the collision point delete lCollisionPoint; break; } } }else if(lCurrentGameObject->GetGameObjectType() & (EObjectTypesFloor)) { TPointIntFloat* lCollisionPoint = iHitBox->IntersectionWithCollisionPointL(lCurrentGameObject->GetHitBox()); //collide if(lCollisionPoint) { //check if explosion happens on water if(lCurrentGameObject->GetGameObjectIdentifier() == EGameObjectIdentifierWater) { //need to adjust explosion since the explosion should be centered relative to the collision point lCollisionPoint->iX -= TIntFloat::Convert(EXPLOSION_100KG_IN_WATER_WIDTH) / 2;//since the collision point is at the left end of the explosion, we center it by moving the collision point left CFighterPilotThePacificWar::FighterGame->iGameData->GetMap()->AddGameObject(CExplosion100KgInWater::New(*lCollisionPoint)); }else { //need to adjust explosion since the explosion should be centered relative to the collision point lCollisionPoint->iX -= TIntFloat::Convert(EXPLOSION_100KG_WIDTH) / 2;//since the collision point is at the left end of the explosion, we center it by moving the collision point left //create explosion on Ground CFighterPilotThePacificWar::FighterGame->iGameData->GetMap()->AddGameObject(CExplosion100Kg::New(*lCollisionPoint)); } //rocket is used Up DestructWithoutExplosion(); delete lCollisionPoint; break;//only one explosion possible per bomb :) } } } } } } //clean up delete lGameObjects; }