Пример #1
0
void AI::findTarget()
{
	if(m_elapsedTime>0.5f)
	{
		// Adjusting the chance that a decisions is taken
		if(rand() % 100 <= 25)
		{
			m_elapsedTime = 0;
			
			// Check with if it's a good idea to chase the avatar or not
			if(shouldChaseTarget())
				chaseTarget();
			else
				fleeFromTarget();
		}
		// If it was not selected the AI will not take decisions for a while
		else
		{
			m_elapsedTime -= m_elapsedTime*0.2f;
		}
	}

	//Do something else when a new AI decision is not avaiable, e.g continue
	else
		return;
}
Пример #2
0
	void Bullet::update(float time)
	{
		    lifeTime -= time;

			//sceneNode->translate(Ogre::Vector3(0,1,0));
			if(lifeTime < 0){
				die = true;
				return;
			}
			
			


			if(currentTarget == NULL)
			{
				
				if(!enemyFactory->enemyList.empty())   //try to find a target
				{
					for (EnemyFactory::EnemyIterator ei = enemyFactory->enemyList.begin(); ei != enemyFactory->enemyList.end(); ei++){
						currentTarget = *ei;
						if(currentTarget != NULL)
							break;
					}
					

					
				}
				
				
			}

			//if(yes)
				

			if(currentTarget != NULL)  //still no target
			{
				
				//currentTarget->getEntity();
				chaseTarget(time);
			}

			
		
	}