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


C++ EntityManager::GetEntityThatResidesOnCell方法代码示例

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


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

示例1: FireAtTarget

void FireAtTarget(const MyEventReceiver& Receiver, EntityManager& PlayerManager, EntityManager& EnemyManager, 
					MazeRenderer& MR, irr::scene::ISceneManager *smgr, irr::scene::ISceneNode *Cursor)
{

	if (PlayerManager.GetCurrentEntity()->CanShoot( Cursor->getPosition(), smgr->getSceneCollisionManager(), MR.MetaTriangleSelector ) )
	{
		//check if entity in target position (for now allow friendly fire)
		if (EnemyManager.GetEntityThatResidesOnCell( irr::core::position2di( (int)(Cursor->getPosition().X)/10, (int)(Cursor->getPosition().Z)/10) ) != NULL)
		{
			Entity *Target = EnemyManager.GetEntityThatResidesOnCell( irr::core::position2di( (int)(Cursor->getPosition().X)/10, (int)(Cursor->getPosition().Z)/10 ) );

			attackResult AR;

			//cover only works if the target is adjacent to it
			//check adjacency

			//pointer to make code shorter
			vector<std::string> *m = &Target->PathFinder.Map;


			//have to look at each individually as multiple covers can be surrounding a cell........
			irr::core::position2di TargetVec((int)(Target->Node->getPosition().Z/10), (int)(Target->Node->getPosition().X/10) );
			bool coverHit = false;

			//checks all the cells around the enemy and accounts for cover - to be honest i don't know wtf is going on, it works, and as long as i don't have to fix it, i'm not reading it again
			for (int y = -1; y < 2 && !coverHit; y++)
			{
				for (int x = -1; x < 2 && !coverHit; x++)
				{
					if (!(y == 0 && x == 0)) //not middle
					{
						if ((*m)[TargetVec.Y+y][TargetVec.X+x] == 'C')
						{
							if (PlayerManager.GetCurrentEntity()->CoverHit(Target->Node->getPosition(),
																			smgr->getSceneCollisionManager(),
																			MR.MetaCoverTriangleSelector,
																			irr::core::vector3df(TargetVec.Y*10, 
																								5,
																								TargetVec.X*10),x,y))
							{
								coverHit = true;
								//make sure to break
								x = 3;
								y = 3;
								break;
							}
						}
					}
				}
			}
							

			//get the attack result struct
			AR = PlayerManager.GetCurrentEntity()->Stats.CalculateDamageOnTarget( Target->Stats, coverHit);

			//calculate the result of the attack
			if (!AR.Missed)
			{
				if (AR.Damage > 0)
				{
					Target->Stats.CurrentHealth -= AR.Damage;
					Target->CheckIfDead();
				}
				else
				{
					//inform enemy too powerful
				}
			}
			else
			{
				//inform of a miss!
			}
		}
	}
	return;
}
开发者ID:AlexDiru,项目名称:neuron-warfare,代码行数:76,代码来源:FireAtTarget.cpp


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