Ejemplo n.º 1
0
void CProfileSelectState::SeletionInput()
{
	SGD::InputManager* input = SGD::InputManager::GetInstance();
#if ARCADE
	if (input->IsButtonPressed(0, 6) || input->IsButtonPressed(1, 6) || input->IsButtonPressed(0, 2) || input->IsButtonPressed(1, 2))
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		return;
	}

	SGD::Vector joy1 = input->GetLeftJoystick(0);
	SGD::Vector joy2 = input->GetLeftJoystick(1);
	if (joy1.x > 0 || joy2.x > 0)
	{
		if (currentProfile >= 2)
			currentProfile = 0;
		else
			currentProfile++;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (joy1.x < 0 || joy2.x < 0)
	{
		if (currentProfile <= 0)
			currentProfile = 2;
		else
			currentProfile--;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsButtonPressed(0, 0) || input->IsButtonPressed(1, 0))
	{
		state = MyState::Menu;
	}

	if (input->IsKeyPressed(SGD::Key::MouseLeft))
	{
		SGD::Point mouse = input->GetMousePosition();
		if (mouse.IsWithinRectangle(SGD::Rectangle{ current, profileSize }))
		{
			state = MyState::Menu;
			return;
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ next, profileSize }))
		{
			if (currentProfile >= 2)
				currentProfile = 0;
			else
				currentProfile++;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ previous, profileSize }))
		{
			if (currentProfile <= 0)
				currentProfile = 2;
			else
				currentProfile--;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
	}
#else
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		return;
	}

	if (input->IsKeyPressed(SGD::Key::RightArrow) || input->IsDPadPressed(0, SGD::DPad::Right))
	{
		if (currentProfile >= 2)
			currentProfile = 0;
		else
			currentProfile++;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsKeyPressed(SGD::Key::LeftArrow) || input->IsDPadPressed(0, SGD::DPad::Left))
	{
		if (currentProfile <= 0)
			currentProfile = 2;
		else
			currentProfile--;
		state = MyState::Transition;
		transTimer = 0;
		CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
	}
	if (input->IsKeyPressed(SGD::Key::Enter) || input->IsButtonPressed(0, 0))
	{
		state = MyState::Menu;
	}

	if (input->IsKeyPressed(SGD::Key::MouseLeft))
	{
		SGD::Point mouse = input->GetMousePosition();
		if (mouse.IsWithinRectangle(SGD::Rectangle{ current, profileSize }))
		{
			state = MyState::Menu;
			return;
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ next, profileSize }))
		{
			if (currentProfile >= 2)
				currentProfile = 0;
			else
				currentProfile++;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
		if (mouse.IsWithinRectangle(SGD::Rectangle{ previous, profileSize }))
		{
			if (currentProfile <= 0)
				currentProfile = 2;
			else
				currentProfile--;
			state = MyState::Transition;
			transTimer = 0;
			CSoundBox::GetInstance()->Play((int)CSoundBox::sounds::uiSwish, false);
		}
	}
#endif
}
Ejemplo n.º 2
0
// Input
/*virtual*/ bool PauseState::Input(void)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();


	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsButtonPressed(0, 2) == true)
	{
		SGD::Event msg("UNPAUSE");
		msg.SendEventNow();
		Game::GetInstance()->RemoveState();

		return true;
	}


	if (pInput->IsKeyPressed(SGD::Key::Down) == true || pInput->IsDPadPressed(0, SGD::DPad::Down) == true)
		m_nCursor = m_nCursor + 1 < NUM_CHOICES ? m_nCursor + 1 : 0;
	else if (pInput->IsKeyPressed(SGD::Key::Up) == true || pInput->IsDPadPressed(0, SGD::DPad::Up) == true)
		m_nCursor = m_nCursor - 1 >= 0 ? m_nCursor - 1 : NUM_CHOICES - 1;


	if (pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonDown(0, 1) == true)
	{

		switch (m_nCursor)
		{
		case 0: // gameplay
		{
					SGD::Event msg("UNPAUSE");
					msg.SendEventNow();
					Game::GetInstance()->RemoveState();

					return true;
		}
			break;

		case 1: // controls
		{
					Game::GetInstance()->AddState(HowToPlayState::GetInstance());
					return true;
		}
			break;
		case 2: // options
			
		{
					//Game::GetInstance()->RemoveState();
					//Game::GetInstance()->RemoveState();
					//Game::GetInstance()->AddState(GameplayState::GetInstance());
					Game::GetInstance()->AddState(OptionsState::GetInstance());
					return true;
		}
			break;
		case 3: // main menu
		{
					if (HTPGameState::GetInstance()->GetChoiceScreen() == true)
					{
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->AddState(MainMenuState::GetInstance());
						return true;
					}

					else
					{
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->RemoveState();
						Game::GetInstance()->AddState(IntroState::GetInstance());
						return true;
					}
		}
			break;
		}
	}


	return true;	// keep playing
}
Ejemplo n.º 3
0
bool PickSaveSlotState::Input(void)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsButtonPressed(0, 2) == true)
	{
		if (modeChosen)
			m_nCursor = MenuItems::EXIT_2;
		else
			m_nCursor = States::EXIT_1;

	}
		
	//return false;	// quit game

	


	if (modeChosen == false)
	{
		if (pInput->IsKeyPressed(SGD::Key::Down) == true || pInput->IsDPadPressed(0, SGD::DPad::Down) == true)
			m_nCursor = m_nCursor + 1 < MODE_CHOICES ? m_nCursor + 1 : 0;

		else if (pInput->IsKeyPressed(SGD::Key::Up) == true || pInput->IsDPadPressed(0, SGD::DPad::Up) == true)
			m_nCursor = m_nCursor - 1 >= 0 ? m_nCursor - 1 : MODE_CHOICES - 1;


		if (pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonPressed(0, 1) == true)
		{
			if (m_nCursor == NEW_GAME)
			{
				currState = NEW_GAME;
				modeChosen = true;
			}
			
			else if (m_nCursor == LOAD_GAME)
			{
				currState = LOAD_GAME;
				modeChosen = true;
			}
			else if (m_nCursor == DELETE_SAVES)
			{
				currState = DELETE_SAVES;
				modeChosen = true;
			}

			else if (m_nCursor == EXIT_1)
				Game::GetInstance()->RemoveState();

			m_nCursor = 0;
			
		}
	}
	else
	{

		if (pInput->IsKeyPressed(SGD::Key::Down) == true || pInput->IsDPadPressed(0, SGD::DPad::Down) == true)
			m_nCursor = m_nCursor + 1 < NUM_CHOICES ? m_nCursor + 1 : 0;

		else if (pInput->IsKeyPressed(SGD::Key::Up) == true || pInput->IsDPadPressed(0, SGD::DPad::Up) == true)
			m_nCursor = m_nCursor - 1 >= 0 ? m_nCursor - 1 : NUM_CHOICES - 1;


		if (pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonPressed(0, 1) == true)
		{
			switch (m_nCursor)
			{
			case MenuItems::SAVE1:
			case MenuItems::SAVE2:
			case MenuItems::SAVE3:
			{
									 Game::GetInstance()->selectedProfile = m_nCursor;

									 if (currState == NEW_GAME || currState == DELETE_SAVES)
									 {
										
											 if (GameplayState::GetInstance()->GetGameMode() == true)
											 {
												 Game::GetInstance()->OverWriteProfile(Game::GetInstance()->GetStoryProfile());
												 Game::GetInstance()->LoadStoryProfiles();
											 }
											 else
											 {
												 Game::GetInstance()->OverWriteProfile(Game::GetInstance()->GetSurvivalProfile());
												 Game::GetInstance()->LoadSurvivalProfiles();
											 }

											 if (currState == DELETE_SAVES)
											 {
												 // Load assets
												 if (GameplayState::GetInstance()->GetGameMode())
												 {
													 for (unsigned int i = 0; i < 3; i++)
													 {
														 profiles[i] = Game::GetInstance()->GetSpecStoryProfile(i);
													 }

												 }
												 else
												 {
													 for (unsigned int i = 0; i < 3; i++)
													 {
														 profiles[i] = Game::GetInstance()->GetSpecSurvialProfile(i);
													 }
												 }
											 }
										 

									 }
									 if (currState == NEW_GAME || currState == LOAD_GAME)
									 {
										 Game::GetInstance()->RemoveState();
										 Game::GetInstance()->RemoveState();
										 //			Game::GetInstance()->AddState(GameplayState::GetInstance());

										 if (GameplayState::GetInstance()->GetGameMode() == true)
											 Game::GetInstance()->AddState(HTPGameState::GetInstance());
										 else
											 Game::GetInstance()->AddState(GameplayState::GetInstance());

										 return true;
									 }
										
									 
									
									 return true;
									 
									
									
			}
				break;


			case MenuItems::EXIT_2:
				Game::GetInstance()->RemoveState();
				return true;

				break;
			}

		}
	}


	return true;
}
Ejemplo n.º 4
0
void OptionsState::Update(float dt)
{
	if (dt <= 0.0)
		return;
	SGD::InputManager * input = SGD::InputManager::GetInstance();
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 2))
	{
		GameData::GetInstance()->SwapState(MainMenuState::GetInstance());
		GameData::GetInstance()->PlayCancel();
	}
	if (menuindex == 0)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Left) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x < 0 || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			bool is = GameData::GetInstance()->GetFont()->IsSpanish();
			GameData::GetInstance()->GetFont()->SetSpanish(!is);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 1)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsDPadPressed(0, SGD::DPad::Left) || input->GetLeftJoystick(0).x < 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetMusicVolume(GameData::GetInstance()->GetMusicVolume() - 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
		else if ((input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetMusicVolume(GameData::GetInstance()->GetMusicVolume() + 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 2)
	{
		if ((input->IsKeyPressed(SGD::Key::Left) || input->IsDPadPressed(0, SGD::DPad::Left) || input->GetLeftJoystick(0).x < 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetEffectVolume(GameData::GetInstance()->GetEffectVolume() - 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
		else if ((input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Right) || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->SetEffectVolume(GameData::GetInstance()->GetEffectVolume() + 5);
			GameData::GetInstance()->PlaySelectionChange();
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 3)
	{
		if ((input->IsKeyPressed(SGD::Key::Enter) || input->IsKeyPressed(SGD::Key::Left) || input->IsKeyPressed(SGD::Key::Right) || input->IsDPadPressed(0, SGD::DPad::Left) || input->IsDPadPressed(0, SGD::DPad::Right) || input->IsButtonPressed(0, 1) || input->GetLeftJoystick(0).x < 0 || input->GetLeftJoystick(0).x > 0) && GameData::GetInstance()->input_timer < 0)
		{
			GameData::GetInstance()->PlaySelectionChange();
			bool is = GameData::GetInstance()->GetWindowed();
			GameData::GetInstance()->SetWindowed(!is);
			SGD::GraphicsManager::GetInstance()->Resize({ GameData::GetInstance()->GetScreenWidth(), GameData::GetInstance()->GetScreenHeight() }, GameData::GetInstance()->GetWindowed());
			GameData::GetInstance()->input_timer = 0.15f;
		}
	}
	if (menuindex == 4)
	{
		if (input->IsKeyPressed(SGD::Key::Enter) || input->IsButtonPressed(0,1))
		{
			GameData::GetInstance()->PlayCancel();
			GameData::GetInstance()->SwapState(MainMenuState::GetInstance());
			
		}
		
	}







	if ((input->IsKeyPressed(SGD::Key::Up) || input->IsDPadPressed(0, SGD::DPad::Up) || input->GetLeftJoystick(0).y < 0) && GameData::GetInstance()->input_timer < 0)
	{
		menuindex--;
		if (menuindex < 0)
			menuindex = maxindex;
		GameData::GetInstance()->PlaySelectionChange();
		GameData::GetInstance()->input_timer = 0.15f;
	}
	if ((input->IsKeyPressed(SGD::Key::Down) || input->IsDPadPressed(0, SGD::DPad::Down) || input->GetLeftJoystick(0).y > 0) && GameData::GetInstance()->input_timer < 0)
	{
		menuindex++;
		if (menuindex > maxindex)
			menuindex = 0;
		GameData::GetInstance()->PlaySelectionChange();
		GameData::GetInstance()->input_timer = 0.15f;
	}
}