void SearchAgent::updateAI(float timeStamp, float dt, unsigned int frameNumber)
{
	Util::AutomaticFunctionProfiler profileThisFunction( &SearchAIGlobals::gPhaseProfilers->aiProfiler );

	
	double steps = (DURATION/(double)__path.size());
	if(timeStamp*dt > last_waypoint*steps)
	{	
		if(!_goalQueue.empty())
		{
			__position = _goalQueue.front().targetLocation;
			std::cout<<"Waypoint: "<< __position;
			_goalQueue.pop();
			last_waypoint++;
		}
	}
}
Exemplo n.º 2
0
void CurveAgent::updateAI(float timeStamp, float dt, unsigned int frameNumber)
{
	//For this function, we assume that all goals are of type GOAL_TYPE_SEEK_STATIC_TARGET.
	//The error check for this was performed in reset().
	Util::AutomaticFunctionProfiler profileThisFunction( &CurveAIGlobals::gPhaseProfilers->aiProfiler );
	Util::Point newPosition;

	//Move one step on hermiteCurve
	if (!curve.calculatePoint(newPosition, timeStamp+dt))
	{
		disable();
		return;
	}

	//Update the database with the new agent's setup
	Util::AxisAlignedBox oldBounds(__position.x - _radius, __position.x + _radius, 0.0f, 0.0f, __position.z - _radius, __position.z + _radius);
	Util::AxisAlignedBox newBounds(newPosition.x - _radius, newPosition.x + _radius, 0.0f, 0.0f, newPosition.z - _radius, newPosition.z + _radius);
	gSpatialDatabase->updateObject(this, oldBounds, newBounds);

	//Update current position
	__position = newPosition;
}
Exemplo n.º 3
0
void SearchAgent::updateAI(float timeStamp, float dt, unsigned int frameNumber)
{
	Util::AutomaticFunctionProfiler profileThisFunction( &SearchAIGlobals::gPhaseProfilers->aiProfiler );

	
	double steps = (DURATION/(double)__path.size());
	if(timeStamp*dt > last_waypoint*steps)
	{	
		if(!_goalQueue.empty())
		{
			Util::AxisAlignedBox oldBounds(__position.x - _radius, __position.x + _radius, 0.0f, 0.0f, __position.z - _radius, __position.z + _radius);

			__position = _goalQueue.front().targetLocation;
			std::cout << "Waypoint: " << __position;
			_goalQueue.pop();
			last_waypoint++;

			Util::AxisAlignedBox newBounds(__position.x - _radius, __position.x + _radius, 0.0f, 0.0f, __position.z - _radius, __position.z + _radius);
			gSpatialDatabase->updateObject(this, oldBounds, newBounds);
		}
	}
}