Beispiel #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;
    }
}
// Enter
/*virtual*/ void IntroState::Enter(void)
{
	// Set background color
	SGD::GraphicsManager::GetInstance()->SetClearColor({ 0, 0, 0 });	// black


	//starting_y = Game::GetInstance()->GetScreenHeight() + 20.0F;// * 15.0F;// + 170.0F;



	// Load assets
	SGD::GraphicsManager*	pGraphics			= SGD::GraphicsManager::GetInstance();
	SGD::AudioManager*		pAudio				= SGD::AudioManager::GetInstance();
	AnimationManager*		pAnimationManager	= AnimationManager::GetInstance();

	//pAnimationManager->Load("resource/config/animations/Zombie_Animation_New.xml", "zombie");
	//animation.m_strCurrAnimation = "zombie";

	pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 35);

	m_hBackgroundImage = pGraphics->LoadTexture("resource/graphics/MenuImages/emergencybroadcast.png");
	m_hinstruct = SGD::GraphicsManager::GetInstance()->LoadTexture("resource/graphics/MenuImages/ArcadeControlsIcons.png");

	m_hEmergency = pAudio->LoadAudio("resource/audio/zombieemergency.wav");

	if (IntroTimer.GetTime() < 45.0f)
	{
		float newTime = 45.0f - IntroTimer.GetTime();

		IntroTimer.AddTime(newTime);
	}

	else if (IntroTimer.GetTime() <= 0.0f)
		IntroTimer.AddTime(45.0f);

	if (ScreenTimer.GetTime() < .1f)
	{
		float newTime = .1f - ScreenTimer.GetTime();

		ScreenTimer.AddTime(newTime);
	}

	else if (ScreenTimer.GetTime() <= 0.0f)
		ScreenTimer.AddTime(.1f);

	transBack = 255;
	transTextFirst = 0;
	transText = 0;

	//IntroTimer.AddTime(45.0f - IntroTimer.GetTime());
	//ScreenTimer.AddTime(.1f - ScreenTimer.GetTime());

	pAudio->PlayAudio(m_hEmergency, false);

	//m_hBackgroundImage	= pGraphics->LoadTexture("resource/graphics/youLose.png");

	//m_hBackgroundMusic = pAudio->LoadAudio("resource/audio/JNB_Credits_PinballGroove.xwm");
	//pAudio->PlayAudio(m_hBackgroundMusic);

}
// Exit
/*virtual*/ void IntroState::Exit(void)
{
	SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
	SGD::AudioManager * pAudio = SGD::AudioManager::GetInstance();

	// Unload assets
	pGraphics->UnloadTexture(m_hBackgroundImage);
	pGraphics->UnloadTexture(m_hinstruct);

	//pAudio->UnloadAudio(m_hBackgroundMusic);

	pAudio->UnloadAudio(m_hEmergency);

	pAudio->SetVoiceVolume(Game::GetInstance()->m_hMainVoice, 100);
}