Esempio n. 1
0
void Player::CheckDamage(void)
{
    SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
    Game* pGame = Game::GetInstance();


    // dead, !hurt
    if (profile.health <= 0.0f)
    {
        profile.health = 0.0f;

        if (m_hHurt != nullptr && pAudio->IsAudioPlaying(*m_hHurt) == true)
            pAudio->StopAudio(*m_hHurt);

        if (pAudio->IsAudioPlaying(*m_hDeath) == false)
            voice = pAudio->PlayAudio(*m_hDeath, false);
        pAudio->SetVoiceVolume(voice);

        m_bIsAlive = false;

        SetVelocity({ 0, 0 });
    }

    // hurt, !dead
    else
    {
        int sound = rand() % 3;

        switch (sound)
        {
        case 0:
            m_hHurt = &pGame->playerHurt1;
            break;
        case 1:
            m_hHurt = &pGame->playerHurt2;
            break;
        case 2:
            m_hHurt = &pGame->playerHurt3;
            break;
        default:
            break;
        }

        if (pAudio->IsAudioPlaying(pGame->playerHurt1) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt2) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt3) == false)
            voice = pAudio->PlayAudio(*m_hHurt, false);
        pAudio->SetVoiceVolume(voice);

        m_hHurt = nullptr;
    }
}
Esempio n. 2
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;
}
Esempio n. 3
0
// Update
/*virtual*/ void IntroState::Update(float elapsedTime)
{
	SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();

	if (IntroTimer.GetTime() < 0.0f)
	{
		pAudio->StopAudio(m_hEmergency);

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

	if (IntroTimer.GetTime() < 25.0f)
	{
		if (ScreenTimer.GetTime() <= 0.0f && IntroTimer.GetTime() > 12.0f)
		{
			transBack -= 5;
			transTextFirst += 5;
			ScreenTimer.AddTime(.1f);
		}

		else if (IntroTimer.GetTime() < 12.0f)
		{
			if (ScreenTimer.GetTime() < 0.0f)
			{
				transText += 5;
				transTextFirst -= 5;
				ScreenTimer.AddTime(.1f);
			}

			//ScreenTimer.Update(elapsedTime);
		}
		
		ScreenTimer.Update(elapsedTime);
	}

	if (transBack <= 0)
	{
		transBack = 0;
	}

	if (transText >= 255)
	{
		transText = 255;
	}

	if (transTextFirst >= 255)
	{
		transTextFirst = 255;
	}

	if (transTextFirst < 0)
	{
		transTextFirst = 0;
	}

	IntroTimer.Update(elapsedTime);

	/*
	AnimationManager::GetInstance()->Update(animation, elapsedTime);

	if (starting_y == 120.0f)
	{
		Game::GetInstance()->RemoveState();
		Game::GetInstance()->AddState(GameplayState::GetInstance());
	}

	starting_y -= SCROLL_SPEED * elapsedTime;

	if (starting_y < 120.0f)
		starting_y = 120.0f;
	*/
}