Getting Sticky after Ink Blaster now works.
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EStickyPad.h"
|
#include "Game/EStickyPad.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
|
#include "Game/EInkBlasterOver.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"
|
||||||
@@ -96,6 +97,8 @@ private:
|
|||||||
bool m_Waiting = true;
|
bool m_Waiting = true;
|
||||||
bool m_Sticky = false;
|
bool m_Sticky = false;
|
||||||
bool m_InkBlaster = false;
|
bool m_InkBlaster = false;
|
||||||
|
bool m_InkAttached = false;
|
||||||
|
bool m_BlockedWaiting = false;
|
||||||
int m_StickyCounter = 5;
|
int m_StickyCounter = 5;
|
||||||
|
|
||||||
glm::vec3 m_SavedSpeed;
|
glm::vec3 m_SavedSpeed;
|
||||||
@@ -112,6 +115,7 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||||
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
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;
|
||||||
@@ -123,6 +127,7 @@ private:
|
|||||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||||
|
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-08.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_EINKBLASTEROVER_H
|
||||||
|
#define DAYDREAM_EINKBLASTEROVER_H
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct InkBlasterOver : Event
|
||||||
|
{
|
||||||
|
EntityID Ball;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_EINKBLASTEROVER_H
|
||||||
@@ -10,12 +10,14 @@
|
|||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EInkBlaster.h"
|
#include "Game/EInkBlaster.h"
|
||||||
|
#include "Game/EInkBlasterOver.h"
|
||||||
#include "Game/EActionButton.h"
|
#include "Game/EActionButton.h"
|
||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||||
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);
|
||||||
|
|
||||||
@@ -109,19 +110,10 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ballComponent->Waiting) {
|
if (ballComponent->Waiting) {
|
||||||
if (m_Waiting == false) {
|
if (!m_Waiting) {
|
||||||
ballComponent->Waiting = false;
|
ballComponent->Waiting = false;
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||||
if (ballComponent->Sticky) {
|
|
||||||
transform->Velocity = ballComponent->SavedSpeed;
|
|
||||||
m_StickyCounter--;
|
|
||||||
std::cout << m_StickyCounter << std::endl;
|
|
||||||
if (m_StickyCounter > 0) {
|
|
||||||
m_Sticky = true;
|
|
||||||
}
|
|
||||||
ballComponent->Sticky = false;
|
|
||||||
}
|
|
||||||
} else if (!ballComponent->Sticky) {
|
} else if (!ballComponent->Sticky) {
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
@@ -130,6 +122,18 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ballComponent->Sticky) {
|
||||||
|
if (!m_Waiting)
|
||||||
|
{
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
transform->Velocity = ballComponent->SavedSpeed;
|
||||||
|
m_StickyCounter--;
|
||||||
|
if (m_StickyCounter > 0) {
|
||||||
|
m_Sticky = true;
|
||||||
|
}
|
||||||
|
ballComponent->Sticky = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||||
if (glm::abs(transformBall->Velocity.y) < 2) {
|
if (glm::abs(transformBall->Velocity.y) < 2) {
|
||||||
@@ -273,15 +277,19 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
ballComponent->Combo = 0;
|
ballComponent->Combo = 0;
|
||||||
|
|
||||||
if (m_InkBlaster) {
|
if (m_InkBlaster) {
|
||||||
m_InkBlaster = false;
|
if (!m_InkAttached) {
|
||||||
ballComponent->Sticky = true;
|
m_InkAttached = true;
|
||||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
m_Waiting = true;
|
||||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
m_BlockedWaiting = true;
|
||||||
|
ballComponent->Sticky = true;
|
||||||
|
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||||
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||||
|
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
}
|
||||||
} else if (m_Sticky) {
|
} else if (m_Sticky) {
|
||||||
m_Sticky = false;
|
m_Sticky = false;
|
||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
ballComponent->Sticky = true;
|
ballComponent->Sticky = true;
|
||||||
ballComponent->Waiting = true;
|
|
||||||
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;
|
||||||
@@ -431,9 +439,26 @@ bool dd::Systems::BallSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver &event)
|
||||||
|
{
|
||||||
|
auto ballComponent = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(event.Ball);
|
||||||
|
|
||||||
|
m_InkBlaster = false;
|
||||||
|
m_InkAttached = false;
|
||||||
|
m_BlockedWaiting = false;
|
||||||
|
m_Sticky = true;
|
||||||
|
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
||||||
|
m_Waiting = false;
|
||||||
|
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
{
|
{
|
||||||
m_Waiting = false;
|
if (!m_BlockedWaiting) {
|
||||||
|
m_Waiting = false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,6 @@ void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
|||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Collision happened!");
|
|
||||||
EntityID entityBrick;
|
EntityID entityBrick;
|
||||||
EntityID entityBall;
|
EntityID entityBall;
|
||||||
EntityID entityShot = 0;
|
EntityID entityShot = 0;
|
||||||
@@ -250,12 +249,10 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
} else {
|
} else {
|
||||||
auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
|
auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
|
||||||
if (shot != nullptr) {
|
if (shot != nullptr) {
|
||||||
LOG_DEBUG("Entity1 is a shot!");
|
|
||||||
entityShot = event.Entity1;
|
entityShot = event.Entity1;
|
||||||
} else {
|
} else {
|
||||||
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
|
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
|
||||||
if (shot != nullptr) {
|
if (shot != nullptr) {
|
||||||
LOG_DEBUG("Entity2 is a shot!");
|
|
||||||
entityShot = event.Entity2;
|
entityShot = event.Entity2;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -118,6 +118,17 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
|||||||
m_SquidLoaded = false;
|
m_SquidLoaded = false;
|
||||||
ball->InkBlaster = false;
|
ball->InkBlaster = false;
|
||||||
ball->Sticky = 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;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user