diff --git a/include/Game/BallSystem.h b/include/Game/BallSystem.h index 235c882..f6d2da1 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" @@ -109,6 +111,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; @@ -130,6 +134,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; @@ -145,6 +151,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/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/KrakenSystem.h b/include/Game/KrakenSystem.h index 3f32cf7..960f14c 100644 --- a/include/Game/KrakenSystem.h +++ b/include/Game/KrakenSystem.h @@ -21,6 +21,7 @@ #include "Physics/ECreateParticleSequence.h" #include "Game/EPause.h" #include "Game/EResume.h" +#include "Game/EComboEvent.h" #include "Game/EKrakenAppear.h" #include "Game/EKrakenAttack.h" #include "Game/EKrakenHit.h" diff --git a/include/Game/LevelSystem.h b/include/Game/LevelSystem.h index b93fc7b..0907e75 100755 --- a/include/Game/LevelSystem.h +++ b/include/Game/LevelSystem.h @@ -143,7 +143,7 @@ private: bool m_Initialized = false; bool m_Pause = false; int m_LooseBricks = 0; - int m_CurrentCluster = 1; + int m_CurrentCluster = 0; int m_CurrentLevel = 1; int m_MultiBalls = 0; int m_PowerUps = 0; diff --git a/include/Game/PadSystem.h b/include/Game/PadSystem.h index 204b56f..7547e81 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" @@ -123,6 +124,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; @@ -140,6 +142,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 ad75c92..98ccea0 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); @@ -72,6 +74,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); @@ -526,11 +533,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..5b391bb 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); @@ -187,6 +189,11 @@ bool dd::Systems::KrakenSystem::OnContact(const dd::Events::Contact &event) 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::KrakenHit e; e.Kraken = krakenEntity; e.Hitter = otherEntitiy; diff --git a/src/game/Game/PadSystem.cpp b/src/game/Game/PadSystem.cpp index 3992565..ce25452 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); @@ -479,13 +480,21 @@ 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; + return true; +} + bool dd::Systems::PadSystem::OnStickyPad(const dd::Events::StickyPad &event) { 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;