LifeBuoy particle effect on hit.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
@@ -18,8 +20,7 @@
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -127,9 +127,30 @@ bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &event)
|
||||
{
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Lifebuoy);
|
||||
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(event.Lifebuoy);
|
||||
lifebuoyComponent->Hits -= 1;
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
|
||||
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
|
||||
|
||||
Events::CreateParticleSequence e;
|
||||
e.EmitterLifeTime = 4;
|
||||
e.EmittingAngle = glm::half_pi<float>();
|
||||
e.Spread = 0.5f;
|
||||
e.NumberOfTicks = 1;
|
||||
e.ParticleLifeTime = 1.f;
|
||||
e.ParticlesPerTick = 1;
|
||||
e.Position = transformComponent->Position;
|
||||
e.ScaleValues.clear();
|
||||
e.ScaleValues.push_back(glm::vec3(0.5f));
|
||||
e.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
|
||||
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||
e.Color = glm::vec4(1, 0, 0, 1);
|
||||
e.AlphaValues.clear();
|
||||
e.AlphaValues.push_back(1.f);
|
||||
e.AlphaValues.push_back(0.f);
|
||||
e.Speed = 10.f;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user