Merge remote-tracking branch 'origin' into Tobias
This commit is contained in:
+10
-6
@@ -48,12 +48,14 @@
|
|||||||
#include "Game/CLifebuoy.h"
|
#include "Game/CLifebuoy.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CBrickPart.h"
|
||||||
#include "Game/CWall.h"
|
#include "Game/CWall.h"
|
||||||
#include "Game/CKraken.h"
|
#include "Game/CKraken.h"
|
||||||
#include "Game/CBackground.h"
|
#include "Game/CBackground.h"
|
||||||
#include "Game/CTravels.h"
|
#include "Game/CTravels.h"
|
||||||
#include "Game/CStickyAim.h"
|
#include "Game/CStickyAim.h"
|
||||||
#include "Game/BallSystem.h"
|
#include "Game/BallSystem.h"
|
||||||
|
#include "Game/LifeSystem.h"
|
||||||
#include "Game/HitLagSystem.h"
|
#include "Game/HitLagSystem.h"
|
||||||
#include "Game/TravellingSystem.h"
|
#include "Game/TravellingSystem.h"
|
||||||
#include "Game/LifebuoySystem.h"
|
#include "Game/LifebuoySystem.h"
|
||||||
@@ -144,6 +146,7 @@ public:
|
|||||||
m_World->ComponentFactory.Register<Components::Physics>();
|
m_World->ComponentFactory.Register<Components::Physics>();
|
||||||
m_World->ComponentFactory.Register<Components::Ball>();
|
m_World->ComponentFactory.Register<Components::Ball>();
|
||||||
m_World->ComponentFactory.Register<Components::Brick>();
|
m_World->ComponentFactory.Register<Components::Brick>();
|
||||||
|
m_World->ComponentFactory.Register<Components::BrickPart>();
|
||||||
m_World->ComponentFactory.Register<Components::Pad>();
|
m_World->ComponentFactory.Register<Components::Pad>();
|
||||||
m_World->ComponentFactory.Register<Components::Wall>();
|
m_World->ComponentFactory.Register<Components::Wall>();
|
||||||
m_World->ComponentFactory.Register<Components::Background>();
|
m_World->ComponentFactory.Register<Components::Background>();
|
||||||
@@ -197,6 +200,9 @@ public:
|
|||||||
m_World->SystemFactory.Register<Systems::WaterSystem>(
|
m_World->SystemFactory.Register<Systems::WaterSystem>(
|
||||||
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
|
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
|
||||||
m_World->AddSystem<Systems::WaterSystem>();
|
m_World->AddSystem<Systems::WaterSystem>();
|
||||||
|
m_World->SystemFactory.Register<Systems::LifeSystem>(
|
||||||
|
[this]() { return new Systems::LifeSystem(m_World.get(), m_EventBroker); });
|
||||||
|
m_World->AddSystem<Systems::LifeSystem>();
|
||||||
|
|
||||||
m_World->ComponentFactory.Register<Components::Model>();
|
m_World->ComponentFactory.Register<Components::Model>();
|
||||||
m_World->ComponentFactory.Register<Components::Template>();
|
m_World->ComponentFactory.Register<Components::Template>();
|
||||||
@@ -364,13 +370,11 @@ public:
|
|||||||
job.ModelMatrix = modelMatrix * model->m_Matrix;
|
job.ModelMatrix = modelMatrix * model->m_Matrix;
|
||||||
job.Color = modelComponent->Color;
|
job.Color = modelComponent->Color;
|
||||||
|
|
||||||
if (model->m_Skeleton != nullptr) {
|
if (model->m_Skeleton != nullptr && animationComponent != nullptr) {
|
||||||
job.Skeleton = model->m_Skeleton;
|
job.Skeleton = model->m_Skeleton;
|
||||||
if (animationComponent != nullptr) {
|
job.AnimationName = animationComponent->Name;
|
||||||
job.AnimationName = animationComponent->Name;
|
job.AnimationTime = animationComponent->Time;
|
||||||
job.AnimationTime = animationComponent->Time;
|
job.NoRootMotion = animationComponent->NoRootMotion;
|
||||||
job.NoRootMotion = animationComponent->NoRootMotion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_RendererQueue.Deferred.Add(job);
|
m_RendererQueue.Deferred.Add(job);
|
||||||
|
|||||||
+18
-10
@@ -1,6 +1,8 @@
|
|||||||
#ifndef DAYDREAM_BALLSYSTEM_H
|
#ifndef DAYDREAM_BALLSYSTEM_H
|
||||||
#define DAYDREAM_BALLSYSTEM_H
|
#define DAYDREAM_BALLSYSTEM_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
@@ -8,14 +10,17 @@
|
|||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/ResourceManager.h"
|
#include "Core/ResourceManager.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
|
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/CRectangleShape.h"
|
#include "Physics/CRectangleShape.h"
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
|
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include "Rendering/CPointLight.h"
|
#include "Rendering/CPointLight.h"
|
||||||
#include "Rendering/CAnimation.h"
|
#include "Rendering/CAnimation.h"
|
||||||
|
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
#include "Game/CLife.h"
|
#include "Game/CLife.h"
|
||||||
@@ -30,6 +35,8 @@
|
|||||||
#include "Game/EStickyAttachedToPad.h"
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EInkBlasterOver.h"
|
#include "Game/EInkBlasterOver.h"
|
||||||
|
#include "Game/EKrakenAttack.h"
|
||||||
|
#include "Game/EKrakenAttackEnd.h"
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
#include "Game/EArrivedAtNewStage.h"
|
#include "Game/EArrivedAtNewStage.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
@@ -39,6 +46,7 @@
|
|||||||
#include "Game/EHitLag.h"
|
#include "Game/EHitLag.h"
|
||||||
#include "Game/EActionButton.h"
|
#include "Game/EActionButton.h"
|
||||||
#include "Game/ELifebuoyHit.h"
|
#include "Game/ELifebuoyHit.h"
|
||||||
|
|
||||||
#include "Physics/ECreateParticleSequence.h"
|
#include "Physics/ECreateParticleSequence.h"
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
|
|
||||||
@@ -75,7 +83,6 @@ public:
|
|||||||
void OnEntityRemoved(EntityID entity) override;
|
void OnEntityRemoved(EntityID entity) override;
|
||||||
|
|
||||||
EntityID CreateBall();
|
EntityID CreateBall();
|
||||||
void CreateLife(int);
|
|
||||||
EntityID Ball() { return m_Ball; };
|
EntityID Ball() { return m_Ball; };
|
||||||
void SetBall(const EntityID& ball) { m_Ball = ball; }
|
void SetBall(const EntityID& ball) { m_Ball = ball; }
|
||||||
|
|
||||||
@@ -87,22 +94,18 @@ public:
|
|||||||
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
||||||
int& MultiBalls() { return m_MultiBalls; }
|
int& MultiBalls() { return m_MultiBalls; }
|
||||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||||
int& Lives() { return m_Lives; }
|
|
||||||
void SetLives(const int& lives) { m_Lives = lives; }
|
|
||||||
int& PastLives() { return m_PastLives; }
|
|
||||||
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
|
||||||
bool ReplaceBall() const { return m_ReplaceBall; }
|
bool ReplaceBall() const { return m_ReplaceBall; }
|
||||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||||
bool IsPaused() const { return m_Pause; }
|
bool IsPaused() const { return m_Pause; }
|
||||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::mt19937 m_RandomGenerator;
|
||||||
|
|
||||||
float m_XMovementMultiplier = 2.f;
|
float m_XMovementMultiplier = 2.f;
|
||||||
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
|
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
|
||||||
float m_EdgeY = 5.2f;
|
float m_EdgeY = 5.2f;
|
||||||
int m_MultiBalls = 0;
|
int m_MultiBalls = 0;
|
||||||
int m_Lives = 3;
|
|
||||||
int m_PastLives = 3;
|
|
||||||
bool m_ReplaceBall = false;
|
bool m_ReplaceBall = false;
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
bool m_Waiting = true;
|
bool m_Waiting = true;
|
||||||
@@ -110,9 +113,12 @@ private:
|
|||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
bool m_InkAttached = false;
|
bool m_InkAttached = false;
|
||||||
bool m_InkBlockedWaiting = false;
|
bool m_InkBlockedWaiting = false;
|
||||||
|
bool m_KrakenAttack = false;
|
||||||
|
double m_KrakenCharge = 0;
|
||||||
bool m_Restarting = false;
|
bool m_Restarting = false;
|
||||||
int m_StickyCounter = 3;
|
int m_StickyCounter = 3;
|
||||||
bool m_GodMode = false;
|
|
||||||
|
bool m_First = true;
|
||||||
|
|
||||||
bool m_StageBlockedWaiting = false;
|
bool m_StageBlockedWaiting = false;
|
||||||
|
|
||||||
@@ -124,13 +130,14 @@ private:
|
|||||||
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
|
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
|
||||||
void ResolveContacts();
|
void ResolveContacts();
|
||||||
|
|
||||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
|
||||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||||
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||||
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Resume> m_EResume;
|
dd::EventRelay<BallSystem, dd::Events::Resume> m_EResume;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||||
@@ -139,13 +146,14 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||||
|
|
||||||
bool Contact(const Events::Contact &event);
|
bool Contact(const Events::Contact &event);
|
||||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
|
||||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||||
|
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||||
|
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnResume(const dd::Events::Resume &event);
|
bool OnResume(const dd::Events::Resume &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-21.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_CBRICKPART_H
|
||||||
|
#define DAYDREAM_CBRICKPART_H
|
||||||
|
|
||||||
|
#include "Core/Component.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct BrickPart : Component
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_CBRICKPART_H
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-21.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_EKRAKENATTACKEND_H
|
||||||
|
#define DAYDREAM_EKRAKENATTACKEND_H
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct KrakenAttackEnd : Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EKRAKENATTACKEND_H
|
||||||
@@ -51,6 +51,7 @@ public:
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttackEnd, &HUD::OnKrakenAttackEnd);
|
||||||
|
|
||||||
updateScore();
|
updateScore();
|
||||||
}
|
}
|
||||||
@@ -71,6 +72,7 @@ private:
|
|||||||
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||||
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
||||||
EventRelay<Frame, Events::KrakenAttack> m_KrakenAttack;
|
EventRelay<Frame, Events::KrakenAttack> m_KrakenAttack;
|
||||||
|
EventRelay<Frame, Events::KrakenAttackEnd> m_KrakenAttackEnd;
|
||||||
|
|
||||||
void updateScore()
|
void updateScore()
|
||||||
{
|
{
|
||||||
@@ -122,6 +124,13 @@ private:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OnKrakenAttackEnd(const Events::KrakenAttackEnd& event)
|
||||||
|
{
|
||||||
|
m_KrakenAttackSlider->Hide();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "Physics/ECreateParticleSequence.h"
|
#include "Physics/ECreateParticleSequence.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EResume.h"
|
#include "Game/EResume.h"
|
||||||
|
#include "Game/EComboEvent.h"
|
||||||
|
#include "Game/EScoreEvent.h"
|
||||||
#include "Game/EKrakenAppear.h"
|
#include "Game/EKrakenAppear.h"
|
||||||
#include "Game/EKrakenAttack.h"
|
#include "Game/EKrakenAttack.h"
|
||||||
#include "Game/EKrakenHit.h"
|
#include "Game/EKrakenHit.h"
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
#include "Game/CTravels.h"
|
#include "Game/CTravels.h"
|
||||||
#include "Game/CKraken.h"
|
#include "Game/CKraken.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
|
#include "Game/CProjectile.h"
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
//#include "Core/Camera.h" Camera Component
|
//#include "Core/Camera.h" Camera Component
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "Transform/EMove.h"
|
#include "Transform/EMove.h"
|
||||||
|
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CBrickPart.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Game/CLife.h"
|
#include "Game/CLife.h"
|
||||||
#include "Game/CWall.h"
|
#include "Game/CWall.h"
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_LIFESYSTEM_H
|
||||||
|
#define DAYDREAM_LIFESYSTEM_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/CTransform.h"
|
||||||
|
#include "Core/CTemplate.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/World.h"
|
||||||
|
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
|
||||||
|
#include "Transform/EMove.h"
|
||||||
|
#include "Rendering/CModel.h"
|
||||||
|
|
||||||
|
#include "Game/CLife.h"
|
||||||
|
#include "Game/EPause.h"
|
||||||
|
#include "Game/EResume.h"
|
||||||
|
#include "Game/ELifeLost.h"
|
||||||
|
#include "Game/EGameOver.h"
|
||||||
|
#include "Game/EKrakenAttackEnd.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
|
||||||
|
class LifeSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LifeSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||||
|
: System(world, eventBroker)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
void Initialize() override;
|
||||||
|
void Update(double dt) override;
|
||||||
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|
||||||
|
bool IsPaused() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
int& Lives() { return m_Lives; }
|
||||||
|
void SetLives(const int& lives) { m_Lives = lives; }
|
||||||
|
int& PastLives() { return m_PastLives; }
|
||||||
|
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_Pause = false;
|
||||||
|
int m_Lives = 3;
|
||||||
|
int m_PastLives = 3;
|
||||||
|
|
||||||
|
bool m_GodMode = false;
|
||||||
|
|
||||||
|
void CreateLife(int);
|
||||||
|
|
||||||
|
dd::EventRelay<LifeSystem, dd::Events::Pause> m_EPause;
|
||||||
|
dd::EventRelay<LifeSystem, dd::Events::Resume> m_EResume;
|
||||||
|
dd::EventRelay<LifeSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||||
|
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
|
bool OnResume(const dd::Events::Resume &event);
|
||||||
|
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_LIFESYSTEM_H
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "Game/EStickyAttachedToPad.h"
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EKrakenAttack.h"
|
#include "Game/EKrakenAttack.h"
|
||||||
|
#include "Game/EKrakenAttackEnd.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
@@ -126,6 +127,7 @@ private:
|
|||||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
|
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
|
||||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||||
|
dd::EventRelay<PadSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||||
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
|
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||||
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
|
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
|
||||||
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
@@ -143,6 +145,7 @@ private:
|
|||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnResume(const dd::Events::Resume &event);
|
bool OnResume(const dd::Events::Resume &event);
|
||||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||||
|
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||||
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "Game/EResume.h"
|
#include "Game/EResume.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EInkBlasterOver.h"
|
#include "Game/EInkBlasterOver.h"
|
||||||
|
#include "Game/EKrakenAttack.h"
|
||||||
|
#include "Game/EKrakenAttackEnd.h"
|
||||||
#include "Game/EActionButton.h"
|
#include "Game/EActionButton.h"
|
||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
@@ -52,6 +54,7 @@ private:
|
|||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
bool m_SquidLoaded = false;
|
bool m_SquidLoaded = false;
|
||||||
|
bool m_KrakenAttack = false;
|
||||||
int m_Shots = 0;
|
int m_Shots = 0;
|
||||||
float m_InkBlasterSpeed = 5;
|
float m_InkBlasterSpeed = 5;
|
||||||
EntityID m_InkBlastTemplate;
|
EntityID m_InkBlastTemplate;
|
||||||
@@ -61,6 +64,8 @@ private:
|
|||||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<ProjectileSystem, dd::Events::Resume> m_EResume;
|
dd::EventRelay<ProjectileSystem, dd::Events::Resume> m_EResume;
|
||||||
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||||
|
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||||
|
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||||
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
|
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
|
||||||
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
|
|
||||||
@@ -68,6 +73,8 @@ private:
|
|||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnResume(const dd::Events::Resume &event);
|
bool OnResume(const dd::Events::Resume &event);
|
||||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||||
|
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||||
|
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||||
bool OnHitPad(const dd::Events::HitPad &event);
|
bool OnHitPad(const dd::Events::HitPad &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Rendering/CAnimation.h"
|
#include "Rendering/CAnimation.h"
|
||||||
|
#include "Rendering/EAnimationComplete.h"
|
||||||
|
#include "Rendering/CModel.h"
|
||||||
|
#include "Rendering/Model.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EResume.h"
|
#include "Game/EResume.h"
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ struct Animation : Component
|
|||||||
std::string Name;
|
std::string Name;
|
||||||
double Time = 0.0;
|
double Time = 0.0;
|
||||||
double Speed = 0.0;
|
double Speed = 0.0;
|
||||||
|
bool Loop = true;
|
||||||
bool NoRootMotion = true;
|
bool NoRootMotion = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef RENDERING_EANIMATIONCOMPLETE_H__
|
||||||
|
#define RENDERING_EANIMATIONCOMPLETE_H__
|
||||||
|
|
||||||
|
#include "Core/Entity.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct AnimationComplete
|
||||||
|
{
|
||||||
|
EntityID Entity;
|
||||||
|
std::string Animation;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -12,15 +12,17 @@ void dd::Systems::BallSystem::RegisterComponents(ComponentFactory *cf)
|
|||||||
|
|
||||||
void dd::Systems::BallSystem::Initialize()
|
void dd::Systems::BallSystem::Initialize()
|
||||||
{
|
{
|
||||||
|
std::random_device rd;
|
||||||
|
m_RandomGenerator = std::mt19937(rd());
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_Contact, &BallSystem::Contact);
|
EVENT_SUBSCRIBE_MEMBER(m_Contact, &BallSystem::Contact);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, &BallSystem::OnLifeLost);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &BallSystem::OnKrakenAttack);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &BallSystem::OnKrakenAttackEnd);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &BallSystem::OnResume);
|
EVENT_SUBSCRIBE_MEMBER(m_EResume, &BallSystem::OnResume);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||||
@@ -35,6 +37,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
transform->Position = glm::vec3(-20.f, 0.26f, -10.f);
|
transform->Position = glm::vec3(-20.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);
|
||||||
|
transform->Orientation = glm::quat();
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
model->ModelFile = "Models/Sid/Sid.dae";
|
model->ModelFile = "Models/Sid/Sid.dae";
|
||||||
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
||||||
@@ -63,27 +66,11 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < Lives(); i++) {
|
SetReplaceBall(true);
|
||||||
CreateLife(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::Update(double dt)
|
void dd::Systems::BallSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
if (Lives() == 0)
|
|
||||||
{
|
|
||||||
Events::GameOver e;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
|
|
||||||
Events::Pause p;
|
|
||||||
p.Type = "All";
|
|
||||||
EventBroker->Publish(p);
|
|
||||||
|
|
||||||
//TODO: Make this not so ugly
|
|
||||||
SetLives(-1);
|
|
||||||
}
|
|
||||||
ResolveContacts();
|
ResolveContacts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +113,11 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
if (ReplaceBall()) {
|
if (ReplaceBall()) {
|
||||||
SetReplaceBall(false);
|
SetReplaceBall(false);
|
||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
|
std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
||||||
|
float random = dist(m_RandomGenerator);
|
||||||
|
ballComponent->SavedSpeed = glm::vec3(random, 1, 0.f);
|
||||||
ballComponent->Waiting = true;
|
ballComponent->Waiting = true;
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ballComponent->Waiting) {
|
if (ballComponent->Waiting) {
|
||||||
@@ -134,12 +125,17 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
m_Restarting = false;
|
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;
|
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
||||||
|
float random = dist(m_RandomGenerator);*/
|
||||||
|
transform->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
|
||||||
} else if (!ballComponent->Sticky) {
|
} else if (!ballComponent->Sticky) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||||
transform->Orientation = glm::quat();
|
if (m_First) {
|
||||||
|
transform->Orientation = glm::quat();
|
||||||
|
m_First = false;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +166,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() && !m_Restarting) {
|
} else if (!m_Restarting) { //If we lose lives when we shouldn't, look here.
|
||||||
Events::ResetBall be;
|
Events::ResetBall be;
|
||||||
EventBroker->Publish(be);
|
EventBroker->Publish(be);
|
||||||
Events::LifeLost e;
|
Events::LifeLost e;
|
||||||
@@ -197,16 +193,6 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Lives() != PastLives()) {
|
|
||||||
auto life = m_World->GetComponent<Components::Life>(entity);
|
|
||||||
if (life != nullptr) {
|
|
||||||
if (life->Number + 1 == PastLives()) {
|
|
||||||
m_World->RemoveEntity(entity);
|
|
||||||
SetPastLives(Lives());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ballComponent != nullptr) {
|
if (ballComponent != nullptr) {
|
||||||
if (!ballComponent->Sticky)
|
if (!ballComponent->Sticky)
|
||||||
{
|
{
|
||||||
@@ -433,31 +419,6 @@ EntityID dd::Systems::BallSystem::CreateBall()
|
|||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::CreateLife(int number)
|
|
||||||
{
|
|
||||||
auto life = m_World->CreateEntity();
|
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
|
||||||
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
|
||||||
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
|
||||||
|
|
||||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
|
||||||
lifeNr->Number = number;
|
|
||||||
|
|
||||||
auto model = m_World->AddComponent<Components::Model>(life);
|
|
||||||
model->ModelFile = "Models/Sid/Sid.dae";
|
|
||||||
|
|
||||||
|
|
||||||
m_World->CommitEntity(life);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
|
||||||
{
|
|
||||||
if (!m_GodMode){
|
|
||||||
SetLives(Lives() - 1);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event)
|
bool dd::Systems::BallSystem::OnMultiBallLost(const dd::Events::MultiBallLost &event)
|
||||||
{
|
{
|
||||||
SetMultiBalls(MultiBalls() - 1);
|
SetMultiBalls(MultiBalls() - 1);
|
||||||
@@ -531,11 +492,25 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
|
||||||
|
{
|
||||||
|
m_KrakenAttack = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
|
||||||
|
{
|
||||||
|
m_KrakenAttack = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (!m_StageBlockedWaiting) {
|
if (!m_KrakenAttack) {
|
||||||
if (!m_InkBlockedWaiting) {
|
if (!m_StageBlockedWaiting) {
|
||||||
m_Waiting = false;
|
if (!m_InkBlockedWaiting) {
|
||||||
|
m_Waiting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: // Grabbing
|
case 2: // Grabbing
|
||||||
|
m_NumberOfActions++;
|
||||||
kraken->CurrentAction = 5;
|
kraken->CurrentAction = 5;
|
||||||
krakenAttack.ChargeUpdate = 0;
|
krakenAttack.ChargeUpdate = 0;
|
||||||
krakenAttack.KrakenStrength = 0.1;
|
krakenAttack.KrakenStrength = 0.1;
|
||||||
@@ -103,6 +104,7 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI
|
|||||||
break;
|
break;
|
||||||
case 3: // Brick Generating
|
case 3: // Brick Generating
|
||||||
{
|
{
|
||||||
|
m_NumberOfActions++;
|
||||||
kraken->CurrentAction = 1;
|
kraken->CurrentAction = 1;
|
||||||
Events::BrickGenerating e;
|
Events::BrickGenerating e;
|
||||||
e.Origin1 = glm::vec3(-5, 7, -10);
|
e.Origin1 = glm::vec3(-5, 7, -10);
|
||||||
@@ -185,8 +187,29 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto projectile = m_World->GetComponent<Components::Projectile>(otherEntitiy);
|
||||||
|
if (projectile != nullptr) {
|
||||||
|
Events::ScoreEvent es;
|
||||||
|
es.Score = 23;
|
||||||
|
Events::KrakenHit e;
|
||||||
|
e.Kraken = krakenEntity;
|
||||||
|
e.Hitter = otherEntitiy;
|
||||||
|
e.MaxHealth = kraken->MaxHealth;
|
||||||
|
e.CurrentHealth = kraken->Health;
|
||||||
|
e.NewHealth = kraken->Health - 1;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
m_World->RemoveEntity(otherEntitiy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(otherEntitiy);
|
auto ball = m_World->GetComponent<Components::Ball>(otherEntitiy);
|
||||||
if (ball != nullptr) {
|
if (ball != nullptr) {
|
||||||
|
ball->Combo += 1;
|
||||||
|
Events::ComboEvent ec;
|
||||||
|
ec.Combo = ball->Combo;
|
||||||
|
ec.Ball = otherEntitiy;
|
||||||
|
EventBroker->Publish(ec);
|
||||||
|
Events::ScoreEvent es;
|
||||||
|
es.Score = ball->Combo * 23;
|
||||||
Events::KrakenHit e;
|
Events::KrakenHit e;
|
||||||
e.Kraken = krakenEntity;
|
e.Kraken = krakenEntity;
|
||||||
e.Hitter = otherEntitiy;
|
e.Hitter = otherEntitiy;
|
||||||
@@ -195,6 +218,7 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
e.NewHealth = kraken->Health - 1;
|
e.NewHealth = kraken->Health - 1;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event)
|
bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event)
|
||||||
|
|||||||
@@ -278,6 +278,15 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto brickPart = m_World->GetComponent<Components::BrickPart>(entity);
|
||||||
|
if (brickPart != nullptr) {
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
if (transform->Position.y < -10) {
|
||||||
|
m_World->RemoveEntity(entity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||||
if (brick != nullptr) {
|
if (brick != nullptr) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
@@ -310,6 +319,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
m_LooseBricks--;
|
m_LooseBricks--;
|
||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -909,6 +919,7 @@ bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &ev
|
|||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event)
|
bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event)
|
||||||
{
|
{
|
||||||
|
m_BrickGenerating = false;
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||||
m_LooseBricks--;
|
m_LooseBricks--;
|
||||||
|
|
||||||
@@ -1240,6 +1251,7 @@ void dd::Systems::LevelSystem::CreateBrokenModelPart(EntityID Parent, std::strin
|
|||||||
auto ent = m_World->CreateEntity(Parent);
|
auto ent = m_World->CreateEntity(Parent);
|
||||||
auto cTemplate = m_World->AddComponent<Components::Template>(ent);
|
auto cTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||||
auto cTransform = m_World->AddComponent<Components::Transform>(ent);
|
auto cTransform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
|
auto cBrickPart = m_World->AddComponent<Components::BrickPart>(ent);
|
||||||
|
|
||||||
cTransform->Position = RelativePosition;
|
cTransform->Position = RelativePosition;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-13.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "Game/LifeSystem.h"
|
||||||
|
|
||||||
|
void dd::Systems::LifeSystem::Initialize()
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LifeSystem::OnPause);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EResume, &LifeSystem::OnResume);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ELifeLost, &LifeSystem::OnLifeLost);
|
||||||
|
|
||||||
|
for (int i = 0; i < Lives(); i++) {
|
||||||
|
CreateLife(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::LifeSystem::Update(double dt)
|
||||||
|
{
|
||||||
|
if (m_Pause) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Lives() < 0) {
|
||||||
|
Events::KrakenAttackEnd ek;
|
||||||
|
EventBroker->Publish(ek);
|
||||||
|
|
||||||
|
Events::GameOver e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
Events::Pause p;
|
||||||
|
p.Type = "All";
|
||||||
|
EventBroker->Publish(p);
|
||||||
|
|
||||||
|
//TODO: Make this not so ugly
|
||||||
|
SetLives(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::LifeSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
|
{
|
||||||
|
if (m_Pause) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if (templateCheck != nullptr){ return; }
|
||||||
|
|
||||||
|
if (Lives() != PastLives()) {
|
||||||
|
auto life = m_World->GetComponent<Components::Life>(entity);
|
||||||
|
if (life != nullptr) {
|
||||||
|
if (life->Number + 1 == PastLives()) {
|
||||||
|
m_World->RemoveEntity(entity);
|
||||||
|
SetPastLives(Lives());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::LifeSystem::CreateLife(int number)
|
||||||
|
{
|
||||||
|
auto life = m_World->CreateEntity();
|
||||||
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
||||||
|
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
||||||
|
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||||
|
|
||||||
|
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||||
|
lifeNr->Number = number;
|
||||||
|
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(life);
|
||||||
|
model->ModelFile = "Models/Sid/Sid.dae";
|
||||||
|
|
||||||
|
m_World->CommitEntity(life);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::LifeSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
||||||
|
{
|
||||||
|
if (!m_GodMode){
|
||||||
|
SetLives(Lives() - 1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::LifeSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
/*if (event.Type != "LifeSystem" && event.Type != "All") {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
m_Pause = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool dd::Systems::LifeSystem::OnResume(const dd::Events::Resume &event)
|
||||||
|
{
|
||||||
|
/*if (event.Type != "LifeSystem" && event.Type != "All") {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
m_Pause = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume);
|
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &PadSystem::OnKrakenAttackEnd);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad);
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
|
||||||
@@ -508,16 +509,24 @@ bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &even
|
|||||||
SetAcceleration(acceleration);
|
SetAcceleration(acceleration);
|
||||||
} else if (m_KrakenCharge >= 1) {
|
} else if (m_KrakenCharge >= 1) {
|
||||||
m_KrakenAttack = false;
|
m_KrakenAttack = false;
|
||||||
m_KrakenCharge = 0;
|
Events::KrakenAttackEnd e;
|
||||||
m_KrakenStrength = 0;
|
EventBroker->Publish(e);
|
||||||
m_PlayerStrength = 0;
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PadSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
|
||||||
|
{
|
||||||
|
m_KrakenAttack = false;
|
||||||
|
m_KrakenCharge = 0;
|
||||||
|
m_KrakenStrength = 0;
|
||||||
|
m_PlayerStrength = 0;
|
||||||
|
|
||||||
m_World->RemoveEntity(m_KrakenArm);
|
m_World->RemoveEntity(m_KrakenArm);
|
||||||
m_World->RemoveEntity(m_KrakenArmHitbox);
|
m_World->RemoveEntity(m_KrakenArmHitbox);
|
||||||
m_KrakenArm = NULL;
|
m_KrakenArm = NULL;
|
||||||
m_KrakenArmHitbox = NULL;
|
m_KrakenArmHitbox = NULL;
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ void dd::Systems::ProjectileSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume);
|
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &ProjectileSystem::OnKrakenAttack);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttackEnd, &ProjectileSystem::OnKrakenAttackEnd);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
|
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
|
||||||
|
|
||||||
@@ -113,34 +115,48 @@ bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
|
||||||
|
{
|
||||||
|
m_KrakenAttack = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event)
|
||||||
|
{
|
||||||
|
m_KrakenAttack = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (m_InkBlaster && m_SquidLoaded) {
|
if (!m_KrakenAttack) {
|
||||||
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
if (m_InkBlaster && m_SquidLoaded) {
|
||||||
m_World->RemoveComponent<Components::Template>(ent);
|
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
||||||
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
|
m_World->RemoveComponent<Components::Template>(ent);
|
||||||
projectile->Speed = m_InkBlasterSpeed;
|
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
projectile->Speed = m_InkBlasterSpeed;
|
||||||
transform->Position = event.Position;
|
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
transform->Position = event.Position;
|
||||||
m_Shots--;
|
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||||
if (m_Shots <= 0) {
|
m_Shots--;
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
if (m_Shots <= 0) {
|
||||||
m_InkBlaster = false;
|
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||||
m_SquidLoaded = false;
|
m_InkBlaster = false;
|
||||||
ball->InkBlaster = false;
|
m_SquidLoaded = false;
|
||||||
ball->Sticky = false;
|
ball->InkBlaster = false;
|
||||||
ball->Waiting = true;
|
ball->Sticky = false;
|
||||||
|
ball->Waiting = true;
|
||||||
{
|
|
||||||
Events::InkBlasterOver e;
|
{
|
||||||
e.Ball = m_AttachedSquid;
|
Events::InkBlasterOver e;
|
||||||
EventBroker->Publish(e);
|
e.Ball = m_AttachedSquid;
|
||||||
}
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
Events::ActionButton e;
|
Events::ActionButton e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,8 +24,29 @@ void dd::Systems::AnimationSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& component : *animations) {
|
for (auto& component : *animations) {
|
||||||
auto animation = static_cast<Components::Animation*>(component.get());
|
EntityID ent = component->Entity;
|
||||||
animation->Time += animation->Speed * dt;
|
auto animationComponent = static_cast<Components::Animation*>(component.get());
|
||||||
|
|
||||||
|
// Get animation information
|
||||||
|
auto modelComponent = m_World->GetComponent<Components::Model>(ent);
|
||||||
|
auto model = ResourceManager::Load<Model>(modelComponent->ModelFile);
|
||||||
|
auto skeleton = model->m_Skeleton;
|
||||||
|
auto animation = skeleton->GetAnimation(animationComponent->Name);
|
||||||
|
|
||||||
|
if (animationComponent->Speed != 0.0) {
|
||||||
|
double nextTime = animationComponent->Time + animationComponent->Speed * dt;
|
||||||
|
if (glm::abs(nextTime) > animation->Duration) {
|
||||||
|
if (!animationComponent->Loop) {
|
||||||
|
animationComponent->Time = glm::sign(nextTime) * animation->Duration;
|
||||||
|
animationComponent->Speed = 0.0;
|
||||||
|
LOG_DEBUG("Animation \"%s\" on Entity %i finished.", animationComponent->Name.c_str(), ent);
|
||||||
|
Events::AnimationComplete e;
|
||||||
|
e.Entity = ent;
|
||||||
|
e.Animation = animationComponent->Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
animationComponent->Time = nextTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,6 +293,10 @@ dd::RawModel::RawModel(std::string fileName)
|
|||||||
Skeleton::Animation::Keyframe animationFrame;
|
Skeleton::Animation::Keyframe animationFrame;
|
||||||
animationFrame.Index = keyframe;
|
animationFrame.Index = keyframe;
|
||||||
animationFrame.Time = frameTimes[keyframe] / animation->mTicksPerSecond;
|
animationFrame.Time = frameTimes[keyframe] / animation->mTicksPerSecond;
|
||||||
|
// HACK: For some reason Blender likes to create a first frame that doesn't start at time 0
|
||||||
|
if (keyframe == 0) {
|
||||||
|
animationFrame.Time = 0;
|
||||||
|
}
|
||||||
for (auto &kv2 : kv.second) {
|
for (auto &kv2 : kv.second) {
|
||||||
int boneID = kv2.first;
|
int boneID = kv2.first;
|
||||||
auto &property = kv2.second;
|
auto &property = kv2.second;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ int dd::Skeleton::GetKeyframe(const Animation& animation, double time)
|
|||||||
|
|
||||||
for (int keyframe = 0; keyframe < animation.Keyframes.size(); ++keyframe) {
|
for (int keyframe = 0; keyframe < animation.Keyframes.size(); ++keyframe) {
|
||||||
if (animation.Keyframes[keyframe].Time > time)
|
if (animation.Keyframes[keyframe].Time > time)
|
||||||
return glm::max(0, keyframe - 1); // HACK: If the time is less than the first keyframe, don
|
return (keyframe - 1) % animation.Keyframes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user