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 "Sound/CCollisionSound.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
#include "Rendering/EAnimationComplete.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -145,6 +146,7 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
dd::EventRelay<BallSystem, dd::Events::AnimationComplete> m_EAnimationComplete;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
@@ -160,6 +162,7 @@ private:
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &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 InkBlaster = false;
|
||||
bool Sticky = false;
|
||||
bool Loaded = false;
|
||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||
glm::vec3 SavedSpeed = glm::vec3(0, 1, 0);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace dd
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AnimationComplete
|
||||
struct AnimationComplete : Event
|
||||
{
|
||||
EntityID Entity;
|
||||
std::string Animation;
|
||||
|
||||
@@ -28,6 +28,7 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &BallSystem::OnAnimationComplete);
|
||||
|
||||
|
||||
//OctoBall
|
||||
@@ -39,7 +40,7 @@ void dd::Systems::BallSystem::Initialize()
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
transform->Orientation = glm::quat();
|
||||
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);
|
||||
animation->Speed = 1.0;
|
||||
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);
|
||||
float random = dist(m_RandomGenerator);*/
|
||||
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;
|
||||
} else if (!ballComponent->Sticky) {
|
||||
} else {
|
||||
transformBall->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
//transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||
if (m_First) {
|
||||
transformBall->Orientation = glm::quat();
|
||||
m_First = false;
|
||||
|
||||
auto cModel = m_World->GetComponent<Components::Model>(entity);
|
||||
cModel->ModelFile = "Models/Sid/Sid_Jump.dae";
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -330,7 +349,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
m_Waiting = true;
|
||||
m_InkBlockedWaiting = 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;
|
||||
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;
|
||||
ballComponent->Sticky = true;
|
||||
//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;
|
||||
ballTransform->Velocity *= -1;
|
||||
Events::StickyAttachedToPad e;
|
||||
@@ -395,10 +414,7 @@ void dd::Systems::BallSystem::ResolveContacts()
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||
reflectedVelocity = glm::normalize(reflectedVelocity) * ballComponent->Speed;
|
||||
transform->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
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 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_InkAttached = false;
|
||||
m_InkBlockedWaiting = false;
|
||||
@@ -520,3 +544,20 @@ bool dd::Systems::BallSystem::OnArrivedToNewStage(const dd::Events::ArrivedAtNew
|
||||
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);
|
||||
ballTransform->Position = m_PadTransform->Position;
|
||||
ballTransform->Position += ball->StickyPlacement;
|
||||
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||
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));
|
||||
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 (ball->Loaded) {
|
||||
ballTransform->Orientation = glm::quat();
|
||||
} else {
|
||||
glm::vec2 dir = glm::normalize(glm::vec2(ball->SavedSpeed.x, ball->SavedSpeed.y));
|
||||
glm::vec2 up = glm::vec2(0.f, 1.f);
|
||||
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));
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
if (m_InkBlaster) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||
ball->Loaded = true;
|
||||
m_SquidLoaded = true;
|
||||
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;
|
||||
}
|
||||
@@ -139,19 +148,32 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
||||
transform->Position = event.Position;
|
||||
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||
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) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||
m_InkBlaster = false;
|
||||
m_SquidLoaded = false;
|
||||
ball->InkBlaster = false;
|
||||
ball->Sticky = false;
|
||||
ball->Loaded = false;
|
||||
ball->Waiting = true;
|
||||
|
||||
{
|
||||
Events::InkBlasterOver e;
|
||||
e.Ball = m_AttachedSquid;
|
||||
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;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/ScreenShakeSystem.h"
|
||||
|
||||
|
||||
void dd::Systems::ScreenShakeSystem::Initialize()
|
||||
{
|
||||
std::random_device rd;
|
||||
|
||||
@@ -42,6 +42,7 @@ void dd::Systems::AnimationSystem::Update(double dt)
|
||||
Events::AnimationComplete e;
|
||||
e.Entity = ent;
|
||||
e.Animation = animationComponent->Name;
|
||||
EventBroker->Publish(e);
|
||||
} else {
|
||||
animationComponent->Time = nextTime;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user