BubbleBobbleRemake / BubbleBobble / GameOverComponent.cpp
GameOverComponent.cpp
Raw
#include "GameOverComponent.h"
#include "PlayerComponent.h"
#include "GameEvents.h"
#include "Scene.h"
#include "GameState.h"

dae::GameOverComponent::GameOverComponent()
{
}

dae::GameOverComponent::~GameOverComponent()
{
}

void dae::GameOverComponent::Initialize()
{
}

void dae::GameOverComponent::Reset()
{
	m_OutOfLivesCount = 0;
}

void dae::GameOverComponent::ReceiveNotification(unsigned eventId, Component* pComponent)
{
    auto pPlayerComponent = dynamic_cast<PlayerComponent*>(pComponent);
    if (pPlayerComponent != nullptr)
    {
        if (PlayerEvents(eventId) == PlayerEvents::OUT_OF_LIVES)
        {
            m_OutOfLivesCount++;

            if (GameState::GetInstance().GetGameMode() == GameMode::SINGLEPLAYER)
            {
                SceneManager::GetInstance().SetScene("GameOver", true);
            }
            else if (GameState::GetInstance().GetGameMode() == GameMode::COOP)
            {
                if (m_OutOfLivesCount >= 2)
                {
                    SceneManager::GetInstance().SetScene("GameOver", true);
                }
            }
        }
    }
}

void dae::GameOverComponent::Update(float )
{
}

void dae::GameOverComponent::FixedUpdate(float )
{
}