Animations
This commit is contained in:
@@ -39,7 +39,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);
|
||||
|
||||
@@ -112,14 +112,19 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||
ballTransform->Position = Transform()->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,18 +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;
|
||||
|
||||
Reference in New Issue
Block a user