Fixed so you don't randomly lose lives upon stage cleared. I think.
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "Game/EStickyPad.h"
|
#include "Game/EStickyPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EInkBlasterOver.h"
|
#include "Game/EInkBlasterOver.h"
|
||||||
|
#include "Game/EStageCleared.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
@@ -100,6 +101,7 @@ private:
|
|||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
bool m_InkAttached = false;
|
bool m_InkAttached = false;
|
||||||
bool m_BlockedWaiting = false;
|
bool m_BlockedWaiting = false;
|
||||||
|
bool m_Restarting = false;
|
||||||
int m_StickyCounter = 5;
|
int m_StickyCounter = 5;
|
||||||
|
|
||||||
glm::vec3 m_SavedSpeed;
|
glm::vec3 m_SavedSpeed;
|
||||||
@@ -120,6 +122,7 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
|
|
||||||
bool Contact(const Events::Contact &event);
|
bool Contact(const Events::Contact &event);
|
||||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
@@ -131,6 +134,7 @@ private:
|
|||||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
||||||
|
|
||||||
//OctoBall
|
//OctoBall
|
||||||
{
|
{
|
||||||
auto ent = m_World->CreateEntity();
|
auto ent = m_World->CreateEntity();
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
transform->Position = glm::vec3(-0.f, 50.26f, -10.f);
|
transform->Position = glm::vec3(0.f, 0.26f, -10.f);
|
||||||
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
|
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
|
||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
@@ -117,6 +118,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
if (ballComponent->Waiting) {
|
if (ballComponent->Waiting) {
|
||||||
if (!m_Waiting) {
|
if (!m_Waiting) {
|
||||||
|
m_Restarting = false;
|
||||||
ballComponent->Waiting = false;
|
ballComponent->Waiting = false;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||||
@@ -155,7 +157,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
Events::MultiBallLost e;
|
Events::MultiBallLost e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (Lives() == PastLives()) {
|
} else if (Lives() == PastLives() && !m_Restarting) {
|
||||||
Events::ResetBall be;
|
Events::ResetBall be;
|
||||||
EventBroker->Publish(be);
|
EventBroker->Publish(be);
|
||||||
Events::LifeLost e;
|
Events::LifeLost e;
|
||||||
@@ -471,3 +473,9 @@ bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &eve
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||||
|
{
|
||||||
|
m_Restarting = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user