当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerEntity::getKickAction方法代码示例

本文整理汇总了C++中PlayerEntity::getKickAction方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerEntity::getKickAction方法的具体用法?C++ PlayerEntity::getKickAction怎么用?C++ PlayerEntity::getKickAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerEntity的用法示例。


在下文中一共展示了PlayerEntity::getKickAction方法的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();
//.........这里部分代码省略.........
开发者ID:poseidn,项目名称:KungFoo,代码行数:101,代码来源:AttackAspect.cpp


注:本文中的PlayerEntity::getKickAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。