Merge branch 'master' of github.com:teamfisk/AgileBreakOut
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EKRAKENATTACK_H
|
||||
#define DAYDREAM_EKRAKENATTACK_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct KrakenAttack : Event
|
||||
{
|
||||
double KrakenStrength;
|
||||
double PlayerStrength;
|
||||
double ChargeUpdate;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EKRAKENATTACK_H
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Game/GUI/FPSCounter.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "GUI/Slider.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -44,9 +46,17 @@ public:
|
||||
|
||||
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
||||
|
||||
m_KrakenAttackSlider = new Slider(this, "KrakenSlider");
|
||||
m_KrakenAttackSlider->SetTexture("Textures/GUI/Menu/SliderBackground.png");
|
||||
m_KrakenAttackSlider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png");
|
||||
m_KrakenAttackSlider->SetLeft(Width / 2 - m_KrakenAttackSlider->Width / 2);
|
||||
m_KrakenAttackSlider->Y = 800;
|
||||
m_KrakenAttackSlider->Hide();
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScore, &HUD::OnScore);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
||||
}
|
||||
|
||||
void Update(double dt) override
|
||||
@@ -63,10 +73,12 @@ private:
|
||||
FPSCounter* m_FPSCounter = nullptr;
|
||||
TextureFrame* m_GameOverFrame = nullptr;
|
||||
TextureFrame* m_ClusterClearFrame = nullptr;
|
||||
Slider* m_KrakenAttackSlider = nullptr;
|
||||
|
||||
EventRelay<Frame, Events::ScoreEvent> m_EScore;
|
||||
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
||||
EventRelay<Frame, Events::KrakenAttack> m_KrakenAttack;
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
{
|
||||
@@ -87,6 +99,19 @@ private:
|
||||
m_ClusterClearFrame->SetTexture("Textures/GUI/HUD/WinScreen.png");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnKrakenAttack(const Events::KrakenAttack& event)
|
||||
{
|
||||
|
||||
if (event.ChargeUpdate >= 1.f) {
|
||||
m_KrakenAttackSlider->Hide();
|
||||
} else {
|
||||
m_KrakenAttackSlider->Show();
|
||||
m_KrakenAttackSlider->SetPercentage(event.ChargeUpdate);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
@@ -133,6 +134,7 @@ private:
|
||||
const int LifebuoyBrick = 3;
|
||||
const int StickyBrick = 4;
|
||||
const int InkBlasterBrick = 5;
|
||||
const int KrakenAttackBrick = 6;
|
||||
|
||||
EntityID m_BrickTemplate;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
@@ -76,6 +77,10 @@ private:
|
||||
bool m_Right = false;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_MultiBall = false;
|
||||
bool m_KrakenAttack = false;
|
||||
double m_KrakenCharge = 0;
|
||||
double m_KrakenStrength = 0;
|
||||
double m_PlayerStrength = 0;
|
||||
float m_Edge = 2.8f;
|
||||
Components::Transform* m_Transform = nullptr;
|
||||
Components::Pad* m_Pad = nullptr;
|
||||
@@ -88,6 +93,8 @@ private:
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
|
||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||
bool OnKeyUp(const dd::Events::KeyUp &event);
|
||||
@@ -95,6 +102,8 @@ private:
|
||||
bool OnContactPowerUp(const dd::Events::Contact &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
|
||||
class PadSteeringInputController;
|
||||
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
||||
|
||||
@@ -129,6 +129,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
}
|
||||
if (ballComponent->Sticky) {
|
||||
//TODO - Ball can stick to same pad just after detaching.
|
||||
if (!m_Waiting)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
@@ -93,6 +93,12 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
} else if (brick->Type == InkBlasterBrick) {
|
||||
Events::InkBlaster e;
|
||||
EventBroker->Publish(e);
|
||||
} else if(brick->Type == KrakenAttackBrick) {
|
||||
Events::KrakenAttack e;
|
||||
e.ChargeUpdate = 0;
|
||||
e.KrakenStrength = 0.1;
|
||||
e.PlayerStrength = 0.05;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
m_LooseBricks--;
|
||||
m_World->RemoveEntity(entity);
|
||||
@@ -207,6 +213,9 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
} else if (typeInt == InkBlasterBrick) {
|
||||
cBrick->Type = InkBlasterBrick;
|
||||
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
} else if (typeInt == KrakenAttackBrick) {
|
||||
cBrick->Type = KrakenAttackBrick;
|
||||
model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -467,6 +476,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
// 3 is lifebuoy brick.
|
||||
// 4 is sticky brick.
|
||||
// 5 is ink blaster brick.
|
||||
// 6 is kraken attack brick.
|
||||
|
||||
// wolor array determines the color of standard bricks.
|
||||
// w is white.
|
||||
|
||||
@@ -28,6 +28,8 @@ void dd::Systems::PadSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
||||
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_EActionButton, &PadSystem::OnActionButton);
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
||||
|
||||
{
|
||||
@@ -84,9 +86,21 @@ void dd::Systems::PadSystem::Update(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
auto transform = Transform();
|
||||
auto pad = Pad();
|
||||
auto acceleration = Acceleration();
|
||||
if (m_KrakenAttack) {
|
||||
m_KrakenCharge -= m_KrakenStrength * dt;
|
||||
if (m_KrakenCharge < 0) {
|
||||
m_KrakenCharge = 0;
|
||||
}
|
||||
Events::KrakenAttack e;
|
||||
e.ChargeUpdate = m_KrakenCharge;
|
||||
EventBroker->Publish(e);
|
||||
//std::cout << "Charge: " << m_KrakenCharge << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
auto transform = Transform();
|
||||
auto pad = Pad();
|
||||
auto acceleration = Acceleration();
|
||||
|
||||
if (transform->Velocity.x < -pad->MaxSpeed) {
|
||||
transform->Velocity.x = -pad->MaxSpeed;
|
||||
@@ -167,7 +181,14 @@ 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_SPACE) {
|
||||
} else if (val == GLFW_KEY_K) {
|
||||
Events::KrakenAttack e;
|
||||
e.ChargeUpdate = 0;
|
||||
e.KrakenStrength = 0.1;
|
||||
e.PlayerStrength = 0.05;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
else if (val == GLFW_KEY_SPACE) {
|
||||
Events::ActionButton e;
|
||||
e.Position = Transform()->Position;
|
||||
EventBroker->Publish(e);
|
||||
@@ -288,6 +309,44 @@ bool dd::Systems::PadSystem::OnStageCleared(const dd::Events::StageCleared &even
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
|
||||
{
|
||||
if (!m_KrakenAttack) {
|
||||
m_KrakenStrength = event.KrakenStrength;
|
||||
m_PlayerStrength = event.PlayerStrength;
|
||||
m_KrakenCharge = event.ChargeUpdate;
|
||||
m_KrakenAttack = true;
|
||||
auto transform = Transform();
|
||||
auto acceleration = Acceleration();
|
||||
|
||||
transform->Velocity = glm::vec3(0, 0, 0);
|
||||
acceleration = glm::vec3(0, 0, 0);
|
||||
|
||||
SetTransform(transform);
|
||||
SetAcceleration(acceleration);
|
||||
} else if (m_KrakenCharge >= 1) {
|
||||
m_KrakenAttack = false;
|
||||
m_KrakenCharge = 0;
|
||||
m_KrakenStrength = 0;
|
||||
m_PlayerStrength = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
if (m_KrakenAttack) {
|
||||
m_KrakenCharge += m_PlayerStrength;
|
||||
|
||||
Events::KrakenAttack e;
|
||||
e.ChargeUpdate = m_KrakenCharge;
|
||||
e.KrakenStrength = 0;
|
||||
e.PlayerStrength = 0;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::PadSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||
{
|
||||
std::string command = event.Command;
|
||||
|
||||
Reference in New Issue
Block a user