本文整理汇总了C++中PlayerEntity::getBikingAction方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerEntity::getBikingAction方法的具体用法?C++ PlayerEntity::getBikingAction怎么用?C++ PlayerEntity::getBikingAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerEntity
的用法示例。
在下文中一共展示了PlayerEntity::getBikingAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step
void AttackAspect::step(GameState & gs, float deltaT) {
// handle attack for all players
std::list<PlayerEntity*> playerFakeList;
auto hitEnemy =
[ &gs ]( PlayerEntity * attacker, EnemyEntity * enemy, PlayerData * player, Vector2 const& conVector ) {
enemy->getHitAction().activate(EnemyBehaviour::HitTime);
// move slightly back
// todo: this kick direction looks a bit strange
//auto kickBack = conVector * PlayerMovement::HitKickBackFactor;
//auto kickForce = conVector * 3000.0f;
//enemy->setMoveDelta(kickBack);
auto conVectorNorm = conVector.normalizedCopy();
enemy->setDirection(-conVectorNorm);
// does not look so good
//enemy->getRigidBody()->applyCentralImpulse( Vector3( kickForce.x(), kickForce.y(), 0.0f) );
enemy->activateLastHit();
EntityFactory fact( gs.getEngines());
//fact.createPunchParticles( enemy->getPosition(), conVector.normalizedCopy() );
auto newEnts = fact.createPunchParticlesTex < BloodEntity > ( enemy->getPosition(), conVector.normalizedCopy() );
//const float bloodSpeed = 5.0f;
for ( auto & e: newEnts ) {
gs.addFragment( std::move(e) );
}
logging::Info() << "Enemy player hit";
gs.getEngines().soundEngine().startVibratePattern( VibratePatterns().EnemyPunched );
if ( attacker->getBikingAction().isActive())
{
enemy->subtractLife( 127);
} else {
enemy->subtractLife( PlayerMovement::KickSubtractLife );
}
logging::Info() << "Enemy has " << enemy->getLife() << " life left";
if ( enemy->getLife() < 0)
{
logging::Info() << "Enemy died";
enemy->die( );
enemy->updateVisual( gs.getEngines() );
gs.slotEnemyDied.signal(gs, player->Id, enemy);
gs.increaseScore( player->Id, GameRules::PointsForKill );
}
if( attacker->getBikingAction().isActive() )
attacker->getBikingAction().setProcessed();
if( attacker->getKickAction().isActive() )
attacker->getKickAction().setProcessed();
};
for (PlayerData & pd : gs.getPlayers()) {
PlayerEntity * pent = pd.Entity;
if (pent == nullptr)
continue;
// check if the player kicks and whether there is an enemy close by
if ((pent->getKickAction().isActive()
&& !pent->getKickAction().wasProcessed())
|| (pent->getBikingAction().isActive()
&& !pent->getBikingAction().wasProcessed())) {
attackOnList(pent, gs.getEnemies(), hitEnemy, &pd,
PlayerMovement::AttackAngle,
PlayerMovement::AttackRangeSquared, EnemyBehaviour::HitTime,
PlayerMovement::KickAffectCount);
}
playerFakeList.push_back(pent);
}
auto hitOnPlayer =
[]( EnemyEntity * attacker, PlayerEntity * enemy, PlayerData * player, Vector2 const& conVector ) {
//enemy->getHitAction().activate(EnemyBehaviour::HitTime);
// move slightly back
// todo: this kick direction looks a bit strange
/*auto kickBack = conVector * 0.25f;
enemy->setMoveDelta(kickBack);
auto conVectorNorm = conVector.normalizedCopy();
enemy->setDirection(-conVectorNorm);*/
};
// checks for enemies hitting player
for (auto * enemy : gs.getEnemies()) {
if (enemy->getKickAction().isActive()
&& !enemy->getKickAction().wasProcessed()) {
attackOnList(enemy, playerFakeList, hitOnPlayer, nullptr,
PlayerMovement::AttackAngle,
PlayerMovement::AttackRangeSquared, EnemyBehaviour::HitTime,
1);
enemy->getKickAction().setProcessed();
//.........这里部分代码省略.........