Added ScoreEvent, added score to bricks. Stage resets after all bricks are destroyed.
This commit is contained in:
@@ -194,7 +194,7 @@ public:
|
||||
|
||||
// Triggers commit events in systems
|
||||
// TODO: Replace completely by EComponentCreated?
|
||||
void CommitEntity(EntityID entity);
|
||||
int CommitEntity(EntityID entity);
|
||||
|
||||
/** Get all components of a specific type.
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ struct Brick : Component
|
||||
{
|
||||
int Points = 10;
|
||||
int Hits = 1;
|
||||
int Score = 50;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-15.
|
||||
// Created by Adniklastrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CLIFE_H
|
||||
|
||||
@@ -19,6 +19,10 @@ struct Pad : Component
|
||||
{
|
||||
int Lives;
|
||||
int Points;
|
||||
|
||||
float slowdownModifier = 5.f;
|
||||
float accelerationSpeed = 80.f;
|
||||
float maxSpeed = 40.f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-15.
|
||||
// Created by Adniklastrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ELIFELOST_H
|
||||
@@ -16,7 +16,7 @@ namespace Events
|
||||
|
||||
struct LifeLost : Event
|
||||
{
|
||||
EntityID entity;
|
||||
EntityID Entity;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERESETBALL_H
|
||||
#define DAYDREAM_ERESETBALL_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ResetBall : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERESETBALL_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ESCOREEVENT_H
|
||||
#define DAYDREAM_ESCOREEVENT_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ScoreEvent : Event
|
||||
{
|
||||
int score = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ESCOREEVENT_H
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Physics/CBoxShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
@@ -66,12 +68,16 @@ public:
|
||||
int lives = 3;
|
||||
int pastLives = 3;
|
||||
|
||||
int score = 0;
|
||||
|
||||
private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool LifeLost(const dd::Events::LifeLost &event);
|
||||
bool ScoreEvent(const dd::Events::ScoreEvent &event);
|
||||
|
||||
bool m_Initialized = false;
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
|
||||
|
||||
#include "Game/EResetBall.h"
|
||||
#include "CPad.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -46,28 +45,25 @@ private:
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<PadSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
|
||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||
bool OnKeyUp(const dd::Events::KeyUp &event);
|
||||
|
||||
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool LifeLost(const dd::Events::LifeLost &event);
|
||||
bool ResetBall(const dd::Events::ResetBall &event);
|
||||
|
||||
EntityID removeThisObject = NULL;
|
||||
|
||||
float slowdownModifier = 5.f;
|
||||
float accelerationSpeed = 80.f;
|
||||
float maxSpeed = 40.f;
|
||||
|
||||
|
||||
|
||||
class PadSteeringInputController;
|
||||
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
||||
|
||||
EntityID ent = 0;
|
||||
Components::Transform* transform;
|
||||
Components::Pad* pad;
|
||||
glm::vec3 acceleration = glm::vec3(0.f, 0.f, 0.f);
|
||||
bool left = false, right = false, replaceBall = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user