Exemple #1
0
	bool FastUnitController::HandlePathState(Ogre::Real time)
	{
		if(offPath)
		{
			Direction = moveList.at(0) - this->getPosition();
			Distance = Direction.normalise();
			rotateToDirection(Direction);
			offPath = false;
		}
		Ogre::Real move = moveSpeed * time;
		sceneNode->translate(Direction * move);
		Distance -= move;

		if(Distance <= 0 )
		{
			sceneNode->setPosition(moveList.at(0));
			Distance = 0;
			moveList.pop_front();
			if(moveList.size())
			{
				Direction = moveList.at(0) - getPosition();
				Distance = Direction.normalise();
				rotateToDirection(Direction);
			}
		}

		return true;
	}
bool
RotateScreen::rotateTo (CompAction         *action,
			CompAction::State  state,
			CompOption::Vector &options,
			int                face,
			bool               withWindow)
{
    CompOption::Vector o (0);

    if (face < 0)
	face = CompOption::getIntOptionNamed (options, "face", screen->vp ().x ());

    if (face > screen->vpSize ().width ())
	return false;

    o.push_back (CompOption ("root", CompOption::TypeInt));
    o.push_back (CompOption ("x", CompOption::TypeInt));
    o.push_back (CompOption ("y", CompOption::TypeInt));

    o[0].value ().set ((int) screen->root ());
    o[1].value ().set (CompOption::getIntOptionNamed (options, "x", pointerX));
    o[2].value ().set (CompOption::getIntOptionNamed (options, "y", pointerY));

    if (withWindow)
    {
	o.push_back (CompOption ("window", CompOption::TypeInt));
	o[3].value ().set (CompOption::getIntOptionNamed (options, "window", 0));
	rotateWithWindow (NULL, 0, o, rotateToDirection (face));
    }
    else
	rotate (NULL, 0, o, rotateToDirection (face));

    return false;
}
Exemple #3
0
	bool FastUnitController::HandleChaseState(Ogre::Real time)
	{
		Ogre::Real move = moveSpeed * time;
		Ogre::Vector3 enemyDirection = nearestEnemy->sceneNode->getPosition() - this->getPosition();
		enemyDirection.y = 0;
		enemyDirection.normalise();
		sceneNode->translate(enemyDirection * move);
		rotateToDirection(enemyDirection);
		offPath = true;

		return true;
	}