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


C++ TransformComponent::GoToPrevPos方法代码示例

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


在下文中一共展示了TransformComponent::GoToPrevPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ScriptParticle_OnCollision

void Floyd::ScriptParticle_OnCollision(World *world, Entity *owner, const Tile *collider)
{
	TransformComponent *ptTransform = owner->GetComponentDirectly<TransformComponent>(CTYPE_TRANSFORM);
	StatComponent *ptStat = owner->GetComponentDirectly<StatComponent>(CTYPE_STAT);
	ParticleComponent *ptParticle = owner->GetComponentDirectly<ParticleComponent>(CTYPE_PARTICLE);

	if ( ! world->GetCurrentLevel()->IsPositionInsideMap(ptTransform->position.PositionAfterMove(ptTransform->direction)))
	{
		ptStat->health = 0;
	}

	if (collider->logicalSprite == TILE_WALL || collider->logicalSprite == TILE_MONSTER || 
		collider->logicalSprite == TILE_STASH || collider->logicalSprite == TILE_NPC || 
		collider->logicalSprite == TILE_TELEPORT || collider->logicalSprite == TILE_DREAMS || 
		collider->logicalSprite == TILE_EXIT || collider->logicalSprite == TILE_HERO || 
		collider->logicalSprite == TILE_BOSS || collider->logicalSprite == TILE_EXIT_BLOCK)
	{
		if (collider->sprite == TILE_HERO) 
		{
			world->GetHero()->GetComponentDirectly<StatComponent>(CTYPE_STAT)->ApplyDamage(ptStat->damage);
		}
		else if ((collider->sprite == TILE_MONSTER || collider->sprite == TILE_BOSS) &&
				 ptParticle->isEmittedFromHero)
		{
			auto enemy =
				// We predict the particle's position. Therefore, the hit target will be the entity after the particle has
				// moved once more.
				world->GetEntityAtPos(ptTransform->position.PositionAfterMove(ptTransform->direction));
			if (enemy) 
			{
				enemy->GetComponentDirectly<StatComponent>(CTYPE_STAT)->ApplyDamage(ptStat->damage);
			}
		}

		ptStat->health = 0;
		ptTransform->GoToPrevPos();
	}
}
开发者ID:emdeha,项目名称:floyd,代码行数:38,代码来源:ScriptsParticle.cpp


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