diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 49b5b48..1e90272 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -48,6 +48,7 @@ #include "Game/CLifebuoy.h" #include "Game/CProjectile.h" #include "Game/CBrick.h" +#include "Game/CBrickPart.h" #include "Game/CWall.h" #include "Game/CKraken.h" #include "Game/CBackground.h" @@ -144,6 +145,7 @@ public: m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); + m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); m_World->ComponentFactory.Register(); diff --git a/include/Game/BallSystem.h b/include/Game/BallSystem.h index f40ce54..ddee3fd 100644 --- a/include/Game/BallSystem.h +++ b/include/Game/BallSystem.h @@ -30,6 +30,8 @@ #include "Game/EStickyAttachedToPad.h" #include "Game/EInkBlaster.h" #include "Game/EInkBlasterOver.h" +#include "Game/EKrakenAttack.h" +#include "Game/EKrakenAttackEnd.h" #include "Game/EStageCleared.h" #include "Game/EArrivedAtNewStage.h" #include "Game/EGameOver.h" @@ -110,6 +112,8 @@ private: bool m_InkBlaster = false; bool m_InkAttached = false; bool m_InkBlockedWaiting = false; + bool m_KrakenAttack = false; + double m_KrakenCharge = 0; bool m_Restarting = false; int m_StickyCounter = 3; bool m_GodMode = false; @@ -131,6 +135,8 @@ private: dd::EventRelay m_EStickyPad; dd::EventRelay m_EInkBlaster; dd::EventRelay m_EInkBlasterOver; + dd::EventRelay m_EKrakenAttack; + dd::EventRelay m_EKrakenAttackEnd; dd::EventRelay m_EPause; dd::EventRelay m_EResume; dd::EventRelay m_Contact; @@ -146,6 +152,8 @@ private: bool OnStickyPad(const dd::Events::StickyPad &event); bool OnInkBlaster(const dd::Events::InkBlaster &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 OnResume(const dd::Events::Resume &event); bool OnActionButton(const dd::Events::ActionButton &event); diff --git a/include/Game/CBrickPart.h b/include/Game/CBrickPart.h new file mode 100644 index 0000000..ff7a532 --- /dev/null +++ b/include/Game/CBrickPart.h @@ -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 diff --git a/include/Game/EKrakenAttackEnd.h b/include/Game/EKrakenAttackEnd.h new file mode 100644 index 0000000..eee5889 --- /dev/null +++ b/include/Game/EKrakenAttackEnd.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 diff --git a/include/Game/GUI/HUD.h b/include/Game/GUI/HUD.h index fa12856..49310d4 100644 --- a/include/Game/GUI/HUD.h +++ b/include/Game/GUI/HUD.h @@ -51,6 +51,7 @@ public: EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver); EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear); EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack); + EVENT_SUBSCRIBE_MEMBER(m_KrakenAttackEnd, &HUD::OnKrakenAttackEnd); updateScore(); } @@ -71,6 +72,7 @@ private: EventRelay m_EGameOver; EventRelay m_ClusterClear; EventRelay m_KrakenAttack; + EventRelay m_KrakenAttackEnd; void updateScore() { @@ -122,6 +124,13 @@ private: return true; } + + bool OnKrakenAttackEnd(const Events::KrakenAttackEnd& event) + { + m_KrakenAttackSlider->Hide(); + + return true; + } }; } diff --git a/include/Game/KrakenSystem.h b/include/Game/KrakenSystem.h index 3f32cf7..12e3528 100644 --- a/include/Game/KrakenSystem.h +++ b/include/Game/KrakenSystem.h @@ -21,6 +21,8 @@ #include "Physics/ECreateParticleSequence.h" #include "Game/EPause.h" #include "Game/EResume.h" +#include "Game/EComboEvent.h" +#include "Game/EScoreEvent.h" #include "Game/EKrakenAppear.h" #include "Game/EKrakenAttack.h" #include "Game/EKrakenHit.h" @@ -29,6 +31,7 @@ #include "Game/CTravels.h" #include "Game/CKraken.h" #include "Game/CBall.h" +#include "Game/CProjectile.h" #include "Sound/CCollisionSound.h" //#include "Core/Camera.h" Camera Component diff --git a/include/Game/LevelSystem.h b/include/Game/LevelSystem.h index b93fc7b..cc5d75c 100755 --- a/include/Game/LevelSystem.h +++ b/include/Game/LevelSystem.h @@ -23,6 +23,7 @@ #include "Transform/EMove.h" #include "Game/CBrick.h" +#include "Game/CBrickPart.h" #include "Game/CBall.h" #include "Game/CLife.h" #include "Game/CWall.h" diff --git a/include/Game/PadSystem.h b/include/Game/PadSystem.h index e799045..656532f 100755 --- a/include/Game/PadSystem.h +++ b/include/Game/PadSystem.h @@ -43,6 +43,7 @@ #include "Game/EStickyAttachedToPad.h" #include "Game/EInkBlaster.h" #include "Game/EKrakenAttack.h" +#include "Game/EKrakenAttackEnd.h" #include "Game/EPowerUpTaken.h" #include "Game/EStageCleared.h" #include "Game/EPause.h" @@ -125,6 +126,7 @@ private: dd::EventRelay m_EPause; dd::EventRelay m_EResume; dd::EventRelay m_EKrakenAttack; + dd::EventRelay m_EKrakenAttackEnd; dd::EventRelay m_EStickyPad; dd::EventRelay m_EStickyAttachedToPad; dd::EventRelay m_EActionButton; @@ -142,6 +144,7 @@ private: bool OnPause(const dd::Events::Pause &event); bool OnResume(const dd::Events::Resume &event); bool OnKrakenAttack(const dd::Events::KrakenAttack &event); + bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event); bool OnStickyPad(const dd::Events::StickyPad &event); bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event); bool OnActionButton(const dd::Events::ActionButton &event); diff --git a/include/Game/ProjectileSystem.h b/include/Game/ProjectileSystem.h index 9491113..41e1900 100644 --- a/include/Game/ProjectileSystem.h +++ b/include/Game/ProjectileSystem.h @@ -19,6 +19,8 @@ #include "Game/EResume.h" #include "Game/EInkBlaster.h" #include "Game/EInkBlasterOver.h" +#include "Game/EKrakenAttack.h" +#include "Game/EKrakenAttackEnd.h" #include "Game/EActionButton.h" #include "Game/EHitPad.h" #include "Game/CProjectile.h" @@ -52,6 +54,7 @@ private: bool m_Pause = false; bool m_InkBlaster = false; bool m_SquidLoaded = false; + bool m_KrakenAttack = false; int m_Shots = 0; float m_InkBlasterSpeed = 5; EntityID m_InkBlastTemplate; @@ -61,6 +64,8 @@ private: dd::EventRelay m_EPause; dd::EventRelay m_EResume; dd::EventRelay m_EInkBlaster; + dd::EventRelay m_EKrakenAttack; + dd::EventRelay m_EKrakenAttackEnd; dd::EventRelay m_EHitPad; dd::EventRelay m_EActionButton; @@ -68,6 +73,8 @@ private: bool OnPause(const dd::Events::Pause &event); bool OnResume(const dd::Events::Resume &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 OnActionButton(const dd::Events::ActionButton &event); }; diff --git a/src/game/Game/BallSystem.cpp b/src/game/Game/BallSystem.cpp index b773370..a6c509e 100644 --- a/src/game/Game/BallSystem.cpp +++ b/src/game/Game/BallSystem.cpp @@ -21,6 +21,8 @@ void dd::Systems::BallSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad); EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster); 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_EResume, &BallSystem::OnResume); EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton); @@ -74,6 +76,11 @@ void dd::Systems::BallSystem::Update(double dt) { if (Lives() == 0) { + if (m_KrakenAttack) { + Events::KrakenAttackEnd e; + EventBroker->Publish(e); + } + Events::GameOver e; EventBroker->Publish(e); @@ -531,11 +538,25 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver 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) { - if (!m_StageBlockedWaiting) { - if (!m_InkBlockedWaiting) { - m_Waiting = false; + if (!m_KrakenAttack) { + if (!m_StageBlockedWaiting) { + if (!m_InkBlockedWaiting) { + m_Waiting = false; + } } } return true; diff --git a/src/game/Game/KrakenSystem.cpp b/src/game/Game/KrakenSystem.cpp index 56a1dae..b15499e 100644 --- a/src/game/Game/KrakenSystem.cpp +++ b/src/game/Game/KrakenSystem.cpp @@ -95,6 +95,7 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI } break; case 2: // Grabbing + m_NumberOfActions++; kraken->CurrentAction = 5; krakenAttack.ChargeUpdate = 0; krakenAttack.KrakenStrength = 0.1; @@ -103,6 +104,7 @@ void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityI break; case 3: // Brick Generating { + m_NumberOfActions++; kraken->CurrentAction = 1; Events::BrickGenerating e; e.Origin1 = glm::vec3(-5, 7, -10); @@ -185,8 +187,29 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event) return false; } + auto projectile = m_World->GetComponent(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(otherEntitiy); 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; e.Kraken = krakenEntity; e.Hitter = otherEntitiy; @@ -195,6 +218,7 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event) e.NewHealth = kraken->Health - 1; EventBroker->Publish(e); } + return true; } bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event) diff --git a/src/game/Game/LevelSystem.cpp b/src/game/Game/LevelSystem.cpp index 15f0e4d..0b59b5d 100755 --- a/src/game/Game/LevelSystem.cpp +++ b/src/game/Game/LevelSystem.cpp @@ -278,6 +278,15 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID } } + auto brickPart = m_World->GetComponent(entity); + if (brickPart != nullptr) { + auto transform = m_World->GetComponent(entity); + if (transform->Position.y < -10) { + m_World->RemoveEntity(entity); + return; + } + } + auto brick = m_World->GetComponent(entity); if (brick != nullptr) { auto transform = m_World->GetComponent(entity); @@ -310,6 +319,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID } m_LooseBricks--; m_World->RemoveEntity(entity); + return; } } @@ -908,6 +918,7 @@ bool dd::Systems::LevelSystem::OnPowerUpTaken(const dd::Events::PowerUpTaken &ev bool dd::Systems::LevelSystem::OnKrakenDefeated(const dd::Events::KrakenDefeated &event) { + m_BrickGenerating = false; SetNumberOfBricks(NumberOfBricks() - 1); m_LooseBricks--; @@ -1239,6 +1250,7 @@ void dd::Systems::LevelSystem::CreateBrokenModelPart(EntityID Parent, std::strin auto ent = m_World->CreateEntity(Parent); auto cTemplate = m_World->AddComponent(ent); auto cTransform = m_World->AddComponent(ent); + auto cBrickPart = m_World->AddComponent(ent); cTransform->Position = RelativePosition; diff --git a/src/game/Game/PadSystem.cpp b/src/game/Game/PadSystem.cpp index 1d365e1..b2ca20e 100755 --- a/src/game/Game/PadSystem.cpp +++ b/src/game/Game/PadSystem.cpp @@ -34,6 +34,7 @@ void dd::Systems::PadSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume); 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_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad); EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton); @@ -489,14 +490,22 @@ bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &even SetAcceleration(acceleration); } else if (m_KrakenCharge >= 1) { m_KrakenAttack = false; - m_KrakenCharge = 0; - m_KrakenStrength = 0; - m_PlayerStrength = 0; + Events::KrakenAttackEnd e; + EventBroker->Publish(e); + } + 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_KrakenArm = NULL; - } return true; } diff --git a/src/game/Game/ProjectileSystem.cpp b/src/game/Game/ProjectileSystem.cpp index eba7b43..05266e1 100644 --- a/src/game/Game/ProjectileSystem.cpp +++ b/src/game/Game/ProjectileSystem.cpp @@ -13,6 +13,8 @@ void dd::Systems::ProjectileSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause); EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume); 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_EActionButton, &ProjectileSystem::OnActionButton); @@ -113,34 +115,48 @@ bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event) 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) { - if (m_InkBlaster && m_SquidLoaded) { - auto ent = m_World->CloneEntity(m_InkBlastTemplate); - m_World->RemoveComponent(ent); - auto projectile = m_World->GetComponent(ent); - projectile->Speed = m_InkBlasterSpeed; - auto transform = m_World->GetComponent(ent); - transform->Position = event.Position; - transform->Velocity = glm::vec3(0, projectile->Speed, 0); - m_Shots--; - if (m_Shots <= 0) { - auto ball = m_World->GetComponent(m_AttachedSquid); - m_InkBlaster = false; - m_SquidLoaded = false; - ball->InkBlaster = false; - ball->Sticky = false; - ball->Waiting = true; - - { - Events::InkBlasterOver e; - e.Ball = m_AttachedSquid; - EventBroker->Publish(e); - } + if (!m_KrakenAttack) { + if (m_InkBlaster && m_SquidLoaded) { + auto ent = m_World->CloneEntity(m_InkBlastTemplate); + m_World->RemoveComponent(ent); + auto projectile = m_World->GetComponent(ent); + projectile->Speed = m_InkBlasterSpeed; + auto transform = m_World->GetComponent(ent); + transform->Position = event.Position; + transform->Velocity = glm::vec3(0, projectile->Speed, 0); + m_Shots--; + if (m_Shots <= 0) { + auto ball = m_World->GetComponent(m_AttachedSquid); + m_InkBlaster = false; + m_SquidLoaded = false; + ball->InkBlaster = false; + ball->Sticky = false; + ball->Waiting = true; + + { + Events::InkBlasterOver e; + e.Ball = m_AttachedSquid; + EventBroker->Publish(e); + } { Events::ActionButton e; EventBroker->Publish(e); } + } } } return true;