本文整理汇总了C++中Enemy::clearKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::clearKey方法的具体用法?C++ Enemy::clearKey怎么用?C++ Enemy::clearKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::clearKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: battleEventCheck
void World::battleEventCheck()
{
BattleState* bs = static_cast<BattleState*>( GetWorldStateManager().getState( GAME_WORLD_STATE_BATTLE ) );
assert( bs );
// Detect battle event.
// If current selected unit isn't hero unit, and isn't talkable,
// regard as enemy. And if hero is in the fight area of enemy, start battle.
UnitSet::iterator it = m_unitSet.begin();
for ( ; it != m_unitSet.end(); ++it )
{
if ( (*it) != getHeroUnit() )
{
Enemy* oppCharacter = static_cast<Enemy*>( *it );
assert( oppCharacter );
if ( oppCharacter->getType() == UT_ENEMY && oppCharacter->isTalkable() == false && !oppCharacter->getRemoveFlag() )
{
if ( isInEventArea( getHeroUnit(), oppCharacter ) == true)
{
//////////////////////////////////////////////////////////////////////////
// Check whether there is obstacle between hero and enemy.
// Shoot ray from hero to enemy, and if distance to the third intersected
// mesh is shorter than distance between hero and enemy, then there exists
// at least one obstacle.
ArnVec3 vStartPos( getHero()->getPos() );
ArnVec3 vRayDir = oppCharacter->getPos() - getHero()->getPos();
float fRayLength = ArnVec3Length( &vRayDir );
ArnVec3Normalize( &vRayDir, &vRayDir );
float f3rdDist = Utility::FullTraverseExhaustiveRayTesting(
getArnSceneGraphPt()->getSceneRoot(),
vStartPos,
vRayDir,
1 );
//printf( "3rd dist, ray length %f, %f\n", f3rdDist, fRayLength );
if ( f3rdDist < fRayLength )
continue;
//////////////////////////////////////////////////////////////////////////
// No more move!
getHeroUnit()->clearKey();
oppCharacter->clearKey();
getHeroUnit()->setControllable( false );
// view each other
getHero()->setViewAt( &oppCharacter->getPos() );
oppCharacter->setViewAt( &getHero()->getPos() );
// Insert to enemy pool at BattleState
bs->insertEnemy( oppCharacter );
if ( GetWorldStateManager().curStateEnum() == GAME_WORLD_STATE_FIELD )
GetWorldStateManager().setNextState( GAME_WORLD_STATE_BATTLE );
}
}
}
}
}
示例2: wannaTalkingEventCheck
void World::wannaTalkingEventCheck()
{
BattleState* bs = static_cast<BattleState*>( GetWorldStateManager().getState( GAME_WORLD_STATE_BATTLE ) );
assert( bs );
// Check if hero is in the talking enemy's fight area. If true, the enemy look at hero.
// This work is almost same as battle event check.
UnitSet::iterator it = m_unitSet.begin();
for ( ; it != m_unitSet.end(); ++it )
{
if ( (*it) != getHeroUnit() )
{
Enemy* unconfirmedEnemy = dynamic_cast<Enemy*>( *it );
if ( unconfirmedEnemy != NULL
&& unconfirmedEnemy->isTalkable() == true
&& !unconfirmedEnemy->getRemoveFlag() )
{
Enemy* talkingEnemy = unconfirmedEnemy;
if ( isInEventArea( getHeroUnit() , talkingEnemy ) == true )
{
// no more move!
talkingEnemy->clearKey();
// View at hero
talkingEnemy->setViewAt( &getHero()->getPos() );
//bs->insertEnemy( talkingEnemy );
}
else
{
talkingEnemy->setRotZ( 0.0f );
}
}
}
}
}