GameOver and WinScreen Added
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,22 @@
|
||||
#ifndef DAYDREAM_ECLUSTERCLEAR_H
|
||||
#define DAYDREAM_ECLUSTERCLEAR_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ClusterClear : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ECLUSTERCLEAR_H
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/FPSCounter.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -44,6 +46,8 @@ public:
|
||||
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScore, &HUD::OnScore);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -53,14 +57,32 @@ private:
|
||||
NumberFrame* m_StageNumberFrame = nullptr;
|
||||
NumberFrame* m_ScoreNumberFrame = nullptr;
|
||||
FPSCounter* m_FPSCounter = nullptr;
|
||||
TextureFrame* m_GameOverFrame = nullptr;
|
||||
TextureFrame* m_ClusterClearFrame = nullptr;
|
||||
|
||||
EventRelay<Frame, Events::ScoreEvent> m_EScore;
|
||||
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
{
|
||||
m_ScoreNumberFrame->SetNumber(m_ScoreNumberFrame->Number() + event.Score);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGameOver(const Events::GameOver& event)
|
||||
{
|
||||
m_GameOverFrame = new GUI::TextureFrame(this, "HUDGameOverFrame");
|
||||
m_GameOverFrame->SetTexture("Textures/GUI/HUD/GameOverScreen.png");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnClusterClear(const Events::ClusterClear& event)
|
||||
{
|
||||
m_ClusterClearFrame = new GUI::TextureFrame(this, "HUDGameOverFrame");
|
||||
m_ClusterClearFrame->SetTexture("Textures/GUI/HUD/WinScreen.png");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
//#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
@@ -62,11 +62,17 @@ void dd::Systems::BallSystem::Initialize()
|
||||
|
||||
void dd::Systems::BallSystem::Update(double dt)
|
||||
{
|
||||
if (Lives() < 0)
|
||||
if (Lives() == 0)
|
||||
{
|
||||
SetLives(3);
|
||||
Events::GameOver e;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
Events::Pause p;
|
||||
p.Type = "All";
|
||||
EventBroker->Publish(p);
|
||||
|
||||
//TODO: Make this not so ugly
|
||||
SetLives(-1);
|
||||
}
|
||||
ResolveContacts();
|
||||
}
|
||||
|
||||
@@ -414,7 +414,11 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
if (m_CurrentLevel < 6) {
|
||||
GetNextLevel();
|
||||
CreateLevel(12);
|
||||
}
|
||||
} else {
|
||||
// Win
|
||||
Events::ClusterClear e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user