bool CGamePlayState::Input(void)
{
    if(IsPaused())
        return true;

    CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();

    if( pDI->KeyPressed( DIK_ESCAPE )||
            pDI->JoystickButtonPressed(2) )
    {
        //m_bIsPaused = true;
        m_bDrawMouse = false;
        CGame::GetInstance()->PushState( CPauseState::GetInstance() );
    }

    if( pDI->KeyPressed( DIK_T ) )
        m_bRenderCulling = !m_bRenderCulling;

    //BUG - temp code added for AI testing
    //if( pDI->MouseButtonPressed( 0 ) )
    //{
    //	/*IUnitInterface* golem = MObjectManager::GetInstance()->GetUnit(120003);
    //	int cameraX = 0 , cameraY = 0 ;
    //			CGamePlayState::GetInstance()->GetCamera(cameraX , cameraY);
    //	int tileXPos = (int)((pDI->MouseGetPosX() + cameraX) / TILE_WIDTH.0f) ;
    //	int tileYPos = (int)((pDI->MouseGetPosY() + cameraY) / TILE_HEIGHT) ;
    //	((CBaseGolem*)(golem))->SetTargetPos(tileXPos, tileYPos);*/
    //}

    return true;
}
//Functions for every state
bool	CInstructions::Input			( )					 
{

	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();


	// Navigate the menu
	if(   (pDI->KeyPressed( DIK_D )  || pDI->JoystickGetLStickDirPressed( DIR_RIGHT, JOYSTICKID1 ) )  || ( pDI->KeyPressed( DIK_RIGHT ) || pDI->JoystickGetLStickDirPressed( DIR_RIGHT, JOYSTICKID2 )  ) )
	{
		++m_nCPos;
		if(m_nCPos > 2)
			m_nCPos = 2;

		CGame::GetInstance()->PlayMoveCursorSFX();
	}
	else if(  (pDI->KeyPressed( DIK_A )  || pDI->JoystickGetLStickDirPressed( DIR_LEFT, JOYSTICKID1 ) )  || ( pDI->KeyPressed( DIK_LEFT ) || pDI->JoystickGetLStickDirPressed( DIR_LEFT, JOYSTICKID2 )  ) )
	{
		--m_nCPos;
		if(m_nCPos < 0)
			m_nCPos = 0;

		CGame::GetInstance()->PlayMoveCursorSFX();
	}

	//Exiting out of the game with escape
	if( (pDI->KeyPressed( DIK_ESCAPE ) || pDI->JoystickButtonPressed( 2, JOYSTICKID1 ) ) ||  ( pDI->JoystickButtonPressed( 3, JOYSTICKID1 )  || pDI->JoystickButtonPressed( 3, JOYSTICKID2 ) ) )
	{
		CGame::GetInstance()->PopState();
		return true;
	}

	// Keep running
	return true;
}
示例#3
0
//Functions for every state
bool	CLoseGame::Input			( )					 
{

	CSGD_DirectInput*	pDI		=	CSGD_DirectInput::GetInstance();

	///Escape to exit
	if (pDI->JoystickButtonPressed( 3, 0 ) || pDI->JoystickButtonPressed( 3, 1 ) )
	{
		CGame::GetInstance()->ChangeState( CMainMenu::GetInstance() );
		return true;
	}
	else if (pDI->KeyPressed( DIK_ESCAPE ) == true || pDI->JoystickButtonPressed( 9, JOYSTICKID1 ) == true)
	{
			CGame::GetInstance()->ChangeState( CMainMenu::GetInstance() );
			return true;
	}

	// Keep running
	return true;
}
示例#4
0
//Functions for every state
bool	CMainMenu::Input			( )					 
{

	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();


	// Navigate the menu
	if(   (pDI->KeyPressed( DIK_S )  || pDI->JoystickGetLStickDirPressed( DIR_DOWN, JOYSTICKID1 ) )  || ( pDI->KeyPressed( DIK_DOWN ) || pDI->JoystickGetLStickDirPressed( DIR_DOWN, JOYSTICKID2 )  ) )
	{
		++m_nCursor;


		// Stop at the bottom
		if( m_nCursor > 7 )		
			m_nCursor = 0;
		
		CGame::GetInstance()->PlayMoveCursorSFX();
	}
	else if(  (pDI->KeyPressed( DIK_W )  || pDI->JoystickGetLStickDirPressed( DIR_UP, JOYSTICKID1 ) )  || ( pDI->KeyPressed( DIK_UP ) || pDI->JoystickGetLStickDirPressed( DIR_UP, JOYSTICKID2 )  ) )
	{
		--m_nCursor;


		// Stop at the top
		if( m_nCursor < 0 )		
			m_nCursor = 7;

		CGame::GetInstance()->PlayMoveCursorSFX();
	}


	// Handle the Enter key
	if( ( pDI->KeyPressed( DIK_TAB ) || pDI->JoystickButtonPressed( 1, JOYSTICKID1 ) ) || (pDI->KeyPressed( DIK_RETURN ) || pDI->JoystickButtonPressed( 1, JOYSTICKID2 )  ) )
	{
	// What selection?
		switch( m_nCursor )
		{
		case 0:			// Campaign Option
			{

				// Change the state to CGameplay Campaign Option
				m_bCampaign = true;
				m_bInGame = true;
				//CGamePlay::GetInstance();
				if (m_bArcadeMode == true)
				{
					CGame::GetInstance()->ChangeState( CArcadeGamePlay::GetInstance() );
					return true;	
				}
				else
				{
					CGame::GetInstance()->ChangeState( CGamePlay::GetInstance() );
					return true;	
				}
				
				

			}
			break;


		case 1:    //Versus
			{
				
				// Change the state to CGameplay Versus Option
				m_bInGame = true;
				m_bVersus = true;
				if (m_bArcadeMode == true)
				{
					CGame::GetInstance()->ChangeState( CArcadeGamePlay::GetInstance() );
					return true;	
				}
				else
				{
					CGame::GetInstance()->ChangeState( CWorldPlay::GetInstance() );
					return true;	
				}

			}
			break;

		case 2:    //Quick Match
			{

				// Change the state to CGameplay Quick Match option
				m_bQuickMatch = true;
				m_bInGame = true;
				if (m_bArcadeMode == true)
				{
					CGame::GetInstance()->ChangeState( CArcadeGamePlay::GetInstance() );
					return true;	
				}
				else
				{
					CGame::GetInstance()->ChangeState( CWorldPlay::GetInstance() );
					return true;	
				}

			}
			break;

		case 3:    //Load
			{

                CGame::GetInstance()->PushState( CLoadGame::GetInstance() );
				return true;
				
			}
			break;

		case 4:    //Instructions
			{

				CGame::GetInstance()->PushState( CInstructions::GetInstance() );
				return true;

			}
			break;
		case 5:   //Credits
			{
				CGame::GetInstance()->PushState( CCredits::GetInstance() );
				return true;
			}
			break;
		case 6:  //options
			{
				CGame::GetInstance()->PushState( COptions::GetInstance() );
			}
			break; //Exit
		case 7:
			{
				return false;
			}
			break;
		}
	}
	
	///Escape to exit
	if (pDI->JoystickButtonPressed( 3, 0 ) || pDI->JoystickButtonPressed( 3, 1 ) )
	{
		m_nCursor = 7;
		CGame::GetInstance()->PlayCancelSFX();
		return true;
	}
	else if (pDI->KeyPressed( DIK_ESCAPE ) == true || pDI->JoystickButtonPressed( 2, JOYSTICKID1 ) == true)
	{
		m_nCursor = 7;
		CGame::GetInstance()->PlayCancelSFX();
		return true;
	}
	// Keep running
	return true;
}
bool CSaveSlotState::Input(void)
{
	CGame* pGame = CGame::GetInstance();
	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();
	CGamePlayState* pGamePlay = CGamePlayState::GetInstance();
	CSGD_FModManager* FM = CSGD_FModManager::GetInstance();
	//Enter
	if(pDI->KeyPressed(DIK_RETURN) ||
		pDI->JoystickButtonPressed(0))
	{
		switch(m_nIndex)
		{
		case SELECT:
			{
				//Change to GamePlayState
				FM->StopSound( CMainMenuState::GetInstance()->GetSongID() );
				pGame->ChangeState(pGamePlay);
				break;
			}
		case SLOTDELETE:
			{
				Delete();
				break;
			}
		case BACK:
			{
				pGame->ChangeState(CMainMenuState::GetInstance());
				break;
			}
		};
	}

	//Directional
	//Up
	if(pDI->KeyPressed(DIK_UP) ||
	   pDI->JoystickGetLStickDirPressed(DIR_UP, 0))
	{
		FM->PlaySoundA(m_nSoundID);
		if(m_nIndex != 0)
			m_nIndex -= 1;
		else
			m_nIndex = NUMSLOTOPTIONS - 1;
	}
	//Down
	if(pDI->KeyPressed(DIK_DOWN) ||
		pDI->JoystickGetLStickDirPressed(DIR_DOWN, 0))
	{
		FM->PlaySoundA(m_nSoundID);
		if(m_nIndex != (NUMSLOTOPTIONS - 1))
			m_nIndex += 1;
		else
			m_nIndex = 0;
	}
	//Left
	if(pDI->KeyPressed(DIK_LEFT) ||
		pDI->JoystickGetLStickDirPressed(DIR_LEFT, 0))
	{
		SetSaveSlot(--m_nCurrSaveSlot);
		FM->PlaySoundA(m_nSoundID);
	}
	//Right
	if(pDI->KeyPressed(DIK_RIGHT) ||
		pDI->JoystickGetLStickDirPressed(DIR_RIGHT, 0))
	{
		SetSaveSlot(++m_nCurrSaveSlot);
		FM->PlaySoundA(m_nSoundID);
	}
	
	return true;
}