Fixed Sticky after Ink bug, fixed directions on Squid after sticky, laser direction is in background. Brick Components implemented, though they do nothing.

This commit is contained in:
PlatinumSkink
2015-10-12 16:45:59 +02:00
parent 8f2af7ca8f
commit 5630771272
16 changed files with 286 additions and 12 deletions
+45 -4
View File
@@ -29,6 +29,7 @@ void dd::Systems::PadSystem::Initialize()
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &PadSystem::OnActionButton);
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
@@ -53,6 +54,21 @@ void dd::Systems::PadSystem::Initialize()
SetEdge(3.2 - (ctransform->Scale.x / 2));
}
//Stick
{
auto ent = m_World->CreateEntity();
m_World->SetProperty(ent, "Name", "Stick");
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(30.f, 0.f, -10.f);
transform->Scale = glm::vec3(0.1f, 20.f, 0.1f);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::StickyAim> sticky = m_World->AddComponent<Components::StickyAim>(ent);
m_World->CommitEntity(ent);
m_StickTransform = transform;
}
}
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
@@ -63,9 +79,21 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
auto ball = m_World->GetComponent<Components::Ball>(entity);
if (ball != nullptr) {
if (ball->Sticky) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
transform->Position = Transform()->Position;
transform->Position += ball->StickyPlacement;
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 (m_StickyAim->Aiming) {
m_StickTransform->Orientation = glm::rotate(glm::quat(), angle, glm::vec3(0.f, 0.f, 1.f));
m_StickTransform->Position = ballTransform->Position;
}*/
} else {
/*if (!m_StickyAim->Aiming) {
m_StickTransform->Position = glm::vec3(30.f, 0.f, 0.f);
}*/
}
}
}
@@ -181,7 +209,15 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
} else if (val == GLFW_KEY_S) {
Events::StageCleared e;
EventBroker->Publish(e);
} else if (val == GLFW_KEY_K) {
} else if (val == GLFW_KEY_Y) {
Events::StickyPad e;
EventBroker->Publish(e);
}
else if (val == GLFW_KEY_I) {
Events::InkBlaster e;
EventBroker->Publish(e);
}
else if (val == GLFW_KEY_K) {
Events::KrakenAttack e;
e.ChargeUpdate = 0;
e.KrakenStrength = 0.1;
@@ -333,6 +369,11 @@ bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &even
return true;
}
bool dd::Systems::PadSystem::OnStickyPad(const dd::Events::StickyPad &event)
{
return true;
}
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
{
if (m_KrakenAttack) {