Beispiel #1
0
//------------------------------------------------------------------------------ 
// doMenuChoice 
//------------------------------------------------------------------------------ 
// Uppgift: Meny som agerar på användarens val.
// Indata : (const menu&) - en referens till menu objekt som håller i vilket
// val användern gjort.
// Utdata : (void)
//------------------------------------------------------------------------------
void TestApp::doMenuChoice(const menu& p_menuChoice) {
	switch (p_menuChoice) {
	case menu::EXIT:  // EXIT
		break;
	case menu::NEWGAME:
		std::remove(REPLAYFILENAME.c_str()); // remove log file
		createNewGame();
		gamePlayMenu();
		break;
	case menu::REPLAY:
		startReplay();
		break;
	case menu::REDO:
		if (m_commandMgr->canRedo()) { m_commandMgr->redo(); }
		break;
	case menu::MOVE:
		startMove();
		break;
	case menu::RESET:
		createNewGame();
		break;
	case menu::UNDO:
		if (m_commandMgr->canUndo()) { m_commandMgr->undo(); }
		break;
	}
}
Beispiel #2
0
bool Walker::init(){
    // CCString* filePath = CCString::createWithFormat("%s_%d_%WALKER_S_WAVE_0.png", m_icon.c_str(), m_side, "N");
    CCString* filePath = CCString::createWithFormat("%s_%d_%s_move_0.png", m_icon.c_str(), m_side, m_direct != "SW" ? "N" : "SW"); // guo.jiang
    if(CCLoadSprite::getSF(filePath->getCString())==NULL){
        CCLOG("filePath=%s",filePath->getCString());
    }
    m_shadow = CCLoadSprite::createSprite("walker_shadow.png");
    m_shadow->setAnchorPoint(ccp(0.5, 0.5));
    m_shadow->setOpacity(127);
    m_batchNode->addChild(m_shadow);
    
    m_iconSpr = CCLoadSprite::createSprite(filePath->getCString());
    m_iconSpr->setAnchorPoint(ccp(0.5,0.5));
    m_batchNode->addChild(m_iconSpr);
    //begin a by ljf  //解决造出兵时的遮挡问题
    m_iconSpr->setCameraMask(m_batchNode->getCameraMask(), true);
    //end a by ljf
    changeDirect(m_direct);
    float scale = 0.5;
    if(m_isHead){
        scale = 2;
    }
    m_iconSpr->setScale(scale);
    
    initPath();
    
    
    startMove();
    
    return true;
}
Beispiel #3
0
void EntityMoveManager::GuiManager_EntityAction(const std::string& action, EmberEntity* entity)
{

	if (action == "move") {
		startMove(*entity);
	}
}
/*!
    \fn void QDecoration::regionClicked(QWidget *widget, int region)

    Handles the event that the specified \a region in the given top
    level \a widget is activated by a single click (the \a region
    parameter is described using the DecorationRegion enum).

    This function is called whenever a region in a top level widget is
    clicked; the default implementation responds to clicks on items in
    the system menu, performing the requested actions.

    \sa regionDoubleClicked(), region()
*/
void QDecoration::regionClicked(QWidget *widget, int reg)
{
    switch(reg) {
    case Move:
        startMove(widget);
        break;
    case Resize:
        startResize(widget);
        break;
    case Help:
#ifndef QT_NO_WHATSTHIS
        if (QWhatsThis::inWhatsThisMode())
            QWhatsThis::leaveWhatsThisMode();
        else
            QWhatsThis::enterWhatsThisMode();
#endif
        break;
    case Close:
        widget->close();
        break;
    case Normalize:
        widget->showNormal();
        break;
    case Maximize:
        if (widget->windowState() & Qt::WindowMaximized)
            widget->showNormal();
        else
            widget->showMaximized();
        break;
    }
}
void FloatyWnd::mouseMoveEvent(QMouseEvent *e)
{
    if ((e->state() & Qt::LeftButton) && !initMousePos.isNull() &&
            (QPoint(e->pos() - initMousePos).manhattanLength() > QApplication::startDragDistance()))
        startMove();
    if (!mousePos.isNull())
        move(e->globalPos() - mousePos);
}
void AvatarEntity::updateJump(const float elapsedTime)
{
	//Si estamos golpeando, lo primero que tenemos que mirar es cuanto tiempo
	//llevamos realizando el golpe. Si se ha acabado ya el golpe volvemos al 
	//estado inactivo
	m_timeout -= elapsedTime;

	m_deltaX = m_direction * CELERITY * elapsedTime;
	m_terrainPosition[0] += m_deltaX;

	if(m_timeout < JUMP_TIMEOUT/7*6  && m_timeout > JUMP_TIMEOUT/7*5)
	{
		setAnim("jump1");
	}
	else if(m_timeout < JUMP_TIMEOUT/7*5  && m_timeout > JUMP_TIMEOUT/7*4)
	{
		setAnim("jump2");
	}
	else if(m_timeout < JUMP_TIMEOUT/7*4  && m_timeout > JUMP_TIMEOUT/7*3)
	{
		setAnim("jump3");
	}
	else if(m_timeout < JUMP_TIMEOUT/7*3  && m_timeout > JUMP_TIMEOUT/7*2)
	{
		setAnim("jump4");
	}
	else if(m_timeout < JUMP_TIMEOUT/7*2  && m_timeout > JUMP_TIMEOUT/7)
	{
		setAnim("jump5");
	}
	else if(m_timeout < JUMP_TIMEOUT/7  && m_timeout > 0)
	{
		setAnim("jump6");
	}
	else if (m_timeout < 0)
	{
		if(m_direction == 0)
		{
			startIdle(); //vuelta a empezar
		}
		else
		{
			startMove();
		}
	}


}
Beispiel #7
0
/**
 * 按指定方向偏移量,这里不考虑速度叠加.
 */
void SimpleMoveComponent::moveWithDirection(float directionX ,float directionY,bool hasTo)
{
    m_update=schedule_selector(SimpleMoveComponent::updateDirection);
    m_hasEndPosition=hasTo;
    
    m_isDirectionDirty=true;
    
    m_directionX=directionX;
    m_directionY=directionY;
    
	calcSpeedVector(directionX, directionY);
    
    if(beforeMove()){
        startMove();
    }
}
Beispiel #8
0
void WindowManager::unmaximize( TopWindow &rWindow )
{
    // Register the window to allow moving it
//     registerWindow( rWindow );

    // Resize the window
    // FIXME: Ugly const_cast
    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout();
    startResize( rLayout, kResizeSE );
    resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() );
    stopResize();
    // Now move it
    startMove( rWindow );
    move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() );
    stopMove();
    rWindow.m_pVarMaximized->set( false );
}
Beispiel #9
0
FloatyWnd::FloatyWnd(FloatyPlugin *plugin, unsigned id)
        : QWidget(NULL, "floaty",
                  WType_TopLevel | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop )
{
    m_plugin = plugin;
    m_id = id;
    init();
#ifdef USE_KDE
    KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
    KWin::setOnAllDesktops(winId(), true);
#endif
    m_tip = NULL;
    tipTimer = new QTimer(this);
    connect(tipTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    moveTimer = new QTimer(this);
    connect(moveTimer, SIGNAL(timeout()), this, SLOT(startMove()));
    setMouseTracking(true);
}
Beispiel #10
0
void SimpleMoveComponent::moveWithDirection(float direction,bool hasTo)
{
    CCLOG("moveWithDirection:%f",direction);
    
    m_update=schedule_selector(SimpleMoveComponent::updateDirection);
    m_hasEndPosition=hasTo;
    
    if (m_moveState==MoveStart) {
		continueMoveWithDirection(direction);
	}else {
        setDirection(direction);
        calcSpeedVector(cosf(direction), sinf(direction));
        
        if(beforeMove()){
            startMove();
        }
	}
}
Beispiel #11
0
void EntityMoveManager::runCommand(const std::string &command, const std::string &args)
{
	if (Move == command) {
		//the first argument must be a valid entity id
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string entityId = tokeniser.nextToken();
		if (entityId != "") {
			EmberEntity* entity = mWorld.getEmberEntity(entityId);
			if (entity != 0) {
				startMove(*entity);
			}
		} else {
			ConsoleBackend::getSingletonPtr()->pushMessage("You must specify a valid entity id to move.", "error");
		}

	}
}
/* greebo: This is called by the ManipulateObserver class on the mouseDown event. It checks, if a manipulator
 * can be selected where the mouse is pointing to.
 */
bool RadiantSelectionSystem::SelectManipulator(const View& view, const Vector2& device_point, const Vector2& device_epsilon)
{
    if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent))
    {
        // Unselect any currently selected manipulators to be sure
        _manipulator->setSelected(false);

        // Test, if the current manipulator can be selected
        if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent))
        {
            View scissored(view);
            ConstructSelectionTest(scissored, Rectangle::ConstructFromPoint(device_point, device_epsilon));

            // The manipulator class checks on its own, if any of its components can be selected
            _manipulator->testSelect(scissored, GetPivot2World());
        }

        // Save the pivot2world matrix
        startMove();

        // This is true, if a manipulator could be selected
        _pivotMoving = _manipulator->isSelected();

        // is a manipulator selected / the pivot moving?
        if (_pivotMoving) {
            Pivot2World pivot;
            pivot.update(GetPivot2World(), view.GetModelview(), view.GetProjection(), view.GetViewport());

            _manip2pivotStart = _pivot2worldStart.getFullInverse().getMultipliedBy(pivot._worldSpace);

            Matrix4 device2manip;
            ConstructDevice2Manip(device2manip, _pivot2worldStart, view.GetModelview(), view.GetProjection(), view.GetViewport());
            _manipulator->getActiveComponent()->Construct(device2manip, device_point[0], device_point[1]);

            _deviceStart = Vector2(device_point[0], device_point[1]);

            _undoBegun = false;
        }

        SceneChangeNotify();
    }

    return _pivotMoving;
}
/* greebo: This is called by the ManipulateObserver class on the mouseDown event. It checks, if a manipulator
 * can be selected where the mouse is pointing to.
 */
bool RadiantSelectionSystem::SelectManipulator(const View& view, const float device_point[2], const float device_epsilon[2]) {
	if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent)) {
#if defined (DEBUG_SELECTION)
		g_render_clipped.destroy();
#endif

		// Unselect any currently selected manipulators to be sure
		_manipulator->setSelected(false);

		// Test, if the current manipulator can be selected
		if (!nothingSelected() || (ManipulatorMode() == eDrag && Mode() == eComponent)) {
			View scissored(view);
			ConstructSelectionTest(scissored, SelectionBoxForPoint(device_point, device_epsilon));

			// The manipulator class checks on its own, if any of its components can be selected
			_manipulator->testSelect(scissored, GetPivot2World());
		}

		// Save the pivot2world matrix
		startMove();

		// This is true, if a manipulator could be selected
		_pivotMoving = _manipulator->isSelected();

		// is a manipulator selected / the pivot moving?
		if (_pivotMoving) {
			Pivot2World pivot;
			pivot.update(GetPivot2World(), view.GetModelview(), view.GetProjection(), view.GetViewport());

			_manip2pivotStart = matrix4_multiplied_by_matrix4(matrix4_full_inverse(_pivot2worldStart), pivot.m_worldSpace);

			Matrix4 device2manip;
			ConstructDevice2Manip(device2manip, _pivot2worldStart, view.GetModelview(), view.GetProjection(), view.GetViewport());
			_manipulator->GetManipulatable()->Construct(device2manip, device_point[0], device_point[1]);

			_undoBegun = false;
		}

		SceneChangeNotify();
	}

	return _pivotMoving;
}
FloatyWnd::FloatyWnd(FloatyPlugin *plugin, unsigned id)
        : QWidget(NULL, "floaty", Qt::Window | Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint)
{
    m_plugin = plugin;
    m_id = id;
    m_blink = 0;
    init();
    setAcceptDrops(true);
    setBackgroundMode(Qt::NoBackground);
#ifdef USE_KDE
    KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
    KWin::setOnAllDesktops(winId(), true);
#endif
    m_tip = NULL;
    tipTimer = new QTimer(this);
    connect(tipTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    moveTimer = new QTimer(this);
    connect(moveTimer, SIGNAL(timeout()), this, SLOT(startMove()));
    blinkTimer = new QTimer(this);
    connect(blinkTimer, SIGNAL(timeout()), this, SLOT(blink()));
    setMouseTracking(true);
}
void
coVR1DTransInteractor::preFrame()
{
   keepSize();
   if (!cover->isPointerLocked() && !cover->isNavigating() && !interactionOngoing && isSelected() && (cover->getButton()->getButtonStatus() /*==  ACTION_BUTTON*/) )
   {

      startMove();
      interactionOngoing = true;
   }
   if (interactionOngoing)
   {
      if (cover->getButton()->wasReleased() )
      {
         stopMove();
         interactionOngoing = false;
      }
      else
         move();
   }

}
Beispiel #16
0
void WindowManager::maximize( TopWindow &rWindow )
{
    // Save the current position/size of the window, to be able to restore it
    m_maximizeRect = SkinsRect( rWindow.getLeft(), rWindow.getTop(),
                               rWindow.getLeft() + rWindow.getWidth(),
                               rWindow.getTop() + rWindow.getHeight() );

    SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
    // Move the window
    startMove( rWindow );
    move( rWindow, workArea.getLeft(), workArea.getTop() );
    stopMove();
    // Now resize it
    // FIXME: Ugly const_cast
    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout();
    startResize( rLayout, kResizeSE );
    resize( rLayout, workArea.getWidth(), workArea.getHeight() );
    stopResize();
    rWindow.m_pVarMaximized->set( true );

    // Make the window unmovable by unregistering it
//     unregisterWindow( rWindow );
}
void QWaylandMaterialDecoration::processMouseTop(QWaylandInputDevice *inputDevice,
                                                 const QPointF &local, Qt::MouseButtons b,
                                                 Qt::KeyboardModifiers mods)
{
    Q_UNUSED(mods);
    if (local.y() <= margins().bottom()) {
        if (local.x() <= margins().left()) {
            // top left bit
            waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
            startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_TOP_LEFT, b);
        } else if (local.x() > window()->width() - margins().right()) {
            // top right bit
            waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
            startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, b);
        } else {
            // top reszie bit
            waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
            startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_TOP, b);
        }
    } else {
        waylandWindow()->restoreMouseCursor(inputDevice);
        startMove(inputDevice, b);
    }
}
void DynamicObjectController::updateMove(const float elapsedTime)
{
	float timeout = m_dynamicObjectModel->getTimeout();
	timeout-=elapsedTime;
	m_dynamicObjectModel->setTimeout(timeout);

	float stepX,stepY;
	Vector4 terrainPosition =  m_dynamicObjectModel->getTerrainPosition();
	m_dynamicObjectModel->getStep(&stepX,&stepY);
	terrainPosition[0]+= stepX*m_dynamicObjectModel->getCelerity()*elapsedTime;
	terrainPosition[1]+= stepY*m_dynamicObjectModel->getCelerity()*elapsedTime;

	if(timeout > 0)
	{

		m_dynamicObjectModel->setTerrainPosition(terrainPosition);
		m_dynamicObjectView->setNextAnim(); 
	}
	else
	{
		//keep moving
		startMove(m_dynamicObjectModel->getState());
	}
}
void Catoms2DBlock::startMove(Rotation2DMove &m) {
    startMove(m,getScheduler()->now());
}
//----------------------------------------
void ofEasyCamExt::startMove( ofVec3f _posEnd, ofQuaternion _orientationEnd, float _timeToTake, float _delay, EasingEquations::EaseType _easeType )
{
	startMove( getPosition(), getOrientationQuat(), _posEnd, _orientationEnd, _timeToTake, _delay, _easeType );
}
void DynamicObjectController::updateState()
{
	DynamicObjectModel::DynamicObjectAction action = m_dynamicObjectModel->getAction();
	
	if (action == DynamicObjectModel::DYNAMIC_OBJECT_ACTION_IDLE )
	{
		//nothing to do
	}
	else
	{
		if(action ==  DynamicObjectModel::DYNAMIC_OBJECT_ACTION_VANISH
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_VANISHING)
		{
			startVanish();
		}

		if(action ==  DynamicObjectModel::DYNAMIC_OBJECT_ACTION_IMPACT
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_IMPACTING)
		{
			startImpact();
		}

		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_UP 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP);
		
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_DOWN 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_LEFT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_LEFT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_LEFT);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_RIGHT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_RIGHT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_RIGHT);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_UP_LEFT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_LEFT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_LEFT);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_UP_RIGHT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_RIGHT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_UP_RIGHT);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_DOWN_LEFT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_LEFT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_LEFT);
		}
		if(action == DynamicObjectModel::DynamicObjectAction::DYNAMIC_OBJECT_ACTION_MOVE_DOWN_RIGHT 
			&& m_dynamicObjectModel->getState()!= DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_RIGHT)
		{
			startMove(DynamicObjectModel::DYNAMIC_OBJECT_STATE_MOVE_DOWN_RIGHT);
		}
	}
}
void AvatarController::updateState()
{
	AvatarModel::AvatarAction action = m_avatarModel->getAction();
	
	if (action == AvatarModel::AvatarAction::AVATAR_ACTION_IDLE )
	{
		//nothing to do
	}
	else
	{
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_DIE 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_DIE)
		{
			startDie();
		}

		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_UP 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP);
		
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_DOWN 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_LEFT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_RIGHT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_RIGHT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_UP_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_LEFT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_UP_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_RIGHT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_RIGHT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_DOWN_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_LEFT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_MOVE_DOWN_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_RIGHT)
		{
			startMove(AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_RIGHT);
		}
			if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_UP 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_DOWN 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_LEFT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_RIGHT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_RIGHT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_UP_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_LEFT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_UP_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_RIGHT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_RIGHT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_DOWN_LEFT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_LEFT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_LEFT);
		}
		if(action == AvatarModel::AvatarAction::AVATAR_ACTION_ATTACK_DOWN_RIGHT 
			&& m_avatarModel->getState()!= AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_RIGHT)
		{
			startAttack(AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_RIGHT);
		}
	}
}
Beispiel #23
0
void Nim::playNim() {
	if (_vm->_wonNim) { // Already won the game.
		_vm->_dialogs->displayScrollChain('Q', 6);
		return;
	}

	if (!_vm->_askedDogfoodAboutNim) {
		_vm->_dialogs->displayScrollChain('Q', 84);
		return;
	}

	_vm->_dialogs->displayScrollChain('Q', 3);
	_playedNim++;
	
	_vm->_graphics->saveScreen();
	_vm->fadeOut();

	CursorMan.showMouse(false);
	setup();
	board();
	//CursorMan.showMouse(true);

	do {
		
		startMove();
		if (_dogfoodsTurn)
			dogFood();
		else {
			CursorMan.showMouse(true);
			takeSome();
			CursorMan.showMouse(false);
		}
		_stones[_row] -= _number;
		showChanges();
	} while (_stonesLeft != 0);

	endOfGame(); // Winning sequence is A1, B3, B1, C1, C1, btw.

	_vm->fadeOut();
	_vm->_graphics->restoreScreen();
	_vm->_graphics->removeBackup();
	_vm->fadeIn();
	CursorMan.showMouse(true);

	if (_dogfoodsTurn) {
		// Dogfood won - as usual.
		if (_playedNim == 1)   // Your first game.
			_vm->_dialogs->displayScrollChain('Q', 4); // Goody! Play me again?
		else
			_vm->_dialogs->displayScrollChain('Q', 5); // Oh, look at that! I've won again!
		_vm->decreaseMoney(4); // And you've just lost 4d!
	} else {
		// You won - strange!
		_vm->_dialogs->displayScrollChain('Q', 7);
		_vm->_objects[kObjectLute - 1] = true;
		_vm->refreshObjectList();
		_vm->_wonNim = true;
		_vm->_background->draw(-1, -1, 0); // Show the settle with no lute on it.
		
		// 7 points for winning!
		_vm->incScore(7);
	}

	if (_playedNim == 1) {
		// 3 points for playing your 1st game.
		_vm->incScore(3);
	}
}
// Shortcut call for an instantly applied scaling of the current selection
void RadiantSelectionSystem::scaleSelected(const Vector3& scaling) {
    // Apply the transformation and freeze the changes
    startMove();
    scale(scaling);
    freezeTransforms();
}
// Shortcut call for an instantly applied translation of the current selection
void RadiantSelectionSystem::translateSelected(const Vector3& translation) {
    // Apply the transformation and freeze the changes
    startMove();
    translate(translation);
    freezeTransforms();
}
// Shortcut call for an instantly applied rotation of the current selection
void RadiantSelectionSystem::rotateSelected(const Quaternion& rotation) {
    // Apply the transformation and freeze the changes
    startMove();
    rotate(rotation);
    freezeTransforms();
}
void AvatarEntity::updateState()
{
	ActionManager::actions actions = Core::singleton().actionManager().getplayeractions(m_index);
	
	if (actions.up == false
		&& actions.defense == false
		&& actions.down == false
		&& actions.left == false
		&& actions.right == false
		&& actions.punch == false
		&& actions.kick == false
		&& actions.megapunch == false
		&& actions.up == false)
	{
		//si no hay accion debemos detener el movimiento 
		if(m_state == MOVE )
		{
			if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
			startIdle();
		}
		else if(m_state == DEFENSE)
		{
			startIdle();
		}
		else if(m_state == LOWER)
		{
			if(m_lowerSoundid != -1) stopSfxSound(m_lowerSoundid);
			startIdle();
		}
	}
	else
	{

		if(actions.punch == true && m_state == IDLE)
		{
			startPunch();
		}
		else if(actions.megapunch == true && m_state == IDLE)
		{
			startJab();
		}
		else if(actions.kick == true && m_state == IDLE)
		{
			startKick();
		}
		else if(actions.down == true && m_state == IDLE)
		{
			if(m_state != LOWER) startLower();
		}
		else if(actions.left == true && m_state!= JUMP && actions.up == false)
		{
			m_direction = -1;
			if(m_state == IDLE || m_state == DEFENSE) startMove();
		}
		else if(actions.right == true && m_state!= JUMP && actions.up == false)
		{
			m_direction = 1;
			if(m_state == IDLE || m_state == DEFENSE) startMove();
		}
		else if(actions.left == true && actions.up == true && (m_state == IDLE || m_state == MOVE))
		{
			m_direction = -1;
			if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
			startJump();
		}
		else if(actions.right == true && actions.up == true && (m_state == IDLE || m_state == MOVE))
		{
			m_direction = 1;
			if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
			startJump();
		}
		else if(actions.up == true && m_state == IDLE)
		{
			m_direction = 0;
			startJump();
		}

		else if(actions.defense == true && m_state == IDLE)
		{
			if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
			startDefense();
		}
	}

	m_action = IDLE_ACT;
}
void AvatarEntity::updateExternal(std::string message, float value)
{
	m_terrainPosition[0] = value;

	if(message == "idle#")
	{
		startIdle();
	}
	else if(message == "punch")
	{
		startPunch();
	}
	else if(message == "jab##")
	{
		startJab();
	}
	else if(message == "kick#")
	{
		startKick();
	}
	else if(message == "lower")
	{
		startLower();
	}
	else if(message == "loweS")
	{
		if(m_lowerSoundid != -1) stopSfxSound(m_lowerSoundid);
		startIdle();
	}
	else if(message == "move#")
	{
		startMove();
	}
	else if(message == "move-")
	{
		m_direction = -1;
	}
	else if(message == "move+")
	{
		m_direction = 1;
	}
	else if(message == "moveJ")
	{
		if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
		startJump();
	}
	else if(message == "moveS")
	{
		if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
		startIdle();
	}
	else if(message == "jump#")
	{
		startJump();
	}

	else if(message == "cover")
	{
		if(m_moveSoundid != -1) stopSfxSound(m_moveSoundid);
		startDefense();
	}

}