本文整理汇总了C++中Missile::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Missile::getType方法的具体用法?C++ Missile::getType怎么用?C++ Missile::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Missile
的用法示例。
在下文中一共展示了Missile::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSpecificMissile
// Get the next free missile of type 'missileType'
Missile* SimpleStoresMgr::getSpecificMissile(const base::String* const missileType)
{
Missile* msl = nullptr;
if (missileType != nullptr) {
base::PairStream* list = getWeapons();
if (list != nullptr) {
// Find the first free (inactive) missile of type weaponType
base::List::Item* item = list->getFirstItem();
while (item != nullptr && msl == nullptr) {
base::Pair* pair = static_cast<base::Pair*>(item->getValue());
Missile* p = dynamic_cast<Missile*>(pair->object());
if (p != nullptr && p->isInactive()) {
// Ok, we have a missile, but is it the type we want?
if (*p->getType() == *missileType) {
p->ref();
msl = p;
}
}
item = item->getNext();
}
list->unref();
}
}
return msl;
}
示例2: onContactBegin
bool MonsterDevil::onContactBegin(cocos2d::PhysicsContact& contact)
{
auto bodyA = contact.getShapeA()->getBody();
auto bodyB = contact.getShapeB()->getBody();
auto componentA = (BaseComponent*)bodyA->getNode();
auto componentB = (BaseComponent*)bodyB->getNode();
BaseComponent* enemyComponent;
bool isComponentA = true;
//어떤것 끼리 부딪혔는지는 안가르쳐주기 때문에
//여기서 어느쪽이 monsterDevil인지 밝혀낸다.
if (componentA->getType() == getType())
{
enemyComponent = componentB;
isComponentA = true;
}
else
{
enemyComponent = componentA;
isComponentA = false;
}
//FLOOR 충돌 무시
if (enemyComponent->getType() == OT_FLOOR)
{
return false;
}
//미사일이랑 충돌 처리
if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
{
Missile* missile = static_cast<Missile*>(enemyComponent);
//수류탄은 뎀 안 입음
if (missile->getType() == OT_MISSILE_GRENADE)
{
return false;
}
//몹이 쏜 건 안 맞음.
if (!missile->isPlayerMissile())
{
return false;
}
float damage = missile->getDamage();
m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);
//사망
if (m_Info.m_CurrentHp <= 0)
{
m_IsDead = true;
}
}
return true;
}
示例3: onContactBegin
bool MonsterRush::onContactBegin(cocos2d::PhysicsContact& contact)
{
auto bodyA = contact.getShapeA()->getBody();
auto bodyB = contact.getShapeB()->getBody();
auto componentA = (BaseComponent*)bodyA->getNode();
auto componentB = (BaseComponent*)bodyB->getNode();
BaseComponent* enemyComponent;
bool isComponentA = true;
if (componentA->getType() == getType())
{
enemyComponent = componentB;
isComponentA = true;
}
else
{
enemyComponent = componentA;
isComponentA = false;
}
//미사일이랑 충돌 처리
if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
{
Missile* missile = static_cast<Missile*>(enemyComponent);
//수류탄은 뎀 안 입음
if (missile->getType() == OT_MISSILE_GRENADE)
{
return false;
}
//몹이 쏜 건 안 맞음.
if (!missile->isPlayerMissile())
{
return false;
}
float damage = missile->getDamage();
m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);
//미사일에 의한 상태 이상 처리
if (missile->getState() == Missile::MST_KNOCKBACK)
{
GET_SOUND_MANAGER()->createSound(SoundManager::PIG, false);
m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
if (missile->getAttackDir() == DIR_LEFT)
{
CommonState::enterKnockback(this, DIR_LEFT);
}
else
{
CommonState::enterKnockback(this, DIR_RIGHT);
}
setState(0,STAT_KNOCKBACK);
}
else if (missile->getState() == Missile::MST_BIND)
{
m_KnockbackStartTime = GET_GAME_MANAGER()->getMicroSecondTime();
getPhysicsBody()->setVelocity(cocos2d::Vect(0, 0));
setState(0,STAT_KNOCKBACK);
}
//사망
if (m_Info.m_CurrentHp <= 0)
{
m_IsDead = true;
}
}
//플레이어랑 부딪친 경우 이펙트 생성
if (enemyComponent->getType() == OT_PLAYER)
{
GET_EFFECT_MANAGER()->createEffect(ET_PUNCH_MISSILE, enemyComponent->getPosition())->enter();
}
return true;
}