diff --git a/include/Game/BallSystem.h b/include/Game/BallSystem.h index 1f9aa30..b6d312a 100644 --- a/include/Game/BallSystem.h +++ b/include/Game/BallSystem.h @@ -35,6 +35,7 @@ #include "Game/EHitLag.h" #include "Game/EActionButton.h" #include "Game/ELifebuoyHit.h" +#include "Physics/ECreateParticleSequence.h" namespace dd { diff --git a/include/Physics/PhysicsSystem.h b/include/Physics/PhysicsSystem.h index 60fd02e..0927eec 100755 --- a/include/Physics/PhysicsSystem.h +++ b/include/Physics/PhysicsSystem.h @@ -57,9 +57,6 @@ namespace dd ~PhysicsSystem(); - EventRelay m_ECreateParticleSequence; - bool CreateParticleSequence(const Events::CreateParticleSequence &event); - void RegisterComponents(ComponentFactory* cf) override; void Initialize() override; void Update(double dt) override; @@ -116,6 +113,8 @@ namespace dd bool OnPause(const dd::Events::Pause &event); dd::EventRelay m_EContact; bool OnContact(const dd::Events::Contact &event); + EventRelay m_ECreateParticleSequence; + bool CreateParticleSequence(const Events::CreateParticleSequence &event); //TODO: Fill struct with info needed. struct EmitterHandler //TODO CHANGE NAMES diff --git a/src/game/Game/BallSystem.cpp b/src/game/Game/BallSystem.cpp index 68c38f0..4088aed 100644 --- a/src/game/Game/BallSystem.cpp +++ b/src/game/Game/BallSystem.cpp @@ -26,6 +26,7 @@ void dd::Systems::BallSystem::Initialize() EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared); EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage); + //OctoBall { auto ent = m_World->CreateEntity(); @@ -287,6 +288,40 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event) float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier(); float y = glm::cos((abs(x) / (1.6f)) * glm::pi() / 2.f) + 1.f; + //When a combo is more than 2 create a particle showing it. + if (ballComponent->Combo >= 1){ + + Events::CreateParticleSequence particleEvent; + + particleEvent.EmitterLifeTime = 3; + particleEvent.EmittingAngle = glm::half_pi(); + particleEvent.Spread = 0.f; + particleEvent.NumberOfTicks = 1; + particleEvent.ParticleLifeTime = 2.f; + particleEvent.ParticlesPerTick = 1; + particleEvent.Position = glm::vec3(ballTransform->Position.x, -3.f, -3.f); + if (ballTransform->Position.x >= 2.7f) { + particleEvent.Position = glm::vec3(2.7f, -3.f, -3.f); + } else if (ballTransform->Position.x <= -2.7f) { + particleEvent.Position = glm::vec3(-2.7f, -3.f, -3.f); + } + particleEvent.Radius = 1.f; + particleEvent.Color = glm::vec4(1.f); + particleEvent.Speed = 0; + + if (ballComponent->Combo <= 9) { + particleEvent.SpriteFile = "Textures/Combo/Combo00" + std::to_string(ballComponent->Combo) + ".png"; + } else if (ballComponent->Combo <= 99) { + particleEvent.SpriteFile = "Textures/Combo/Combo0" + std::to_string(ballComponent->Combo) + ".png"; + } else { + particleEvent.SpriteFile = "Textures/Combo/Combo" + std::to_string(ballComponent->Combo) + ".png"; + } + EventBroker->Publish(particleEvent); + } + + + + ballComponent->Combo = 0; if (!ballComponent->Waiting) { if (m_InkBlaster) {