Merge branch 'master' of github.com:teamfisk/AgileBreakOut
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -50,6 +50,7 @@
|
|||||||
#include "Physics/ECreateParticleSequence.h"
|
#include "Physics/ECreateParticleSequence.h"
|
||||||
#include "Sound/CCollisionSound.h"
|
#include "Sound/CCollisionSound.h"
|
||||||
#include "Sound/EPlaySound.h"
|
#include "Sound/EPlaySound.h"
|
||||||
|
#include "Rendering/EAnimationComplete.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -145,6 +146,7 @@ private:
|
|||||||
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;
|
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||||
|
dd::EventRelay<BallSystem, dd::Events::AnimationComplete> m_EAnimationComplete;
|
||||||
|
|
||||||
bool Contact(const Events::Contact &event);
|
bool Contact(const Events::Contact &event);
|
||||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||||
@@ -160,6 +162,7 @@ private:
|
|||||||
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);
|
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||||
|
bool OnAnimationComplete(const dd::Events::AnimationComplete &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ struct Ball : Component
|
|||||||
bool Waiting = true;
|
bool Waiting = true;
|
||||||
bool InkBlaster = false;
|
bool InkBlaster = false;
|
||||||
bool Sticky = false;
|
bool Sticky = false;
|
||||||
|
bool Loaded = false;
|
||||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||||
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
|
#include "Rendering/CAnimation.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace dd
|
|||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
|
|
||||||
struct AnimationComplete
|
struct AnimationComplete : Event
|
||||||
{
|
{
|
||||||
EntityID Entity;
|
EntityID Entity;
|
||||||
std::string Animation;
|
std::string Animation;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
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);
|
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &BallSystem::OnAnimationComplete);
|
||||||
|
|
||||||
|
|
||||||
//OctoBall
|
//OctoBall
|
||||||
@@ -39,7 +40,7 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
transform->Orientation = glm::quat();
|
transform->Orientation = glm::quat();
|
||||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||||
model->ModelFile = "Models/Sid/Sid.dae";
|
model->ModelFile = "Models/Sid/Sid_Flying.dae";
|
||||||
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
auto animation = m_World->AddComponent<Components::Animation>(ent);
|
||||||
animation->Speed = 1.0;
|
animation->Speed = 1.0;
|
||||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||||
@@ -118,13 +119,31 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
/*std::uniform_real_distribution<float> dist(-0.5f, 0.5f);
|
||||||
float random = dist(m_RandomGenerator);*/
|
float random = dist(m_RandomGenerator);*/
|
||||||
transformBall->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
|
transformBall->Velocity = glm::normalize(ballComponent->SavedSpeed) * ballComponent->Speed;
|
||||||
|
|
||||||
|
auto cAnim = m_World->GetComponent<Components::Animation>(entity);
|
||||||
|
cAnim->Loop = false;
|
||||||
|
cAnim->Speed = 2.f;
|
||||||
|
cAnim->Time = 0.f;
|
||||||
//transform->Velocity = glm::normalize(glm::vec3(0, 1, 0)) * ballComponent->Speed;
|
//transform->Velocity = glm::normalize(glm::vec3(0, 1, 0)) * ballComponent->Speed;
|
||||||
} else if (!ballComponent->Sticky) {
|
} else {
|
||||||
transformBall->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
transformBall->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
|
||||||
if (m_First) {
|
auto cModel = m_World->GetComponent<Components::Model>(entity);
|
||||||
transformBall->Orientation = glm::quat();
|
cModel->ModelFile = "Models/Sid/Sid_Jump.dae";
|
||||||
m_First = false;
|
|
||||||
|
auto cAnim = m_World->GetComponent<Components::Animation>(entity);
|
||||||
|
cAnim->Speed = 0.f;
|
||||||
|
//cAnim->Time = 0.f; //Maybe not the best but it works;
|
||||||
|
|
||||||
|
if (!ballComponent->Sticky) {
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||||
|
|
||||||
|
if (m_First) {
|
||||||
|
transform->Orientation = glm::quat();
|
||||||
|
m_First = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -330,7 +349,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
m_InkBlockedWaiting = true;
|
m_InkBlockedWaiting = true;
|
||||||
ballComponent->Sticky = true;
|
ballComponent->Sticky = true;
|
||||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
ballComponent->StickyPlacement = glm::vec3(0, 0.25f, 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;
|
||||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||||
}
|
}
|
||||||
@@ -340,7 +359,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
m_Waiting = true;
|
m_Waiting = true;
|
||||||
ballComponent->Sticky = true;
|
ballComponent->Sticky = true;
|
||||||
//ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
//ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
ballComponent->StickyPlacement = glm::vec3(0, 0.25f, 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;
|
||||||
ballTransform->Velocity *= -1;
|
ballTransform->Velocity *= -1;
|
||||||
Events::StickyAttachedToPad e;
|
Events::StickyAttachedToPad e;
|
||||||
@@ -395,10 +414,7 @@ void dd::Systems::BallSystem::ResolveContacts()
|
|||||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||||
reflectedVelocity = glm::normalize(reflectedVelocity) * ballComponent->Speed;
|
reflectedVelocity = glm::normalize(reflectedVelocity) * ballComponent->Speed;
|
||||||
transform->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
transform->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_Contacts.clear();
|
m_Contacts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +490,14 @@ bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver
|
|||||||
auto ballComponent = m_World->GetComponent<Components::Ball>(event.Ball);
|
auto ballComponent = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(event.Ball);
|
auto transform = m_World->GetComponent<Components::Transform>(event.Ball);
|
||||||
|
|
||||||
|
|
||||||
|
auto cModel = m_World->GetComponent<Components::Model>(event.Ball);
|
||||||
|
cModel->ModelFile = "Models/Sid/Sid_Jump.dae";
|
||||||
|
|
||||||
|
auto cAnim = m_World->GetComponent<Components::Animation>(event.Ball);
|
||||||
|
cAnim->Speed = 2.f;
|
||||||
|
cAnim->Loop = false;
|
||||||
|
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
m_InkAttached = false;
|
m_InkAttached = false;
|
||||||
m_InkBlockedWaiting = false;
|
m_InkBlockedWaiting = false;
|
||||||
@@ -520,3 +544,20 @@ bool dd::Systems::BallSystem::OnArrivedToNewStage(const dd::Events::ArrivedAtNew
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::BallSystem::OnAnimationComplete(const dd::Events::AnimationComplete &event)
|
||||||
|
{
|
||||||
|
auto model = m_World->GetComponent<Components::Model>(event.Entity);
|
||||||
|
if (model) {
|
||||||
|
if (model->ModelFile == "Models/Sid/Sid_Jump.dae") {
|
||||||
|
model->ModelFile = "Models/Sid/Sid_Flying.dae";
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(event.Entity);
|
||||||
|
anim->Speed = 1.f;
|
||||||
|
anim->Loop = true;
|
||||||
|
anim->Time = 0.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,14 +129,19 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
ballTransform->Position = m_PadTransform->Position;
|
ballTransform->Position = m_PadTransform->Position;
|
||||||
ballTransform->Position += ball->StickyPlacement;
|
ballTransform->Position += ball->StickyPlacement;
|
||||||
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
if (ball->Loaded) {
|
||||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
ballTransform->Orientation = glm::quat();
|
||||||
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
} else {
|
||||||
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
||||||
if (ball->Sticky) {
|
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||||
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
float angle = glm::acos(glm::dot<float>(dir, up)) * glm::sign(dir.x);
|
||||||
m_StickTransform->Position = ballTransform->Position;
|
ballTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, -1.f));
|
||||||
|
if (ball->Sticky) {
|
||||||
|
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
|
||||||
|
m_StickTransform->Position = ballTransform->Position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!m_StickyAim->Aiming) {
|
if (!m_StickyAim->Aiming) {
|
||||||
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
|
||||||
|
|||||||
@@ -109,8 +109,17 @@ bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &e
|
|||||||
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||||
{
|
{
|
||||||
if (m_InkBlaster) {
|
if (m_InkBlaster) {
|
||||||
|
auto ball = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||||
|
ball->Loaded = true;
|
||||||
m_SquidLoaded = true;
|
m_SquidLoaded = true;
|
||||||
m_AttachedSquid = event.Ball;
|
m_AttachedSquid = event.Ball;
|
||||||
|
|
||||||
|
auto model = m_World->GetComponent<Components::Model>(m_AttachedSquid);
|
||||||
|
model->ModelFile = "Models/Sid/Sid_Shoot.dae";
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = false;
|
||||||
|
anim->Speed = 0.f;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -139,19 +148,32 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
|||||||
transform->Position = event.Position;
|
transform->Position = event.Position;
|
||||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||||
m_Shots--;
|
m_Shots--;
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = false;
|
||||||
|
anim->Speed = 1.f;
|
||||||
|
anim->Time = 0.f;
|
||||||
|
|
||||||
if (m_Shots <= 0) {
|
if (m_Shots <= 0) {
|
||||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||||
m_InkBlaster = false;
|
m_InkBlaster = false;
|
||||||
m_SquidLoaded = false;
|
m_SquidLoaded = false;
|
||||||
ball->InkBlaster = false;
|
ball->InkBlaster = false;
|
||||||
ball->Sticky = false;
|
ball->Sticky = false;
|
||||||
|
ball->Loaded = false;
|
||||||
ball->Waiting = true;
|
ball->Waiting = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
Events::InkBlasterOver e;
|
Events::InkBlasterOver e;
|
||||||
e.Ball = m_AttachedSquid;
|
e.Ball = m_AttachedSquid;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
auto model = m_World->GetComponent<Components::Model>(m_AttachedSquid);
|
||||||
|
model->ModelFile = "Models/Sid/Sid_Flying.dae";
|
||||||
|
|
||||||
|
auto anim = m_World->GetComponent<Components::Animation>(m_AttachedSquid);
|
||||||
|
anim->Loop = true;
|
||||||
|
anim->Speed = 1.f;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Events::ActionButton e;
|
Events::ActionButton e;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "Game/ScreenShakeSystem.h"
|
#include "Game/ScreenShakeSystem.h"
|
||||||
|
|
||||||
|
|
||||||
void dd::Systems::ScreenShakeSystem::Initialize()
|
void dd::Systems::ScreenShakeSystem::Initialize()
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ void dd::Systems::AnimationSystem::Update(double dt)
|
|||||||
Events::AnimationComplete e;
|
Events::AnimationComplete e;
|
||||||
e.Entity = ent;
|
e.Entity = ent;
|
||||||
e.Animation = animationComponent->Name;
|
e.Animation = animationComponent->Name;
|
||||||
|
EventBroker->Publish(e);
|
||||||
} else {
|
} else {
|
||||||
animationComponent->Time = nextTime;
|
animationComponent->Time = nextTime;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user