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
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;
		}
	}
}