Ejemplo n.º 1
0
// Input
/*virtual*/ bool CreditsState::Input( void )
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();


	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsKeyPressed(SGD::Key::Enter) == true || pInput->IsButtonDown(0, 2) == true)
	{
		Game::GetInstance()->RemoveState();
		//Game::GetInstance()->AddState(MainMenuState::GetInstance());
	}


	return true;
}
bool QuickTimeState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if( pInput->IsKeyPressed( SGD::Key::Escape ) )
	{
		Game::GetInstance()->RemoveState();
	}

	if( SGD::InputManager::GetInstance()->IsControllerConnected( 0 ) || SGD::InputManager::GetInstance()->IsControllerConnected( 1 ) )
	{
		if( currentQT != nullptr )
		{
			if( pInput->IsButtonPressed( 0 , 0 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::Zero;
			}
			else if( pInput->IsButtonPressed( 0 , 1 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::One;

			}
			else if( pInput->IsButtonPressed( 0 , 2 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::Two;

			}
			else if( pInput->IsButtonPressed( 0 , 3 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::Three;

			}
			else if( pInput->IsButtonPressed( 0 , 4 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::Four;

			}
			else if( pInput->IsButtonPressed( 0 , 5 ) )
			{
				currentQT->m_kLastKeyPressed = SGD::Key::Five;
			}
			else
			{
				currentQT->m_kLastKeyPressed = SGD::Key::None;
			}
		}
	}
	else
	{
		if( currentQT != nullptr )
		{
			currentQT->m_kLastKeyPressed = pInput->GetAnyKeyPressed();
		}
	}

	return true;
}
bool AnimationTestState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if( pInput->IsKeyPressed(SGD::Key::Enter ))
	{
		RunQuickTime();
	}

	if (pInput->IsKeyPressed(SGD::Key::Escape))
	{
		Game::GetInstance()->RemoveState();
	}

	if( currentQT != nullptr )
	{
		currentQT->m_kLastKeyPressed = pInput->GetAnyKeyPressed();
	}
	

	return true;
}
Ejemplo n.º 4
0
// Input
/*virtual*/ bool IntroState::Input(void)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();
	SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();

	// Press Escape to quit
	if (pInput->IsKeyPressed(SGD::Key::Escape) == true || pInput->IsButtonPressed(0, 9) == true || pInput->IsButtonPressed(0, 2) == true)
	{

		//COMMENT IN WHEN AUDIO ADDED
		pAudio->StopAudio(m_hEmergency);

		Game::GetInstance()->RemoveState();
		Game::GetInstance()->AddState(GameplayState::GetInstance());
		return true;
	}



	// keep playing
	return true;
}
Ejemplo n.º 5
0
void Player::Update(float elapsedTime) {

	SGD::InputManager *ptInput = SGD::InputManager::GetInstance();

	if (ptInput->IsKeyPressed(SGD::Key::Space) || ptInput->IsKeyPressed(SGD::Key::W)) {
		m_bPendingJump = true;
	}

	Puff* ptPuff = dynamic_cast<Puff*>(GameplayState::GetInstance()->GetPuff());

	if (ptInput->IsKeyPressed(SGD::Key::MouseLeft)) {
		// Allocate a CreateLaserMessage

		CreateBulletMessage* pMsg = new CreateBulletMessage(

			ptPuff->GetPosition().x + ptPuff->GetSize().width / 4,
			ptPuff->GetPosition().y + ptPuff->GetSize().height / 4,
			//m_ptPosition.x + m_szSize.width / 2,
			//m_ptPosition.y + m_szSize.height / 2,

			m_fRotation, BULLET_A);

		// Queue the message into the Message System
		pMsg->QueueMessage();
		pMsg = nullptr;
	}

	//=============================================================
	// independent phycis timer/buffer
	//////////////////////////////////////////////////////////////
	m_fAccumulatedTime += elapsedTime;

	if (m_fAccumulatedTime < FRAME) return;

	elapsedTime = FRAME;

	while (m_fAccumulatedTime >= FRAME) {
		m_fAccumulatedTime -= FRAME;
	}
	//=============================================================
	// independent phycis timer/buffer
	//////////////////////////////////////////////////////////////

	if (ptInput->IsKeyDown(SGD::Key::A)) {
		m_bIsFlipped = true;

		if (m_fSpeed < m_fMaxSpeed) {
			m_fSpeed += m_fAccelerationRate * elapsedTime;
		}
		
	} 

	if (ptInput->IsKeyDown(SGD::Key::D)) {
		m_bIsFlipped = false;

		if (m_fSpeed > -m_fMaxSpeed) {
			m_fSpeed -= m_fAccelerationRate * elapsedTime;
		}
		
	} 
	//	left and right control
	if (!(ptInput->IsKeyDown(SGD::Key::D) || ptInput->IsKeyDown(SGD::Key::A))) {

		if (m_ptPosition.y + m_szSize.height / 2 == GameplayState::GetInstance()->GetWorldSize().height - m_fGroundOffset) {
			if (m_fSpeed > 0) {
				if (m_fSpeed - (m_fAccelerationRate * 2.0f) * elapsedTime < 0) {
					m_fSpeed = 0;
				} else {
					m_fSpeed -= (m_fAccelerationRate * 2.0f) * elapsedTime;
				}
			} else if (m_fSpeed < 0) {
				m_fSpeed += (m_fAccelerationRate * 2.0f) * elapsedTime;
			}
		}
	}


	if (m_bPendingJump) {	//pre-Jump trigger "space and w"
		if (m_ptPosition.y + m_szSize.height / 2 == GameplayState::GetInstance()->GetWorldSize().height - m_fGroundOffset) {
			m_vtVelocity.y = -1500.0f;
		}

		m_bPendingJump = false;
	}

	SGD::Vector vtNewVelocity{ -m_fSpeed, 0 };

	m_vtVelocity.x = vtNewVelocity.x;
 	m_vtVelocity += m_vtGravity;

	if (m_fSpeed > 0) {
		m_pCharaterAnim->Pause(false);
	} else if (m_fSpeed < 0) {
		m_pCharaterAnim->Pause(false);
	} else {
		m_pCharaterAnim->Pause(true);
		m_pCharaterAnim->Restart(true, 1.0f);
	}

	if (m_pCharaterAnim != nullptr) {
		m_pCharaterAnim->Update(elapsedTime, m_bIsFlipped);
		Entity::Update(elapsedTime);
	}
	StayInWorld();
}
Ejemplo n.º 6
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.º 7
0
void CProfileSelectState::MenuInput()
{
	SGD::InputManager* input = SGD::InputManager::GetInstance();

	if (state == MyState::ConfirmOverwrite)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
		{
			delete confirm;
			confirm = nullptr;
			CGameplayState::GetInstance()->DeleteProfile(currentProfile+1);
			profiles[currentProfile] = CreateProfile();
			TutorialConfirmation();
			break;
		}
		case 1:
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
		}
		case -1:
		default:
			break;
		}
		return;
	}

	if (state == MyState::ConfirmDelete)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
			CGameplayState::GetInstance()->DeleteProfile(currentProfile+1);
			profiles[currentProfile] = CreateProfile();
			//profiles[currentProfile].profile = currentProfile + 1;
			//Don't break! They both delete confirm and change state beck to menu
		case 1:
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			break;
		case -1:
		default:
			break;
		}
		return;
	}

	if (state == MyState::ConfirmTutorial)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
			profiles[currentProfile].currLevel = Level::Gen1;
		case 1:
			CGameplayState::GetInstance()->SetSaveData(profiles[currentProfile]);
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
			Game::GetInstance()->PushState(CGameplayState::GetInstance());
			break;
		case 2:
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			break;
		case -1:
		default:
			break;
		}
		return;
	}

#if ARCADE
	if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
	{
		state = MyState::Idle;
		return;
	}

	switch (menu->Input())
	{
	case 0:
		if (profiles[currentProfile].currLevel == Level::Tutorial)
		{
			TutorialConfirmation();
			break;
		}
		CGameplayState::GetInstance()->SetSaveData(profiles[currentProfile]);
		Game::GetInstance()->PopState();
		Game::GetInstance()->PopState();
		Game::GetInstance()->PushState(CGameplayState::GetInstance());
		break;
	case 1:
	{
		std::vector<std::string> yesno;
		yesno.push_back("Yes");
		yesno.push_back("No");
		confirm = new CMenu(&Game::GetInstance()->FontPoiret, yesno, "Overwrite?", { Game::GetInstance()->GetScreenWidth() * .55f, Game::GetInstance()->GetScreenHeight() * .6f }, false);
		state = MyState::ConfirmOverwrite;
		break;
	}
	case 2:
	{
		std::vector<std::string> yesno;
		yesno.push_back("Yes");
		yesno.push_back("No");
		confirm = new CMenu(&Game::GetInstance()->FontPoiret, yesno, "Delete?", { Game::GetInstance()->GetScreenWidth() * .55f, Game::GetInstance()->GetScreenHeight() * .6f }, false);
		state = MyState::ConfirmDelete;
		break;
	}
	case 3:
	{
		state = MyState::Idle;
		break;
	}
	case 4:
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		break;
	}
	case -1:
	default:
		break;
	}
}
Ejemplo n.º 8
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.º 9
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.º 10
0
bool LoadState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if (pInput->IsKeyPressed(SGD::Key::Escape) || pInput->IsButtonDown(0, 6))
	{
		Game::GetInstance()->RemoveState();
	}

	if (pInput->GetCursorMovement().x || pInput->GetCursorMovement().y)
	{
		if (pInput->GetCursorPosition().IsPointInRectangle(newRect))
			m_nCursor = 0;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot1))
			m_nCursor = 1;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot2))
			m_nCursor = 2;
		else if (pInput->GetCursorPosition().IsPointInRectangle(saveslot3))
			m_nCursor = 3;
		else if (pInput->GetCursorPosition().IsPointInRectangle(exit))
			m_nCursor = 4;
		else
			m_nCursor = -1;
	}
	if (m_fArcadeTimer >= 1.0f)
	{
		if (pInput->IsKeyPressed(SGD::Key::Left) || pInput->IsKeyPressed(SGD::Key::A) || pInput->GetLeftJoystick(0).x == -1)
		{
			m_nCursor--;
			if (m_nCursor < 0)
				m_nCursor = 4;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Right) || pInput->IsKeyPressed(SGD::Key::D) || pInput->GetLeftJoystick(0).x == 1)
		{
			m_nCursor++;
			if (m_nCursor > 4)
				m_nCursor = 0;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Up) || pInput->IsKeyPressed(SGD::Key::W) || pInput->GetLeftJoystick(0).y == -1)
		{
			m_nCursor--;
			if (m_nCursor < 0)
				m_nCursor = 4;

			m_fArcadeTimer = 0.0f;

		}
		else if (pInput->IsKeyPressed(SGD::Key::Down) || pInput->IsKeyPressed(SGD::Key::S) || pInput->GetLeftJoystick(0).y == 1)
		{
			m_nCursor++;
			if (m_nCursor > 4)
				m_nCursor = 0;

			m_fArcadeTimer = 0.0f;

		}
	}

	if (pInput->IsKeyPressed(SGD::Key::Enter) || pInput->IsKeyPressed(SGD::Key::MouseLeft) || pInput->IsButtonDown(0, 0))
	{
		switch (m_nCursor)
		{
		case 0:
			Game::GetInstance()->AddState(GameplayState::GetInstance());
			break;
		case 1:
			Load("resource/Save/Save.xml");
			break;
		case 2:
			Load2("resource/Save/Save2.xml");
			break;
		case 3:
			Load3("resource/Save/Save3.xml");
			break;
		case 4:
			Game::GetInstance()->RemoveState();
			break;
		default:
			break;
		}
	}

	return true;
}
Ejemplo n.º 11
0
void WeaponManager::Input()
{
	SGD::InputManager * pInput = SGD::InputManager::GetInstance();
	SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();

	if (pInput->IsKeyPressed(SGD::Key::Q) == true || pInput->IsButtonPressed(0, 4) == true || mousewheel < 0)
	{
		curIndex--;

		if (curIndex < 0)
		{
			curIndex = m_vWeapons.size() - 1;
		}


		if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
		{
			pAudio->PlayAudio(m_hWpnSwitch, false);
		}

		while (m_vWeapons[curIndex]->GetEquipped() != true)
		{
			curIndex--;

			if (curIndex < 0)
			{
				curIndex = m_vWeapons.size() - 1;
			}
		}

		mousewheel = 0;
	}

	if (pInput->IsKeyPressed(SGD::Key::E) == true || pInput->IsButtonPressed(0, 5) == true || mousewheel > 0)
	{
		curIndex++;


		if (curIndex > (int)m_vWeapons.size() - 1)
		{
			curIndex = 0;
		}

		if (pAudio->IsAudioPlaying(m_hWpnSwitch) == false)
		{
			pAudio->PlayAudio(m_hWpnSwitch, false);
		}

		while (m_vWeapons[curIndex]->GetEquipped() != true)
		{
			curIndex++;

			if (curIndex > (int)m_vWeapons.size() - 1)
			{
				curIndex = 0;
			}
		}

		mousewheel = 0;
	}

	if (pInput->IsKeyPressed(SGD::Key::R) == true && m_vWeapons[curIndex]->GetCurrAmmo() < m_vWeapons[curIndex]->GetMagSize())
	{
		//GetSelected()->SetCurrAmmo(0);
		GetSelected()->GetReloadTimer().AddTime(GetSelected()->GetReloadTime());
		//m_vWeapons[curIndex]->SetCurrAmmo(0);
		//m_vWeapons[curIndex]->GetReloadTimer().AddTime(m_vWeapons[curIndex]->GetReloadTime());
	}
}
Ejemplo n.º 12
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;
	}
}