Merge branch 'master' of github.com:teamfisk/AgileBreakOut
This commit is contained in:
@@ -17,21 +17,23 @@
|
|||||||
#include "Game/CPowerUp.h"
|
#include "Game/CPowerUp.h"
|
||||||
#include "Game/CLife.h"
|
#include "Game/CLife.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CLifebuoy.h"
|
||||||
#include "Game/ELifeLost.h"
|
#include "Game/ELifeLost.h"
|
||||||
#include "Game/EComboEvent.h"
|
#include "Game/EComboEvent.h"
|
||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EStickyPad.h"
|
#include "Game/EStickyPad.h"
|
||||||
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EInkBlasterOver.h"
|
#include "Game/EInkBlasterOver.h"
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/EArrivedAtNewStage.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
#include "Game/EHitLag.h"
|
#include "Game/EHitLag.h"
|
||||||
#include "Game/EActionButton.h"
|
#include "Game/EActionButton.h"
|
||||||
#include "Game/CLifebuoy.h"
|
|
||||||
#include "Game/ELifebuoyHit.h"
|
#include "Game/ELifebuoyHit.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
@@ -101,9 +103,11 @@ private:
|
|||||||
bool m_Sticky = false;
|
bool m_Sticky = false;
|
||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
bool m_InkAttached = false;
|
bool m_InkAttached = false;
|
||||||
bool m_BlockedWaiting = false;
|
bool m_InkBlockedWaiting = false;
|
||||||
bool m_Restarting = false;
|
bool m_Restarting = false;
|
||||||
int m_StickyCounter = 5;
|
int m_StickyCounter = 3;
|
||||||
|
|
||||||
|
bool m_StageBlockedWaiting = false;
|
||||||
|
|
||||||
glm::vec3 m_SavedSpeed;
|
glm::vec3 m_SavedSpeed;
|
||||||
bool m_InitializePause = false;
|
bool m_InitializePause = false;
|
||||||
@@ -124,6 +128,7 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||||
|
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 OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
@@ -136,6 +141,7 @@ private:
|
|||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||||
|
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EVENTS_EARRIVEDATNEWSTAGE_H__
|
||||||
|
#define EVENTS_EARRIVEDATNEWSTAGE_H__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ArrivedAtNewStage : public Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EARRIVEDATNEWSTAGE_H
|
||||||
@@ -16,6 +16,7 @@ namespace Events
|
|||||||
struct InkBlaster : Event
|
struct InkBlaster : Event
|
||||||
{
|
{
|
||||||
Components::Transform* Transform;
|
Components::Transform* Transform;
|
||||||
|
int Shots;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-12.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EVENTS_ESTICKYATTACHEDTOPAD_H__
|
||||||
|
#define EVENTS_ESTICKYATTACHEDTOPAD_H__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct StickyAttachedToPad : public Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_ESTICKYATTACHEDTOPADE_H
|
||||||
@@ -16,6 +16,7 @@ namespace Events
|
|||||||
struct StickyPad : Event
|
struct StickyPad : Event
|
||||||
{
|
{
|
||||||
Components::Transform* Transform;
|
Components::Transform* Transform;
|
||||||
|
int Times;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public:
|
|||||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||||
void CreateLevel(int);
|
void CreateLevel(int);
|
||||||
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||||
|
void BrickHit(EntityID, EntityID, int);
|
||||||
|
|
||||||
void OnEntityRemoved(EntityID entity);
|
void OnEntityRemoved(EntityID entity);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "Game/EResetBall.h"
|
#include "Game/EResetBall.h"
|
||||||
#include "Game/EMultiBall.h"
|
#include "Game/EMultiBall.h"
|
||||||
#include "Game/EStickyPad.h"
|
#include "Game/EStickyPad.h"
|
||||||
|
#include "Game/EStickyAttachedToPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
#include "Game/EKrakenAttack.h"
|
#include "Game/EKrakenAttack.h"
|
||||||
#include "Game/EPowerUpTaken.h"
|
#include "Game/EPowerUpTaken.h"
|
||||||
@@ -101,6 +102,7 @@ private:
|
|||||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||||
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::ActionButton> m_EActionButton;
|
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
||||||
|
|
||||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||||
@@ -111,6 +113,7 @@ private:
|
|||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||||
|
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
||||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||||
|
|
||||||
class PadSteeringInputController;
|
class PadSteeringInputController;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "CRectangleShape.h"
|
#include "CRectangleShape.h"
|
||||||
|
|
||||||
#include "Game/EStageCleared.h"
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/EArrivedAtNewStage.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage);
|
||||||
|
|
||||||
//OctoBall
|
//OctoBall
|
||||||
{
|
{
|
||||||
@@ -292,7 +293,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
if (!m_InkAttached) {
|
if (!m_InkAttached) {
|
||||||
m_InkAttached = true;
|
m_InkAttached = true;
|
||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
m_BlockedWaiting = true;
|
m_InkBlockedWaiting = true;
|
||||||
ballComponent->Sticky = true;
|
ballComponent->Sticky = true;
|
||||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||||
@@ -305,6 +306,8 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||||
ballTransform->Velocity *= -1;
|
ballTransform->Velocity *= -1;
|
||||||
|
Events::StickyAttachedToPad e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +446,6 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
|
|||||||
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||||
{
|
{
|
||||||
m_Sticky = true;
|
m_Sticky = true;
|
||||||
m_StickyCounter = 5;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,7 +462,7 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
|
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
m_InkAttached = false;
|
m_InkAttached = false;
|
||||||
m_BlockedWaiting = false;
|
m_InkBlockedWaiting = false;
|
||||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
||||||
m_Waiting = false;
|
m_Waiting = false;
|
||||||
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
||||||
@@ -469,8 +471,10 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
|
|
||||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (!m_BlockedWaiting) {
|
if (!m_StageBlockedWaiting) {
|
||||||
m_Waiting = false;
|
if (!m_InkBlockedWaiting) {
|
||||||
|
m_Waiting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -478,6 +482,13 @@ bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &eve
|
|||||||
bool dd::Systems::BallSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
bool dd::Systems::BallSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||||
{
|
{
|
||||||
m_Restarting = true;
|
m_Restarting = true;
|
||||||
|
m_StageBlockedWaiting = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event)
|
||||||
|
{
|
||||||
|
m_StageBlockedWaiting = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+101
-96
@@ -78,7 +78,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
//Removes bricks that falls out of the stage.
|
//Removes bricks that falls out of the stage.
|
||||||
if (transform->Position.y < -10) {
|
if (transform->Position.y < -10) {
|
||||||
if (brick->Type == StandardBrick) {
|
/*if (brick->Type == StandardBrick) {
|
||||||
} else if (brick->Type == MultiBallBrick) {
|
} else if (brick->Type == MultiBallBrick) {
|
||||||
Events::MultiBall e;
|
Events::MultiBall e;
|
||||||
e.padTransform = transform;
|
e.padTransform = transform;
|
||||||
@@ -99,7 +99,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
e.KrakenStrength = 0.1;
|
e.KrakenStrength = 0.1;
|
||||||
e.PlayerStrength = 0.05;
|
e.PlayerStrength = 0.05;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}*/
|
||||||
m_LooseBricks--;
|
m_LooseBricks--;
|
||||||
m_World->RemoveEntity(entity);
|
m_World->RemoveEntity(entity);
|
||||||
}
|
}
|
||||||
@@ -284,113 +284,118 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
if (entityShot != 0) {
|
if (entityShot != 0) {
|
||||||
// For when a brick gets shot.
|
// For when a brick gets shot.
|
||||||
brick->Removed = true;
|
brick->Removed = true;
|
||||||
|
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
|
||||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
|
||||||
physicsComponent->GravityScale = 1.f;
|
|
||||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
|
||||||
|
|
||||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
|
||||||
auto transformComponentShot = m_World->GetComponent<Components::Transform>(entityShot);
|
|
||||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
|
||||||
|
|
||||||
Events::SetImpulse e;
|
|
||||||
e.Entity = entityBrick;
|
|
||||||
|
|
||||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentShot->Position.x - transformComponentBrick->Position.x) / 4),
|
|
||||||
transformComponentBrick->Position.y + ((transformComponentShot->Position.y - transformComponentBrick->Position.y) / 4));
|
|
||||||
|
|
||||||
e.Impulse = glm::normalize(point)*5.f;
|
|
||||||
e.Point = point;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
|
|
||||||
|
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
|
||||||
Events::ScoreEvent es;
|
|
||||||
es.Score = brick->Score;
|
|
||||||
EventBroker->Publish(es);
|
|
||||||
|
|
||||||
m_World->RemoveEntity(entityShot);
|
m_World->RemoveEntity(entityShot);
|
||||||
|
BrickHit(entityShot, entityBrick, 1);
|
||||||
Events::CreateParticleSequence ep;
|
|
||||||
ep.parent = entityBrick;
|
|
||||||
ep.EmitterLifeTime = 1.f;
|
|
||||||
ep.ParticleLifeTime = 1.5f;
|
|
||||||
ep.ParticlesPerTick = 1;
|
|
||||||
ep.SpawnRate = 0.2;
|
|
||||||
ep.EmittingAngle = glm::half_pi<float>();
|
|
||||||
ep.Spread = 1.5f;
|
|
||||||
ep.Position = transformComponentBrick->Position;
|
|
||||||
ep.Radius = 0.05;
|
|
||||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
|
||||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
|
||||||
ep.Speed = 50;
|
|
||||||
EventBroker->Publish(ep);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Restarting() && !brick->Removed) {
|
if (!Restarting() && !brick->Removed) {
|
||||||
brick->Removed = true;
|
brick->Removed = true;
|
||||||
// Hit brick with ball code.
|
|
||||||
ball->Combo += 1;
|
// Hit brick with ball code.
|
||||||
Events::ComboEvent ec;
|
ball->Combo += 1;
|
||||||
ec.Combo = ball->Combo;
|
Events::ComboEvent ec;
|
||||||
ec.Ball = entityBall;
|
ec.Combo = ball->Combo;
|
||||||
EventBroker->Publish(ec);
|
ec.Ball = entityBall;
|
||||||
|
EventBroker->Publish(ec);
|
||||||
|
|
||||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
BrickHit(entityBall, entityBrick, ball->Combo);
|
||||||
|
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
|
||||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
|
||||||
physicsComponent->GravityScale = 1.f;
|
|
||||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
|
||||||
|
|
||||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
|
||||||
auto transformComponentBall = m_World->GetComponent<Components::Transform>(entityBall);
|
|
||||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
|
||||||
|
|
||||||
Events::SetImpulse e;
|
|
||||||
e.Entity = entityBrick;
|
|
||||||
|
|
||||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentBall->Position.x - transformComponentBrick->Position.x )/4),
|
|
||||||
transformComponentBrick->Position.y + ((transformComponentBall->Position.y - transformComponentBrick->Position.y)/4));
|
|
||||||
|
|
||||||
e.Impulse = glm::normalize(point)*5.f;///2.f;
|
|
||||||
e.Point = point;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
//TODO: Bricks dont collide with walls D=
|
|
||||||
|
|
||||||
|
|
||||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
|
||||||
Events::ScoreEvent es;
|
|
||||||
es.Score = brick->Score * ball->Combo;
|
|
||||||
EventBroker->Publish(es);
|
|
||||||
|
|
||||||
Events::CreateParticleSequence ep;
|
|
||||||
ep.parent = entityBrick;
|
|
||||||
ep.EmitterLifeTime = 1.f;
|
|
||||||
ep.ParticleLifeTime = 1.5f;
|
|
||||||
ep.ParticlesPerTick = 1;
|
|
||||||
ep.SpawnRate = 0.2;
|
|
||||||
ep.EmittingAngle = glm::half_pi<float>();
|
|
||||||
ep.Spread = 1.5f;
|
|
||||||
ep.Position = transformComponentBrick->Position;
|
|
||||||
ep.Radius = 0.05;
|
|
||||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
|
||||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
|
||||||
ep.Speed = 50;
|
|
||||||
EventBroker->Publish(ep);
|
|
||||||
|
|
||||||
//std::cout << "Combo: " << ball->Combo << std::endl;
|
|
||||||
//std::cout << NumberOfBricks() << std::endl;
|
|
||||||
//std::cout << "Brick Score: " << brick->Score << std::endl;
|
|
||||||
//std::cout << "Score: " << Score() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBrick, int combo)
|
||||||
|
{
|
||||||
|
auto brick = m_World->GetComponent<Components::Brick>(entityBrick);
|
||||||
|
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||||
|
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||||
|
physicsComponent->GravityScale = 1.f;
|
||||||
|
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||||
|
|
||||||
|
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||||
|
auto transformComponentHitter = m_World->GetComponent<Components::Transform>(entityHitter);
|
||||||
|
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
||||||
|
|
||||||
|
// Check if the brick is any kind of special.
|
||||||
|
auto multi = m_World->GetComponent<Components::MultiBallBrick>(entityBrick);
|
||||||
|
if (multi != nullptr) {
|
||||||
|
Events::MultiBall e;
|
||||||
|
e.padTransform = transformComponentBrick;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto buoy = m_World->GetComponent<Components::LifebuoyBrick>(entityBrick);
|
||||||
|
if (buoy != nullptr) {
|
||||||
|
Events::Lifebuoy e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto sticky = m_World->GetComponent<Components::StickyBrick>(entityBrick);
|
||||||
|
if (sticky != nullptr) {
|
||||||
|
Events::StickyPad e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
e.Times = 3;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto ink = m_World->GetComponent<Components::InkBlasterBrick>(entityBrick);
|
||||||
|
if (ink != nullptr) {
|
||||||
|
Events::InkBlaster e;
|
||||||
|
e.Transform = transformComponentBrick;
|
||||||
|
e.Shots = 5;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto kraken = m_World->GetComponent<Components::KrakenAttackBrick>(entityBrick);
|
||||||
|
if (kraken != nullptr) {
|
||||||
|
Events::KrakenAttack e;
|
||||||
|
e.ChargeUpdate = 0;
|
||||||
|
e.KrakenStrength = 0.1;
|
||||||
|
e.PlayerStrength = 0.05;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::SetImpulse e;
|
||||||
|
e.Entity = entityBrick;
|
||||||
|
|
||||||
|
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentHitter->Position.x - transformComponentBrick->Position.x) / 4),
|
||||||
|
transformComponentBrick->Position.y + ((transformComponentHitter->Position.y - transformComponentBrick->Position.y) / 4));
|
||||||
|
|
||||||
|
e.Impulse = glm::normalize(point)*5.f;
|
||||||
|
e.Point = point;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||||
|
Events::ScoreEvent es;
|
||||||
|
es.Score = brick->Score * combo;
|
||||||
|
EventBroker->Publish(es);
|
||||||
|
|
||||||
|
Events::CreateParticleSequence ep;
|
||||||
|
ep.parent = entityBrick;
|
||||||
|
ep.EmitterLifeTime = 1.f;
|
||||||
|
ep.ParticleLifeTime = 1.5f;
|
||||||
|
ep.ParticlesPerTick = 1;
|
||||||
|
ep.SpawnRate = 0.2;
|
||||||
|
ep.EmittingAngle = glm::half_pi<float>();
|
||||||
|
ep.Spread = 1.5f;
|
||||||
|
ep.Position = transformComponentBrick->Position;
|
||||||
|
ep.Radius = 0.05;
|
||||||
|
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||||
|
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
||||||
|
ep.Speed = 50;
|
||||||
|
EventBroker->Publish(ep);
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event)
|
bool dd::Systems::LevelSystem::OnScoreEvent(const dd::Events::ScoreEvent &event)
|
||||||
{
|
{
|
||||||
SetScore(Score() += event.Score);
|
SetScore(Score() += event.Score);
|
||||||
|
|||||||
+17
-10
@@ -30,6 +30,7 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
||||||
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_EActionButton, &PadSystem::OnActionButton);
|
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
|
||||||
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
||||||
|
|
||||||
@@ -61,13 +62,15 @@ void dd::Systems::PadSystem::Initialize()
|
|||||||
m_World->SetProperty(ent, "Name", "Stick");
|
m_World->SetProperty(ent, "Name", "Stick");
|
||||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
transform->Position = glm::vec3(30.f, 0.f, -10.f);
|
transform->Position = glm::vec3(30.f, 0.f, -10.f);
|
||||||
transform->Scale = glm::vec3(0.1f, 20.f, 0.1f);
|
transform->Scale = glm::vec3(0.1f, 25.f, 0.1f);
|
||||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
sprite->SpriteFile = "Models/Brick/White.png";
|
||||||
|
sprite->Color = glm::vec4(0.f, 0.5f, 0.f, 0.5f);
|
||||||
std::shared_ptr<Components::StickyAim> sticky = m_World->AddComponent<Components::StickyAim>(ent);
|
std::shared_ptr<Components::StickyAim> sticky = m_World->AddComponent<Components::StickyAim>(ent);
|
||||||
m_World->CommitEntity(ent);
|
m_World->CommitEntity(ent);
|
||||||
|
|
||||||
m_StickTransform = transform;
|
m_StickTransform = transform;
|
||||||
|
m_StickyAim = sticky;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,14 +89,11 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
||||||
/*if (m_StickyAim->Aiming) {
|
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
||||||
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
m_StickTransform->Position = ballTransform->Position;
|
||||||
m_StickTransform->Position = ballTransform->Position;
|
}
|
||||||
}*/
|
if (!m_StickyAim->Aiming) {
|
||||||
} else {
|
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
||||||
/*if (!m_StickyAim->Aiming) {
|
|
||||||
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,6 +374,12 @@ bool dd::Systems::PadSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::PadSystem::OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event)
|
||||||
|
{
|
||||||
|
m_StickyAim->Aiming = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
if (m_KrakenAttack) {
|
if (m_KrakenAttack) {
|
||||||
@@ -385,6 +391,7 @@ bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &even
|
|||||||
e.PlayerStrength = 0;
|
e.PlayerStrength = 0;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
m_StickyAim->Aiming = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||||
{
|
{
|
||||||
m_InkBlaster = true;
|
m_InkBlaster = true;
|
||||||
m_Shots = 5;
|
m_Shots = event.Shots;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
|||||||
if (m_DistanceTravelled > 12.f) {
|
if (m_DistanceTravelled > 12.f) {
|
||||||
m_DistanceTravelled = 0;
|
m_DistanceTravelled = 0;
|
||||||
m_Travelling = false;
|
m_Travelling = false;
|
||||||
|
Events::ArrivedAtNewStage e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DistanceTravelled += 6.0f * dt;
|
m_DistanceTravelled += 6.0f * dt;
|
||||||
|
|||||||
Reference in New Issue
Block a user