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;
}
// 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 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;
}
Example #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;
}
Example #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();
}
Example #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
}
Example #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;
	}
}
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;
}
Example #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
}
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;
}
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());
	}
}
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;
	}
}
Example #13
0
void Console::Update(void)
{
	// keep track of the current line (first string in 'buffer_info')
	current_line = &buffer_info[0].line;
	// store a pointer to input manager
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();
	// store a value for the previous char
	static wchar_t char_prev = L'\0';

	// store a value for the current char
	wchar_t c = pInput->GetAnyCharDown();
	// if there is a character sitting in the input buffer, and it's not being held down...
	if (c && c != char_prev)
	{
		/*===================================================<AUTHORS NOTE>===================================================================*/
		/*                                                                                                                                    */
		/*       size checks occour inside 'if' checks to prevent falling to the final 'else' case, causeing new lines						  */
		/*       and backspace characters to be inserted into the new line																	  */
		/*                                                                                                                                    */
		/*====================================================================================================================================*/
		// ignore tilde characters
		if (c == '`' || c == '~')
			return;
		// if this character is a carrage return character...
		if (c == L'\r' )
		{
			// if the current line is empty..
			if (current_line->size() == 0)
			{
				// update previous character
				char_prev = c;
				// break out of this function
				return;
			}
			// allocate delimiters for string splitting
			char delim[] = { '(', ')', ',' };
			// split the current line into peices (commmand name and its parameters)
			vector<string> command = ParseCommand(*current_line, delim);
			// ensure we have a vaild command
			if (command.size() == 0)
			{
				WriteLine("Failed to parse command", SGD::Color::Red);
				char_prev = c;
				return;
			}
			// store the name of this command
			string command_name = command[0];
			// remove the command name from the data
			command.erase(command.begin());
			// allocate the params for this command (can't be stack allocated, as this memory will need to
			// be used later, but will be destroyed if left in stack memory)
			vector<string>* prams = new vector<string>;
			(*prams) = command;
			// dispatch an event, signaling a console command
			EventProc::GetInstance()->Dispatch(command_name.c_str(), (void*)prams, true);
			// end this line
			buffer_info.insert(buffer_info.begin(), { "", SGD::Color::White});

		}
		// if this is a backspace character...
		else if (c == L'\b')
		{
			// if the current line is empty...
			if (current_line->size() == 0)
			{
				// update previous character
				char_prev = c;
				// break out of this function
				return;
			}
			// delete the last character on the current line
			current_line->pop_back();
		}
		else
			// otherwise, just add this character to the current line
			current_line->push_back(char(c));		
	}
	// update the previous character
	char_prev = c;
}
Example #14
0
void Tower::Update(float dt)
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();
	SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();

	if (m_bSelected)
	{
		SGD::Point pos = SGD::Point(m_ptPosition.x - 96 - Camera::x, m_ptPosition.y - 128 - Camera::y);
		SGD::Point pos2 = pos + SGD::Vector(224, 128);

		SGD::Rectangle upgradeOneRect;
		upgradeOneRect.left = pos.x + 8;
		upgradeOneRect.top = pos.y + 8;
		upgradeOneRect.right = pos.x + 108;
		upgradeOneRect.bottom = pos.y + 72;

		SGD::Rectangle upgradeTwoRect;
		upgradeTwoRect.left = pos.x + 116;
		upgradeTwoRect.top = pos.y + 8;
		upgradeTwoRect.right = pos.x + 216;
		upgradeTwoRect.bottom = pos.y + 72;

		SGD::Rectangle sellButton;
		sellButton.right = pos2.x - 8;
		sellButton.bottom = pos2.y - 8;
		sellButton.left = pos2.x - 80;
		sellButton.top = pos2.y - 32;

		if (pInput->GetMousePosition().IsWithinRectangle(upgradeOneRect))
		{
			if (!m_bHoverOne)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverOne = true;
		}
		else
		{
			m_bHoverOne = false;
		}

		if (pInput->GetMousePosition().IsWithinRectangle(upgradeTwoRect))
		{
			if (!m_bHoverTwo)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverTwo = true;
		}
		else
		{
			m_bHoverTwo = false;
		}

		if (pInput->GetMousePosition().IsWithinRectangle(sellButton))
		{
			if (!m_bHoverSell)
				pAudio->PlayAudio(m_pTowerFlyweight->GetClickSound());

			m_bHoverSell = true;
		}
		else
		{
			m_bHoverSell = false;
		}
	}
}