HitLagSystem implemented.
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
@@ -120,6 +121,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::BallSystem>(
|
||||
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::BallSystem>();
|
||||
m_World->SystemFactory.Register<Systems::HitLagSystem>(
|
||||
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::HitLagSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -77,10 +76,8 @@ public:
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool MultiBall() const { return m_MultiBall; }
|
||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||
bool Pause() const { return m_Pause; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
bool HitLag() const { return m_HitLag; }
|
||||
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||
|
||||
private:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
@@ -93,12 +90,6 @@ private:
|
||||
bool m_MultiBall = false;
|
||||
bool m_Pause = false;
|
||||
|
||||
bool m_HitLag = false;
|
||||
float m_Time;
|
||||
float m_SlowdownTime;
|
||||
float m_HitLagTimer = 0;
|
||||
float m_HitLagPlacement = 0;
|
||||
|
||||
EntityID m_Ball;
|
||||
|
||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
@@ -106,14 +97,12 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<BallSystem, dd::Events::HitLag> m_EHitLag;
|
||||
|
||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-30.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_HITLAGSYSTEM_H
|
||||
#define DAYDREAM_HITLAGSYSTEM_H
|
||||
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Game/PadSystem.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class HitLagSystem : public System
|
||||
{
|
||||
public:
|
||||
HitLagSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Update(double dt) override;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
bool HitLag() const { return m_HitLag; }
|
||||
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||
private:
|
||||
bool m_Pause;
|
||||
bool m_HitLag;
|
||||
float m_HitLagDuration;
|
||||
float m_HitLagTimer;
|
||||
|
||||
dd::EventRelay<HitLagSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<HitLagSystem, dd::Events::HitLag> m_EHitLag;
|
||||
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_HITLAGSYSTEM_H
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
||||
bool Initialized() const { return m_Initialized; }
|
||||
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
||||
bool Pause() const { return m_Pause; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
int& MultiBalls() { return m_MultiBalls; }
|
||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
Components::Pad* Pad() const { return m_Pad; }
|
||||
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
||||
|
||||
bool Pause() const { return m_Pause; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
@@ -56,10 +55,8 @@ public:
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
bool Pause() const { return m_Pause; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
bool HitLag() const { return m_HitLag; }
|
||||
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||
|
||||
private:
|
||||
b2Vec2 m_Gravity;
|
||||
@@ -68,16 +65,8 @@ private:
|
||||
double m_Accumulator;
|
||||
bool m_Pause = false;
|
||||
|
||||
bool m_HitLag = false;
|
||||
float m_Time;
|
||||
float m_SlowdownTime;
|
||||
float m_HitLagTimer = 0;
|
||||
float m_HitLagPlacement = 0;
|
||||
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::HitLag> m_EHitLag;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user