本文整理汇总了C++中Tank::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Tank::getKey方法的具体用法?C++ Tank::getKey怎么用?C++ Tank::getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tank
的用法示例。
在下文中一共展示了Tank::getKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEventId
void Munitions::handleEventId(EventData const &eventMessage)
{
if(EvtData_From_ActorCollisionObject::msEventType == eventMessage.getEventType())
{
const EvtData_From_ActorCollisionObject& evtData = static_cast<const EvtData_From_ActorCollisionObject&>(eventMessage);
Munitions *pMunition = dynamic_cast<Munitions*>(ActorHandler::getInstance()->getActor(evtData.mFirstActorId));
Actor *pSecondActor = ActorHandler::getInstance()->getActor(evtData.mSecondActorId);
Actor::ActorTypes secondActorType = pSecondActor->getActorType();
Actor::ActorTypes munitionOwnerType = pMunition->getOwnerType();
//if a enemy collides with a munition
if(secondActorType == Actor::ActorType_Enemy)
{
Enemy* pEnemy = dynamic_cast<Enemy*>(pSecondActor);
if((munitionOwnerType == Actor::ActorType_Tank || munitionOwnerType == Actor::ActorType_Driver) && pEnemy->getHealthPoints() > 0)
{
if(pEnemy->getKey().isOwner())
{
pEnemy->reduceHp(Weapon::calculateDamage(pMunition->getEfficiency(),pEnemy->getEnemySize(),pMunition->getDamage()), eventMessage.getNetworkId(), pMunition->getOwner());
}
else
{
safeThreadSafeQueueEvent(EventDataPtr(myNew EvtData_To_ActorReduceHp(pEnemy->getKey(), Weapon::calculateDamage(pMunition->getEfficiency(),pEnemy->getEnemySize(),pMunition->getDamage()), pMunition->getOwner())));
}
}
}
//if a tank collides with a munition
else if(secondActorType == Actor::ActorType_Tank)
{
Tank* pTank = dynamic_cast<Tank*>(pSecondActor);
if(munitionOwnerType == Actor::ActorType_Enemy)
{
if(pTank->getKey().isOwner())
{
pTank->reduceHp(pMunition->getDamage());
}
else
{
safeThreadSafeQueueEvent(EventDataPtr(myNew EvtData_To_ActorReduceHp(pTank->getKey(), pMunition->getDamage(), pMunition->getOwner())));
}
}
}
//if a driver collides with a munition
else if(secondActorType == Actor::ActorType_Driver)
{
Driver* pDriver = dynamic_cast<Driver*>(pSecondActor);
if(munitionOwnerType == Actor::ActorType_Enemy)
{
if(pDriver->getKey().isOwner())
{
pDriver->reduceHp(pMunition->getDamage());
}
else
{
safeThreadSafeQueueEvent(EventDataPtr(myNew EvtData_To_ActorReduceHp(pDriver->getKey(), pMunition->getDamage(), pMunition->getOwner())));
}
}
}
}
}
示例2: main
//.........这里部分代码省略.........
if(rnd == 0)
{
tempObj->setPosition(D3DXVECTOR3(-30.0f * j,0.0f,-30.0f * i));
tempObj->setScale(D3DXVECTOR3(15.0f, 15.0f, 15.0f));
tempObj->setID(-1);
}
else
{
tempObj->setPosition(D3DXVECTOR3(-30.0f * j, -10.0f,-30.0f * i));
tempObj->setScale(D3DXVECTOR3(15.0f, 0.1f, 15.0f));
tempObj->setID(-2);
}
int color = colorCounter % 4;
if(color == 0)
tempObj->setColor(D3DXCOLOR(0.0f,0.0f,0.0f,1.0f));
else if(color == 1)
tempObj->setColor(D3DXCOLOR(1.0f,0.0f,0.0f,1.0f));
else if(color == 2)
tempObj->setColor(D3DXCOLOR(1.0f,1.0f,0.0f,1.0f));
else if(color == 3)
tempObj->setColor(D3DXCOLOR(0.0f,1.0f,1.0f,1.0f));
colorCounter++;
}
}
//module->loadObjectShapeInstance(gfx::ShapeTypes::CUBE, 1, "Cube", 5000);
module->loadMeshInstance("../../ModelFiles/TankGround/TankGeometry.txt", 2, "LongRangeTank", 5000);
//module->loadMeshInstance("../../ModelFiles/TankGround/TankGeometry.txt", 1, "Tank3", 5000);
module->loadMeshInstance("../../ModelFiles/TankAir/TankAirGeometry.txt", 3, "CloseRangeTank", 5000);
/*gfx::InstanceMesh *mesh1 = module->createMeshInstanced("Tank");
mesh1->setTextureID(0);
mesh1->setFlagUpdateAbsolute(false);
mesh1->setID(lolAnt->getKey());
mesh1->setName("enemy");
mesh1->setPosition(D3DXVECTOR3(lolAnt->getPosition().x, lolAnt->getPosition().y, lolAnt->getPosition().z));
mesh1->setScale(D3DXVECTOR3(2.5f, 1.5f, 2.5f));
mesh1->setColor(D3DXCOLOR(0.0f, 0.25f, 1.0f, 1.0f));
mesh1 = module->createMeshInstanced("Tank3");
mesh1->setTextureID(0);
mesh1->setFlagUpdateAbsolute(false);
mesh1->setID(spindelFan->getKey());
mesh1->setName("enemy2");
mesh1->setPosition(D3DXVECTOR3(spindelFan->getPosition().x, spindelFan->getPosition().y, spindelFan->getPosition().z));
mesh1->setScale(D3DXVECTOR3(2.5f, 1.5f, 2.5f));
mesh1->setColor(D3DXCOLOR(0.0f, 0.25f, 1.0f, 1.0f));
mesh1 = module->createMeshInstanced("Tank2");
mesh1->setTextureID(1);
mesh1->setFlagUpdateAbsolute(false);
mesh1->setID(pt->getKey());
mesh1->setName("player");
mesh1->setPosition(D3DXVECTOR3(pt->getPosition().x, pt->getPosition().y, pt->getPosition().z));
mesh1->setScale(D3DXVECTOR3(2.5f, 1.5f, 2.5f));
mesh1->setColor(D3DXCOLOR(1.0f, 0.0f, 1.0f, 1.0f));*/
//Create actors
Tank *pt = myNew Tank(200, 15, Tank::TankType_CloseCombat);
pi->setTankActorId(pt->getKey());
//safeQueueEvent(EventDataPtr(myNew EvtData_From_ActorCreated(pt->getKey())));
FireAnt *lolAnt = myNew FireAnt(100,20,Enemy::Size_Small,1,150.0f);
//safeQueueEvent(EventDataPtr(myNew EvtData_From_ActorCreated(lolAnt->getKey())));
actorHandler->insertActor(lolAnt);
lolAnt->setPosition(-120.0f,0.0f,0.0f);