本文整理汇总了C++中CGameObject::IsAlive方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::IsAlive方法的具体用法?C++ CGameObject::IsAlive怎么用?C++ CGameObject::IsAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::IsAlive方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCollision
void CSniper::OnCollision(float deltaTime, std::vector<CGameObject*>* listObjectCollision)
{
float normalX = 0;
float normalY = 0;
float moveX = 0.0f;
float moveY = 0.0f;
float timeCollision;
for (std::vector<CBullet*>::iterator it = CPoolingObject::GetInstance()->m_listBulletOfObject.begin(); it != CPoolingObject::GetInstance()->m_listBulletOfObject.end();)
{
CGameObject* obj = *it;
timeCollision = CCollision::GetInstance()->Collision(obj, this, normalX, normalY, moveX, moveY, deltaTime);
if((timeCollision > 0.0f && timeCollision < 1.0f) || timeCollision == 2.0f)
{
if(obj->IsAlive() && obj->GetLayer() == LAYER::PLAYER)
{
// Gan trang thai die cho doi tuong
this->m_stateCurrent = SN_IS_DIE;
// Xoa vien dan ra khoi d.s
it = CPoolingObject::GetInstance()->m_listBulletOfObject.erase(it);
//Load sound die
ManageAudio::GetInstance()->playSound(TypeAudio::ENEMY_DEAD_SFX);
// Tang diem cua contra len
CContra::GetInstance()->IncreateScore(500);
}
else
++it;
}
else
{
++it;
}
}
}
示例2: TutorialEventLogic
TBool CWeaponsTutorialLoseIfAllAmericanSoldiersDied::TutorialEventLogic() //checks if the Event Condition has been met
{
CGameObjectManager* lObjectManager = CFighterPilotThePacificWar::FighterGame->iGameData->GetMap()->GetObjectManager();
CPointerArray<CGameObject>*& lObjects = lObjectManager->GetAllGameObjects();
for(TInt lIndex = 0; lIndex < lObjects->GetCount(); lIndex++)
{
CGameObject* lCurrentGameObject = lObjects->Get(lIndex);
if(lCurrentGameObject->GetConflictSide() == EConflictSideAmerican && lCurrentGameObject->GetGameObjectType() == EObjectTypesGroundUnit)
{
if(lCurrentGameObject->IsAlive())
return false;
}
}
return true; //all American soldiers on the map died
}
开发者ID:DavidAStoll,项目名称:FighterPilotGameCode,代码行数:17,代码来源:CWeaponsTutorialLoseIfAllAmericanSoldiersDied.cpp
示例3: OnCollision
void CGroundCanon::OnCollision(float deltaTime, std::vector<CGameObject*>* listObjectCollision)
{
float normalX = 0;
float normalY = 0;
float moveX = 0.0f;
float moveY = 0.0f;
float timeCollision;
for (std::vector<CBullet*>::iterator it = CPoolingObject::GetInstance()->m_listBulletOfObject.begin(); it != CPoolingObject::GetInstance()->m_listBulletOfObject.end();)
{
CGameObject* obj = *it;
timeCollision = CCollision::GetInstance()->Collision(obj, this, normalX, normalY, moveX, moveY, deltaTime);
if ((timeCollision > 0.0f && timeCollision < 1.0f) || timeCollision == 2.0f)
{
if (obj->IsAlive() && obj->GetLayer() == LAYER::PLAYER)
{
this->m_HP--;
it = CPoolingObject::GetInstance()->m_listBulletOfObject.erase(it);
CBulletEffect* effect = CPoolingObject::GetInstance()->GetBulletEffect();
effect->SetAlive(true);
effect->SetPos(obj->GetPos());
}
else
++it;
if (this->m_HP == 0)
{
// Gan trang thai die cho doi tuong
this->m_stateCurrent = GROUNDCANON_SHOOT_STATE::G_IS_SHOOTING_DIE;
//Load sound die
ManageAudio::GetInstance()->playSound(TypeAudio::ENEMY_DEAD_SFX);
// Tang diem cua contra len
CContra::GetInstance()->IncreateScore(300);
}
}
else
{
++it;
}
}
}
示例4: OnCollision
void CScubaSolider::OnCollision(float deltaTime, std::vector<CGameObject*>* listObjectCollision)
{
float normalX = 0;
float normalY = 0;
float moveX = 0.0f;
float moveY = 0.0f;
float timeCollision;
if ((this->m_currentFrame == 0) || (this->m_currentFrame == 1))
{
return;
}
else
{
for (std::vector<CBullet*>::iterator it = CPoolingObject::GetInstance()->m_listBulletOfObject.begin(); it != CPoolingObject::GetInstance()->m_listBulletOfObject.end();)
{
CGameObject* obj = *it;
if (obj->IsAlive() && obj->GetLayer() == LAYER::PLAYER)
{
timeCollision = CCollision::GetInstance()->Collision(obj, this, normalX, normalY, moveX, moveY, deltaTime);
if ((timeCollision > 0.0f && timeCollision < 1.0f) || timeCollision == 2.0f)
{
// Gan trang thai die cho doi tuong
this->m_stateCurrent = SCUBAR_SOLIDER_STATE::SBS_IS_DIE;
// Xoa vien dan ra khoi d.s
CGameObject* effect = CPoolingObject::GetInstance()->GetEnemyEffect();
effect->SetAlive(true);
effect->SetPos(this->m_pos);
this->m_isALive = false;
it = CPoolingObject::GetInstance()->m_listBulletOfObject.erase(it);
//Load sound die
ManageAudio::GetInstance()->playSound(TypeAudio::ENEMY_DEAD_SFX);
// Tang diem cua contra len
CContra::GetInstance()->IncreateScore(1000);
}
else
++it;
}
else
++it;
}
}
}
示例5: PossibleCollision
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();
}
}
示例6: PossibleCollision
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;
}