Merge remote-tracking branch 'origin/master' into Physics
Conflicts: include/Core/Engine.h
This commit is contained in:
@@ -9,4 +9,4 @@ BGMVolume=0.5
|
||||
[Video]
|
||||
Fullscreen=false
|
||||
Width=675
|
||||
Height=1080
|
||||
Height=1080[Water]Radius=0.3[Cheat]GodMode=false
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Executable
BIN
Binary file not shown.
@@ -41,9 +41,6 @@ struct Transform : public Component
|
||||
glm::vec3 Velocity;
|
||||
/** Physical scale multiplier. */
|
||||
glm::vec3 Scale;
|
||||
|
||||
// Sticky is if it sticks with the player or not. True means it will follow the camera.
|
||||
bool Sticky = true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+13
-251
@@ -48,12 +48,17 @@
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CWall.h"
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/CBackground.h"
|
||||
#include "Game/CTravels.h"
|
||||
#include "Game/CStickyAim.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/TravellingSystem.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
#include "Game/KrakenSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
@@ -139,10 +144,14 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Wall>();
|
||||
m_World->ComponentFactory.Register<Components::Background>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||
m_World->ComponentFactory.Register<Components::Projectile>();
|
||||
m_World->ComponentFactory.Register<Components::Kraken>();
|
||||
m_World->ComponentFactory.Register<Components::StickyAim>();
|
||||
m_World->ComponentFactory.Register<Components::Travels>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
@@ -181,6 +190,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::TravellingSystem>(
|
||||
[this]() { return new Systems::TravellingSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TravellingSystem>();
|
||||
m_World->SystemFactory.Register<Systems::KrakenSystem>(
|
||||
[this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::KrakenSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
@@ -190,209 +202,13 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
|
||||
m_World->Initialize();
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 20.f;
|
||||
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(3.f, -5.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 15.f;
|
||||
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
|
||||
//Halfpipe background test model.
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 34.6f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
|
||||
//Background
|
||||
|
||||
{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -30.f);
|
||||
transform->Scale = glm::vec3(2681.f / 50.f, 1080.f / 50.f, 1.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(background);
|
||||
sprite->SpriteFile = "Textures/Background.png";
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
transform->Sticky = true;
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
|
||||
|
||||
|
||||
|
||||
//ParticleTest
|
||||
|
||||
|
||||
/*{
|
||||
auto Pe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
|
||||
auto emitteSprite = m_World->AddComponent<Components::Sprite>(Pe);
|
||||
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png";
|
||||
particleEmitter->GravityScale = 0.0f;
|
||||
particleEmitter->SpawnRate = 1.f;
|
||||
particleEmitter->NumberOfTicks = 2;
|
||||
particleEmitter->Speed = 1.f;
|
||||
particleEmitter->ParticlesPerTick = 5;
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
|
||||
auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
|
||||
|
||||
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
PtTransform->Position = transform->Position;
|
||||
PtSprite->SpriteFile = "Textures/Background.png";
|
||||
PtParticle->LifeTime = 3.f;
|
||||
PtParticle->Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter);
|
||||
}
|
||||
m_World->CommitEntity(Pe);
|
||||
}*/
|
||||
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto BottomWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||
transform->Sticky = true;
|
||||
m_World->CommitEntity(BottomWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto leftWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
leftWall);
|
||||
transform->Position = glm::vec3(-4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto rightWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
rightWall);
|
||||
transform->Position = glm::vec3(4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
m_EScreenShake = decltype(m_EScreenShake)(std::bind(&Engine::OnScreenShake, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EScreenShake);
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
@@ -413,9 +229,6 @@ public:
|
||||
//ResourceManager::Update();
|
||||
if (m_GameIsRunning) {
|
||||
m_World->Update(dt);
|
||||
|
||||
// I apologize about this.
|
||||
ScreenShakeUpdate(dt);
|
||||
} else {
|
||||
m_EventBroker->Process<Systems::SoundSystem>();
|
||||
}
|
||||
@@ -600,36 +413,6 @@ public:
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
void ScreenShakeUpdate(double dt)
|
||||
{
|
||||
if (m_ScreenShake) {
|
||||
m_ShakeTimer += dt;
|
||||
if (m_ShakeTimer >= m_ShakeEndTime) {
|
||||
//std::cout << "Used: " << m_ShakeIntensity << " True: " << m_ShakeRepresentativeIntensity << std::endl;
|
||||
m_ShakeRepresentativeIntensity -= m_ShakeRepresentativeIntensity * m_CoolerMultiplier * dt;
|
||||
m_ShakeIntensity = m_ShakeRepresentativeIntensity;
|
||||
if (m_ShakeIntensity <= 0) {
|
||||
m_ScreenShake = false;
|
||||
m_Renderer->PlaceCamera(glm::vec3(0, 0, 0));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//std::cout << "Timer: " << m_ShakeTimer << " End: " << m_ShakeEndTime << std::endl;
|
||||
}
|
||||
float randomX = (rand() % m_ShakeIntensity);
|
||||
float randomY = (rand() % m_ShakeIntensity);
|
||||
|
||||
float half = m_ShakeIntensity / 2;
|
||||
|
||||
randomX = (randomX - half) / 20;
|
||||
randomY = (randomY - half) / 20;
|
||||
|
||||
//std::cout << "X: " << randomX << " Y: " << randomY << std::endl;
|
||||
|
||||
m_Renderer->PlaceCamera(glm::vec3(randomX, randomY, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<EventBroker> m_EventBroker;
|
||||
GUI::Frame* m_FrameStack = nullptr;
|
||||
@@ -662,27 +445,6 @@ private:
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//TODO: Extreme Redo.
|
||||
bool m_ScreenShake = false;
|
||||
int m_ShakeIntensity = 0;
|
||||
float m_ShakeRepresentativeIntensity = 0;
|
||||
float m_ShakeTimer = 0;
|
||||
float m_ShakeEndTime = 0;
|
||||
float m_TimeTakenToCoolDown = 0;
|
||||
float m_CoolerMultiplier = 0;
|
||||
dd::EventRelay<Engine, dd::Events::ScreenShake> m_EScreenShake;
|
||||
bool OnScreenShake(const dd::Events::ScreenShake &event)
|
||||
{
|
||||
m_ScreenShake = true;
|
||||
m_ShakeIntensity = event.Intensity;
|
||||
m_ShakeRepresentativeIntensity = event.Intensity;
|
||||
m_ShakeEndTime = event.Time;
|
||||
m_ShakeTimer = 0;
|
||||
m_TimeTakenToCoolDown = event.TimeTakenToCoolDown;
|
||||
m_CoolerMultiplier = m_ShakeIntensity / m_TimeTakenToCoolDown;
|
||||
return true;
|
||||
}
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
#include "Camera.h"
|
||||
#include "RenderQueue.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ protected:
|
||||
e.FrameName = m_Name;
|
||||
EventBroker->Publish(e);
|
||||
Events::PlaySound soundEvent;
|
||||
soundEvent.FilePath = "Sounds/GUI/hover.wav";
|
||||
soundEvent.FilePath = "Sounds/GUI/hover-n.wav";
|
||||
EventBroker->Publish(soundEvent);
|
||||
|
||||
} else if (!isOver && m_MouseIsOver) { // Leave
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
}
|
||||
else {
|
||||
Events::PlaySound e;
|
||||
e.FilePath = "Sounds/GUI/click.wav";
|
||||
e.FilePath = "Sounds/GUI/click-n.wav";
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
@@ -32,6 +34,7 @@
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EActionButton.h"
|
||||
@@ -94,7 +97,7 @@ public:
|
||||
|
||||
private:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
float m_EdgeX = 3.2f;
|
||||
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
|
||||
float m_EdgeY = 5.2f;
|
||||
int m_MultiBalls = 0;
|
||||
int m_Lives = 3;
|
||||
@@ -108,6 +111,7 @@ private:
|
||||
bool m_InkBlockedWaiting = false;
|
||||
bool m_Restarting = false;
|
||||
int m_StickyCounter = 3;
|
||||
bool m_GodMode = false;
|
||||
|
||||
bool m_StageBlockedWaiting = false;
|
||||
|
||||
@@ -127,6 +131,7 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<BallSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
@@ -141,6 +146,7 @@ private:
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CBACKGROUND_H
|
||||
#define DAYDREAM_CBACKGROUND_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Background : Component
|
||||
{
|
||||
float distanceLeftToCorrectTravelPosition;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CBACKGROUND_H
|
||||
@@ -19,6 +19,7 @@ struct Brick : Component
|
||||
//0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken
|
||||
int Type = 0;
|
||||
bool Removed = false;
|
||||
int Number = 0; // For the Kraken to keep track of which bricks needs replacing.
|
||||
|
||||
//What number of types each is.
|
||||
const int EmptyBrickSpace = 0;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CKRAKEN_H
|
||||
#define DAYDREAM_CKRAKEN_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Kraken : Component {
|
||||
|
||||
int Health = 10;
|
||||
int CurrentAction = 1;
|
||||
|
||||
const int Idle = 1;
|
||||
const int Grabbing = 2;
|
||||
const int Taunting = 3;
|
||||
const int Moving = 4;
|
||||
const int BrickGenerating = 5;
|
||||
// Idle. Generating bricks. Taunting. No idea.
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CKRAKEN_H
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CTRAVELS_H
|
||||
#define DAYDREAM_CTRAVELS_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Travels : Component
|
||||
{
|
||||
//This indicates that the object moves upon moving to the next stage. Place this on an object that is to move.
|
||||
//The camera does not move. Things that are to follow the camera should not have this component.
|
||||
|
||||
bool CurrentlyTraveling = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CTRAVELS_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CWALL_H
|
||||
#define DAYDREAM_CWALL_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Wall : Component
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CWALL_H
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-16.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EBRICKGENERATING_H
|
||||
#define DAYDREAM_EBRICKGENERATING_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct BrickGenerating : Event
|
||||
{
|
||||
glm::vec3 Origin;
|
||||
int TargetLine;
|
||||
int Set;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EBRICKGENERATING_H
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EKRAKENAPPEAR_H
|
||||
#define DAYDREAM_EKRAKENAPPEAR_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct KrakenAppear : Event
|
||||
{
|
||||
int Health;
|
||||
glm::vec3 Position;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EKRAKENAPPEAR_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Administrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERAISEWATER_H
|
||||
#define DAYDREAM_ERAISEWATER_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct RaiseWater : Event
|
||||
{
|
||||
float Amount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERAISEWATER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERESETALL_H
|
||||
#define DAYDREAM_ERESETALL_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ResetAll : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERESETALL_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-19.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERESUME_H
|
||||
#define DAYDREAM_ERESUME_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct Resume : Event
|
||||
{
|
||||
std::string Type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERESUME_H
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
@@ -70,16 +71,18 @@ public:
|
||||
std::string& CurrentType() { return m_CurrentType; }
|
||||
void SetCurrentType(const std::string& currentType) { m_CurrentType = currentType; }
|
||||
private:
|
||||
bool m_Pause;
|
||||
bool m_HitLag;
|
||||
bool m_Pause = false;
|
||||
bool m_HitLag = false;
|
||||
float m_HitLagDuration;
|
||||
float m_HitLagTimer;
|
||||
std::string m_CurrentType;
|
||||
|
||||
dd::EventRelay<HitLagSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<HitLagSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<HitLagSystem, dd::Events::HitLag> m_EHitLag;
|
||||
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-15.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_KRAKENSYSTEM_H
|
||||
#define DAYDREAM_KRAKENSYSTEM_H
|
||||
|
||||
#include <random>
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EKrakenAppear.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EBrickGenerating.h"
|
||||
#include "Game/CTravels.h"
|
||||
#include "Game/CKraken.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
//#include "Core/Camera.h" Camera Component
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class KrakenSystem : public System
|
||||
{
|
||||
public:
|
||||
KrakenSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
void InitializeObjects();
|
||||
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
private:
|
||||
std::mt19937 m_RandomGenerator;
|
||||
|
||||
bool m_Pause = false;
|
||||
bool m_KrakenBattle = false;
|
||||
bool m_ReturnToIdle = false;
|
||||
EntityID m_KrakenTemplate;
|
||||
std::string m_Action = "Idle";
|
||||
float m_KrakenTimer = 0;
|
||||
float m_KrakenSecondsToAction = 1;
|
||||
const int Idle = 1;
|
||||
|
||||
std::array<int, 14> m_Bricks;
|
||||
std::array<int, 14> m_Colors;
|
||||
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenAppear> m_EKrakenAppear;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnKrakenAppear(const dd::Events::KrakenAppear &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
void GetBrickSet();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_KRAKENSYSTEM_H
|
||||
@@ -14,14 +14,22 @@
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
|
||||
#include "Transform/EMove.h"
|
||||
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CWall.h"
|
||||
#include "Game/CBackground.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/CTravels.h"
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
|
||||
@@ -38,14 +46,19 @@
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
|
||||
#include "Game/EKrakenAppear.h"
|
||||
#include "Game/EBrickGenerating.h"
|
||||
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
@@ -82,7 +95,7 @@ public:
|
||||
|
||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||
void CreateLevel(int);
|
||||
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||
EntityID CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||
void BrickHit(EntityID, EntityID, int);
|
||||
|
||||
void OnEntityRemoved(EntityID entity);
|
||||
@@ -137,6 +150,7 @@ private:
|
||||
float m_SpaceToEdge = 0.25f;
|
||||
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
|
||||
float m_NotResettingTheStage = 5.f;
|
||||
bool m_GodMode = false;
|
||||
|
||||
const int EmptyBrickSpace = 0;
|
||||
const int StandardBrick = 1;
|
||||
@@ -146,11 +160,16 @@ private:
|
||||
const int InkBlasterBrick = 5;
|
||||
const int KrakenAttackBrick = 6;
|
||||
|
||||
const int Kraken = 100;
|
||||
|
||||
EntityID m_BrickTemplate;
|
||||
|
||||
std::array<int, 42> m_Bricks;
|
||||
std::array<glm::vec4, 42> m_Colors;
|
||||
|
||||
std::array<int, 14> m_BrickSet;
|
||||
std::array<glm::vec4, 14> m_ColorSet;
|
||||
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
||||
dd::EventRelay<LevelSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
@@ -159,7 +178,9 @@ private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
||||
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<LevelSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<LevelSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<LevelSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
||||
@@ -169,7 +190,10 @@ private:
|
||||
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
void GetBrickSet(int Set);
|
||||
|
||||
void GetNextLevel();
|
||||
void SetBrokenModel(EntityID entity);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
@@ -15,11 +17,11 @@
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -48,11 +50,13 @@ private:
|
||||
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Lifebuoy> m_ELifebuoy;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::LifebuoyHit> m_ELifebuoyHit;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||
bool OnLifebuoyHit(const dd::Events::LifebuoyHit &event);
|
||||
|
||||
|
||||
@@ -13,20 +13,31 @@
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
|
||||
#include "Input/EBindKey.h"
|
||||
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
|
||||
#include "Transform/EMove.h"
|
||||
#include "Transform/ERotate.h"
|
||||
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/CStickyAim.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EResetAll.h"
|
||||
#include "Game/ERaiseWater.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EStickyAttachedToPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
@@ -34,11 +45,14 @@
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
|
||||
#include "Game/EBrickGenerating.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -103,7 +117,10 @@ private:
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<PadSystem, dd::Events::ResetAll> m_EResetAll;
|
||||
dd::EventRelay<PadSystem, dd::Events::RaiseWater> m_ERaiseWater;
|
||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
|
||||
@@ -115,7 +132,10 @@ private:
|
||||
bool OnContactPowerUp(const dd::Events::Contact &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnResetAll(const dd::Events::ResetAll &event);
|
||||
bool OnRaiseWater(const dd::Events::RaiseWater &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
@@ -56,12 +58,14 @@ private:
|
||||
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_SCREENSHAKESYSTEM_H
|
||||
#define DAYDREAM_SCREENSHAKESYSTEM_H
|
||||
|
||||
#include <random>
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
//#include "Core/Camera.h" Camera Component
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class ScreenShakeSystem : public System
|
||||
{
|
||||
public:
|
||||
ScreenShakeSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
void InitializeObjects();
|
||||
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
void FlipPause();
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
private:
|
||||
std::mt19937 m_RandomGenerator;
|
||||
|
||||
bool m_Pause;
|
||||
bool m_ScreenShake;
|
||||
int m_ShakeIntensity;
|
||||
glm::vec3 m_CameraPosition;
|
||||
float m_ShakeRepresentativeIntensity;
|
||||
float m_ShakeTimer;
|
||||
float m_ShakeEndTime;
|
||||
float m_TimeTakenToCoolDown;
|
||||
float m_CoolerMultiplier;
|
||||
glm::vec3 m_Random;
|
||||
|
||||
dd::EventRelay<ScreenShakeSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<ScreenShakeSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<ScreenShakeSystem, dd::Events::ScreenShake> m_EScreenShake;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnScreenShake(const dd::Events::ScreenShake &event);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_SCREENSHAKESYSTEM_H
|
||||
@@ -8,11 +8,16 @@
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Transform/EMove.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/CTravels.h"
|
||||
#include "Game/CBackground.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -43,10 +48,14 @@ private:
|
||||
float m_DistanceTravelled = 0;
|
||||
|
||||
dd::EventRelay<TravellingSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<TravellingSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<TravellingSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<TravellingSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <Box2D/Box2D.h>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
@@ -32,6 +34,7 @@
|
||||
|
||||
#include "CRectangleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
@@ -114,6 +117,8 @@ namespace dd
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Resume> m_EResume;
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -25,7 +26,9 @@ private:
|
||||
bool m_Paused = false;
|
||||
|
||||
EventRelay<AnimationSystem, Events::Pause> m_EPause;
|
||||
EventRelay<AnimationSystem, Events::Resume> m_EResume;
|
||||
bool OnPause(const Events::Pause& e);
|
||||
bool OnResume(const Events::Resume& e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ public:
|
||||
void Update(double dt) override;
|
||||
|
||||
private:
|
||||
const std::string MENU_BGM = "Sounds/BGM/eastern-music.wav";
|
||||
const std::string GAME_BGM = "Sounds/BGM/under-the-sea-n.wav";
|
||||
const std::string WATER_BGM = "Sounds/BGM/water-flowing.wav";
|
||||
|
||||
float m_BGMMasterVolume = 1.f;
|
||||
float m_SFXMasterVolume = 1.f;
|
||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||
|
||||
@@ -39,14 +39,38 @@ public:
|
||||
TransformSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
Components::Transform AbsoluteTransform(EntityID entity);
|
||||
glm::vec3 AbsolutePosition(EntityID entity);
|
||||
glm::quat AbsoluteOrientation(EntityID entity);
|
||||
glm::vec3 AbsoluteScale(EntityID entity);
|
||||
|
||||
// Events
|
||||
EventRelay<TransformSystem, Events::Move> m_EMove;
|
||||
bool OnMove(const Events::Move &event);
|
||||
EventRelay<TransformSystem, Events::Rotate> m_ERotate;
|
||||
bool OnRotate(const Events::Rotate &event);
|
||||
private:
|
||||
struct MoveItems
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::vec3 GoalPosition;
|
||||
float Speed;
|
||||
};
|
||||
std::unordered_map<EntityID, MoveItems> m_MoveItems;
|
||||
std::multimap<EntityID, MoveItems> m_QueuedMoveItems;
|
||||
struct RotationItems
|
||||
{
|
||||
EntityID Entity;
|
||||
glm::quat GoalRotation;
|
||||
double Time;
|
||||
};
|
||||
std::unordered_map<EntityID, RotationItems> m_RotationItems;
|
||||
std::multimap<EntityID, RotationItems> m_QueuedRotationItems;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -123,7 +123,8 @@ void dd::Renderer::CreateBuffers()
|
||||
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
||||
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
||||
m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.png");
|
||||
m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png");
|
||||
//m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png");
|
||||
m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Particles/FadeBall.png");
|
||||
|
||||
glGenRenderbuffers(1, &m_RbDepthBuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_RbDepthBuffer);
|
||||
@@ -207,8 +208,8 @@ void dd::Renderer::CreateBuffers()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Resolution.Width, m_Resolution.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
//Fill water pass
|
||||
glGenFramebuffers(1, &m_FbWater);
|
||||
@@ -557,7 +558,9 @@ void dd::Renderer::DrawWater(RenderQueue &rq)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
m_SpWater2->Bind();
|
||||
//TODO: Add this in water particle component. Blurradius
|
||||
float radius = 3.f;
|
||||
|
||||
float radius = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Water.Radius", 0.2f);
|
||||
radius *= 35;
|
||||
|
||||
glUniform2fv(glGetUniformLocation(shaderProgramHandle, "dir"), 1, glm::value_ptr(glm::vec2(1.0f, 0.0f)));
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "res"), m_Resolution.Width);
|
||||
|
||||
@@ -21,7 +21,8 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &BallSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &BallSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EArrivedAtNewStage, &BallSystem::OnArrivedToNewStage);
|
||||
@@ -31,7 +32,7 @@ void dd::Systems::BallSystem::Initialize()
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(0.f, 0.26f, -10.f);
|
||||
transform->Position = glm::vec3(-20.f, 0.26f, -10.f);
|
||||
transform->Scale = glm::vec3(0.3f, 0.3f, 0.3f);
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
@@ -49,7 +50,6 @@ void dd::Systems::BallSystem::Initialize()
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||
physics->Calculate = true;
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
@@ -64,6 +64,8 @@ void dd::Systems::BallSystem::Initialize()
|
||||
for (int i = 0; i < Lives(); i++) {
|
||||
CreateLife(i);
|
||||
}
|
||||
|
||||
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
|
||||
}
|
||||
|
||||
void dd::Systems::BallSystem::Update(double dt)
|
||||
@@ -87,8 +89,13 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
{
|
||||
//TODO: When the ball collides with 2 bricks on the same frame it is reflected and then reflected again, make it reflect only once like a list or something?
|
||||
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||
if (IsPaused()) {
|
||||
|
||||
/*if (IsPaused()) {
|
||||
if (ballComponent != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
@@ -108,7 +115,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
ballComponent->Paused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
@@ -170,7 +177,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
return;
|
||||
}
|
||||
} //Removing this made the wall collisions work again
|
||||
/*else if (transformBall->Position.x > EdgeX()) {
|
||||
/* else if (transformBall->Position.x > EdgeX()) {
|
||||
if (transformBall->Velocity.x > 0) {
|
||||
glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(1, 0));
|
||||
transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
@@ -180,7 +187,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(-1, 0));
|
||||
transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
}
|
||||
} else if (transformBall->Position.y > EdgeY()) {
|
||||
} /*else if (transformBall->Position.y > EdgeY()) {
|
||||
if (transformBall->Velocity.y > 0) {
|
||||
glm::vec2 reflectedVelocity = glm::reflect(glm::vec2(transformBall->Velocity.x, transformBall->Velocity.y), glm::vec2(0, 1));
|
||||
transformBall->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
@@ -212,18 +219,26 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
|
||||
bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "BallSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "BallSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "BallSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
m_Pause = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::BallSystem::OnEntityCommit(EntityID entity)
|
||||
{
|
||||
|
||||
@@ -269,6 +284,10 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ballComponent->Waiting || ballComponent->Sticky) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(ballEntity);
|
||||
glm::vec2 ballVelocity = glm::vec2(ballTransform->Velocity.x, ballTransform->Velocity.y);
|
||||
@@ -321,9 +340,6 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
EventBroker->Publish(particleEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ballComponent->Combo = 0;
|
||||
if (!ballComponent->Waiting) {
|
||||
if (m_InkBlaster) {
|
||||
@@ -341,7 +357,8 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
m_Sticky = false;
|
||||
m_Waiting = 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->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity *= -1;
|
||||
Events::StickyAttachedToPad e;
|
||||
@@ -417,7 +434,6 @@ void dd::Systems::BallSystem::CreateLife(int number)
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
||||
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
||||
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
transform->Sticky = true;
|
||||
|
||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||
lifeNr->Number = number;
|
||||
@@ -431,8 +447,9 @@ void dd::Systems::BallSystem::CreateLife(int number)
|
||||
|
||||
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
||||
{
|
||||
SetLives(Lives() - 1);
|
||||
|
||||
if (!m_GodMode){
|
||||
SetLives(Lives() - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -485,6 +502,7 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
|
||||
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||
{
|
||||
m_Sticky = true;
|
||||
m_StickyCounter = event.Times;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
void dd::Systems::HitLagSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &HitLagSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &HitLagSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &HitLagSystem::OnHitLag);
|
||||
}
|
||||
|
||||
@@ -29,25 +30,33 @@ void dd::Systems::HitLagSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::HitLagSystem::FlipPause()
|
||||
{
|
||||
Events::Pause e;
|
||||
e.Type = CurrentType();
|
||||
EventBroker->Publish(e);
|
||||
if (!IsPaused()) {
|
||||
Events::Pause e;
|
||||
e.Type = CurrentType();
|
||||
EventBroker->Publish(e);
|
||||
} else {
|
||||
Events::Resume e;
|
||||
e.Type = CurrentType();
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::HitLagSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
m_Pause = true;
|
||||
return true;
|
||||
}
|
||||
bool dd::Systems::HitLagSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::HitLagSystem::OnHitLag(const dd::Events::HitLag &event)
|
||||
{
|
||||
if (HitLag()) {
|
||||
FlipPause();
|
||||
SetHitLagTimer(0);
|
||||
}
|
||||
SetHitLag(true);
|
||||
SetCurrentType(event.Type);
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-15.
|
||||
//
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/KrakenSystem.h"
|
||||
|
||||
void dd::Systems::KrakenSystem::Initialize()
|
||||
{
|
||||
std::random_device rd;
|
||||
m_RandomGenerator = std::mt19937(rd());
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &KrakenSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &KrakenSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAppear, &KrakenSystem::OnKrakenAppear);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &KrakenSystem::OnKrakenAttack);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &KrakenSystem::OnBrickGenerating);
|
||||
|
||||
EntityID ent = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
auto kraken = m_World->AddComponent<Components::Kraken>(ent);
|
||||
std::shared_ptr<Components::RectangleShape> cCircle = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
cCircle->Dimensions = glm::vec2(2, 4);
|
||||
//cCircle->Radius = 2;
|
||||
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(ent);
|
||||
std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
|
||||
auto travels = m_World->AddComponent<Components::Travels>(ent);
|
||||
travels->CurrentlyTraveling = false;
|
||||
|
||||
cPhys->CollisionType = CollisionType::Type::Static;
|
||||
cPhys->GravityScale = 0.f;
|
||||
cPhys->Category = CollisionLayer::Type::Brick;
|
||||
cPhys->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||
|
||||
model->ModelFile = "Models/Test/Ball/Sid.obj";
|
||||
transform->Position = glm::vec3(50, 50, -10);
|
||||
//sound
|
||||
auto collisionSound = m_World->AddComponent<Components::CollisionSound>(ent);
|
||||
collisionSound->FilePath = "Sounds/Brick/LTTP_Boss_Hit.wav";
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_KrakenTemplate = ent;
|
||||
|
||||
InitializeObjects();
|
||||
}
|
||||
|
||||
void dd::Systems::KrakenSystem::InitializeObjects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dd::Systems::KrakenSystem::Update(double dt)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::KrakenSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
auto kraken = m_World->GetComponent<Components::Kraken>(entity);
|
||||
if (kraken != nullptr) {
|
||||
Events::KrakenAttack krakenAttack;
|
||||
switch (kraken->CurrentAction)
|
||||
{
|
||||
case 1: // Idle
|
||||
//m_KrakenTimer += dt;
|
||||
if (m_KrakenTimer > m_KrakenSecondsToAction) {
|
||||
m_KrakenTimer = 0;
|
||||
std::uniform_real_distribution<float> dist(1, 2.999f);
|
||||
float random = dist(m_RandomGenerator);
|
||||
std::cout << random << std::endl;
|
||||
kraken->CurrentAction = random;
|
||||
std::cout << kraken->CurrentAction << std::endl;
|
||||
}
|
||||
break;
|
||||
case 2: // Grabbing
|
||||
kraken->CurrentAction = 5;
|
||||
krakenAttack.ChargeUpdate = 0;
|
||||
krakenAttack.KrakenStrength = 0.1;
|
||||
krakenAttack.PlayerStrength = 0.05;
|
||||
EventBroker->Publish(krakenAttack);
|
||||
break;
|
||||
case 3: // Brick Generating
|
||||
break;
|
||||
case 4: // Moving
|
||||
break;
|
||||
case 5: // Taunting
|
||||
if (m_ReturnToIdle) {
|
||||
m_ReturnToIdle = false;
|
||||
kraken->CurrentAction = Idle;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//LOG_INFO("Something's probably off about the random number generator.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
/*if (event.Type != "KrakenSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "KrakenSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnKrakenAppear(const dd::Events::KrakenAppear &event)
|
||||
{
|
||||
auto ent = m_World->CloneEntity(m_KrakenTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
m_KrakenBattle = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
|
||||
{
|
||||
if (event.ChargeUpdate >= 1) {
|
||||
m_ReturnToIdle = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::KrakenSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
+470
-101
@@ -11,15 +11,216 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
{
|
||||
std::random_device rd;
|
||||
m_RandomGenerator = std::mt19937(rd());
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &LevelSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScoreEvent, &LevelSystem::OnScoreEvent);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &LevelSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECreatePowerUp, &LevelSystem::OnCreatePowerUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &LevelSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &LevelSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScoreEvent, &LevelSystem::OnScoreEvent);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &LevelSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECreatePowerUp, &LevelSystem::OnCreatePowerUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &LevelSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &LevelSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating);
|
||||
|
||||
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue("Cheat.GodMode", false);
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 20.f;
|
||||
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(3.f, -5.f, -5.f);
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 15.f;
|
||||
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
|
||||
//Halfpipe background test model.
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
auto background = m_World->AddComponent<Components::Background>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
auto travels = m_World->AddComponent<Components::Travels>(t_halfPipe);
|
||||
travels->CurrentlyTraveling = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
|
||||
auto t_halfPipe2 = m_World->CloneEntity(t_halfPipe);
|
||||
auto transform2 = m_World->GetComponent<Components::Transform>(t_halfPipe);
|
||||
transform2->Position = glm::vec3(0.f, 34.6f, -15.f); //Halfpipe Value
|
||||
}
|
||||
|
||||
//Background
|
||||
|
||||
/*{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
auto travels = m_World->AddComponent<Components::Travels>(background);
|
||||
travels->CurrentlyTraveling = false;
|
||||
auto backgroundComponent = m_World->AddComponent<Components::Background>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -30.f);
|
||||
transform->Scale = glm::vec3(2681.f / 50.f, 1080.f / 50.f, 1.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(background);
|
||||
sprite->SpriteFile = "Textures/Background.png";
|
||||
m_World->CommitEntity(background);
|
||||
}*/
|
||||
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
//ParticleTest
|
||||
|
||||
|
||||
/*{
|
||||
auto Pe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
|
||||
auto emitteSprite = m_World->AddComponent<Components::Sprite>(Pe);
|
||||
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png";
|
||||
particleEmitter->GravityScale = 0.0f;
|
||||
particleEmitter->SpawnRate = 1.f;
|
||||
particleEmitter->NumberOfTicks = 2;
|
||||
particleEmitter->Speed = 1.f;
|
||||
particleEmitter->ParticlesPerTick = 5;
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
|
||||
auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
|
||||
|
||||
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
PtTransform->Position = transform->Position;
|
||||
PtSprite->SpriteFile = "Textures/Background.png";
|
||||
PtParticle->LifeTime = 3.f;
|
||||
PtParticle->Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter);
|
||||
}
|
||||
m_World->CommitEntity(Pe);
|
||||
}*/
|
||||
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto BottomWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
|
||||
auto wall = m_World->AddComponent<Components::Wall>(BottomWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
if (m_GodMode) {
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy | CollisionLayer::Ball);
|
||||
} else {
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||
}
|
||||
m_World->CommitEntity(BottomWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
|
||||
auto wall = m_World->AddComponent<Components::Wall>(topWall);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto leftWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
leftWall);
|
||||
transform->Position = glm::vec3(-4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
auto wall = m_World->AddComponent<Components::Wall>(leftWall);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto rightWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
rightWall);
|
||||
transform->Position = glm::vec3(4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
auto wall = m_World->AddComponent<Components::Wall>(rightWall);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
m_BrickTemplate = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(m_BrickTemplate);
|
||||
@@ -29,11 +230,14 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
cRec->Dimensions = glm::vec2(0.9f, 0.35f);
|
||||
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(m_BrickTemplate);
|
||||
std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(m_BrickTemplate);
|
||||
|
||||
auto travels = m_World->AddComponent<Components::Travels>(m_BrickTemplate);
|
||||
travels->CurrentlyTraveling = false;
|
||||
|
||||
cPhys->CollisionType = CollisionType::Type::Static;
|
||||
cPhys->GravityScale = 0.f;
|
||||
cPhys->Category = CollisionLayer::Type::Brick;
|
||||
cPhys->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||
transform->Sticky = false;
|
||||
|
||||
model->ModelFile = "Models/Brick/WhiteBrick.obj";
|
||||
transform->Position = glm::vec3(50, 50, -10);
|
||||
@@ -62,15 +266,19 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
// Check the background.
|
||||
auto model = m_World->GetComponent<Components::Model>(entity);
|
||||
if (model != nullptr) {
|
||||
if (model->ModelFile == "Models/Test/halfpipe/Halfpipe.obj") {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y <= -34.6) {
|
||||
transform->Position.y = 34.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto background = m_World->GetComponent<Components::Background>(entity);
|
||||
if (background != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y <= -34.6) { //Halfpipe Value.
|
||||
transform->Position.y = 34.6;
|
||||
Events::Move e;
|
||||
e.Entity = entity;
|
||||
e.GoalPosition = glm::vec3(transform->Position.x, 34.6 + background->distanceLeftToCorrectTravelPosition, transform->Position.z);
|
||||
e.Speed = 6.0f;
|
||||
e.Queue = false;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
|
||||
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||
if (brick != nullptr) {
|
||||
@@ -88,9 +296,11 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
EventBroker->Publish(e);
|
||||
} else if (brick->Type == StickyBrick) {
|
||||
Events::StickyPad e;
|
||||
e.Times = 3;
|
||||
EventBroker->Publish(e);
|
||||
} else if (brick->Type == InkBlasterBrick) {
|
||||
Events::InkBlaster e;
|
||||
e.Shots = 5;
|
||||
EventBroker->Publish(e);
|
||||
} else if(brick->Type == KrakenAttackBrick) {
|
||||
Events::KrakenAttack e;
|
||||
@@ -135,18 +345,24 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
|
||||
bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "LevelSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "LevelSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "LevelSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge)
|
||||
{
|
||||
SetNumberOfBricks(rows * lines);
|
||||
@@ -187,17 +403,22 @@ void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel)
|
||||
SetRestarting(false);
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt, glm::vec4 colorVec)
|
||||
EntityID dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt, glm::vec4 colorVec)
|
||||
{
|
||||
if (typeInt == EmptyBrickSpace) {
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
auto brick = m_World->CloneEntity(m_BrickTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(brick);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(brick);
|
||||
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
|
||||
|
||||
if (typeInt == StandardBrick) {
|
||||
cBrick->Type = StandardBrick;
|
||||
auto type = m_World->AddComponent<Components::StandardBrick>(brick);
|
||||
@@ -223,16 +444,134 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
cBrick->Type = KrakenAttackBrick;
|
||||
auto type = m_World->AddComponent<Components::KrakenAttackBrick>(brick);
|
||||
model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f);
|
||||
} else if (typeInt == Kraken) {
|
||||
Events::KrakenAppear e;
|
||||
e.Position = transform->Position;
|
||||
e.Health = 10;
|
||||
EventBroker->Publish(e);
|
||||
m_World->RemoveEntity(brick);
|
||||
return brick;
|
||||
}
|
||||
|
||||
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
|
||||
cBrick->Score = 10 * num;
|
||||
return;
|
||||
return brick;
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnBrickGenerating(const dd::Events::BrickGenerating &event)
|
||||
{
|
||||
GetBrickSet(event.Set);
|
||||
LOG_DEBUG("This is happening.");
|
||||
|
||||
int rows = 2;
|
||||
int lines = 7;
|
||||
int getter = 0;
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < lines; j++) {
|
||||
auto ent = CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), -4, 1, m_BrickSet[getter], m_ColorSet[getter]);
|
||||
if (ent != NULL) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
Events::Move e;
|
||||
e.GoalPosition = transform->Position;
|
||||
transform->Position = event.Origin;
|
||||
e.Entity = ent;
|
||||
e.Speed = 6;
|
||||
e.Queue = false;
|
||||
EventBroker->Publish(e);
|
||||
m_LooseBricks++;
|
||||
SetNumberOfBricks(NumberOfBricks() + 1);
|
||||
}
|
||||
getter++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::GetBrickSet(int set)
|
||||
{
|
||||
std::array<int, 14> level;
|
||||
std::array<glm::vec4, 14> color;
|
||||
// Level array indicates type of brick.
|
||||
// 0 is empty space.
|
||||
// 1 is standard brick.
|
||||
// 2 is multiball brick.
|
||||
// 3 is lifebuoy brick.
|
||||
// 4 is sticky brick.
|
||||
// 5 is ink blaster brick.
|
||||
// 6 is kraken attack brick.
|
||||
|
||||
// color array determines the color of standard bricks.
|
||||
// w is white.
|
||||
// r is red.
|
||||
// g is green.
|
||||
// b is blue.
|
||||
// y is yellow.
|
||||
// c is cyan.
|
||||
// m is magenta.
|
||||
// d is dark.
|
||||
// Feel free to make your own.
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 0);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 0);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 0);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 0);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 0);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 0);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 0);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 0);
|
||||
|
||||
if (set == 1) {
|
||||
level =
|
||||
{1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1 };
|
||||
color =
|
||||
{r, r, r, r, r, r, r,
|
||||
r, r, r, r, r, r, r };
|
||||
}
|
||||
else if (set == 2) {
|
||||
level =
|
||||
{2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2 };
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w };
|
||||
}
|
||||
else if (set == 3) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0 };
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w };
|
||||
}
|
||||
else if (set == 4) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0 };
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w };
|
||||
}
|
||||
else if (set == 5) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0 };
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w };
|
||||
}
|
||||
else if (set == 6) {
|
||||
level =
|
||||
{0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0 };
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w };
|
||||
}
|
||||
|
||||
std::copy(std::begin(level), std::end(level), std::begin(m_BrickSet));
|
||||
std::copy(std::begin(color), std::end(color), std::begin(m_ColorSet));
|
||||
}
|
||||
|
||||
|
||||
void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
||||
{
|
||||
|
||||
@@ -478,7 +817,6 @@ bool dd::Systems::LevelSystem::OnCreatePowerUp(const dd::Events::CreatePowerUp &
|
||||
cPhys->CollisionType = CollisionType::Type::Dynamic;
|
||||
cPhys->Category = CollisionLayer::Type::PowerUp;
|
||||
cPhys->Mask = CollisionLayer::Type::Pad;
|
||||
transform->Sticky = false;
|
||||
|
||||
std::shared_ptr<Components::PowerUp> cPow = m_World->AddComponent<Components::PowerUp>(powerUp);
|
||||
|
||||
@@ -512,7 +850,7 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
m_CurrentLevel++;
|
||||
if (m_CurrentLevel < 6) {
|
||||
GetNextLevel();
|
||||
CreateLevel(12);
|
||||
CreateLevel(12); //NextLevelDistance
|
||||
} else {
|
||||
// Win
|
||||
Events::ClusterClear e;
|
||||
@@ -539,7 +877,9 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
// 5 is ink blaster brick.
|
||||
// 6 is kraken attack brick.
|
||||
|
||||
// wolor array determines the color of standard bricks.
|
||||
// 100 is KRAKEN!
|
||||
|
||||
// color array determines the color of standard bricks.
|
||||
// w is white.
|
||||
// r is red.
|
||||
// g is green.
|
||||
@@ -572,70 +912,8 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f);
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_CurrentCluster == 0) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -650,7 +928,82 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 100, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 6) {
|
||||
level =
|
||||
{0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 1) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
@@ -658,7 +1011,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 0, 1, 2, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0,
|
||||
1, 0, 1, 0, 1, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
@@ -727,7 +1080,23 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
w, br, w, g, w, lb1, w,
|
||||
y, w, y, d, b, w, b,
|
||||
w, br, w, w, w, lb1, w};
|
||||
}
|
||||
}
|
||||
else if (m_CurrentLevel == 6) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 100, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 3) {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ void dd::Systems::LifebuoySystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &LifebuoySystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LifebuoySystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &LifebuoySystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifebuoy, &LifebuoySystem::OnLifebuoy);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifebuoyHit, &LifebuoySystem::OnLifebuoyHit);
|
||||
|
||||
@@ -29,7 +30,6 @@ void dd::Systems::LifebuoySystem::Initialize()
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick | CollisionLayer::LifeBuoy | CollisionLayer::Pad | CollisionLayer::Water);
|
||||
physics->Density = 1.0f;
|
||||
physics->GravityScale = 1;
|
||||
ctransform->Sticky = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Lifebuoy/Lifebuoy1.obj";
|
||||
auto lifebuoy = m_World->AddComponent<Components::Lifebuoy>(ent);
|
||||
@@ -89,18 +89,23 @@ void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "LifebuoySystem" && event.Type != "All") {
|
||||
/*if (event.Type != "LifebuoySystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "LifebuoySystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
@@ -127,9 +132,30 @@ bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &event)
|
||||
{
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Lifebuoy);
|
||||
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(event.Lifebuoy);
|
||||
lifebuoyComponent->Hits -= 1;
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
|
||||
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
|
||||
|
||||
Events::CreateParticleSequence e;
|
||||
e.EmitterLifeTime = 4;
|
||||
e.EmittingAngle = glm::half_pi<float>();
|
||||
e.Spread = 0.5f;
|
||||
e.NumberOfTicks = 1;
|
||||
e.ParticleLifeTime = 1.f;
|
||||
e.ParticlesPerTick = 1;
|
||||
e.Position = transformComponent->Position;
|
||||
e.ScaleValues.clear();
|
||||
e.ScaleValues.push_back(glm::vec3(0.5f));
|
||||
e.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
|
||||
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||
e.Color = glm::vec4(1, 0, 0, 1);
|
||||
e.AlphaValues.clear();
|
||||
e.AlphaValues.push_back(1.f);
|
||||
e.AlphaValues.push_back(0.f);
|
||||
e.Speed = 10.f;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+83
-18
@@ -28,7 +28,10 @@ void dd::Systems::PadSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &PadSystem::OnResetBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetAll, &PadSystem::OnResetAll);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERaiseWater, &PadSystem::OnRaiseWater);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PadSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenAttack, &PadSystem::OnKrakenAttack);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &PadSystem::OnStickyPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyAttachedToPad, &PadSystem::OnStickyAttachedToPad);
|
||||
@@ -47,7 +50,6 @@ void dd::Systems::PadSystem::Initialize()
|
||||
physics->Category = CollisionLayer::Type::Pad;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::PowerUp | CollisionLayer::LifeBuoy);
|
||||
physics->Calculate = true;
|
||||
ctransform->Sticky = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Ship/Ship.obj";
|
||||
|
||||
@@ -90,6 +92,10 @@ void dd::Systems::PadSystem::Initialize()
|
||||
|
||||
void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
@@ -186,18 +192,24 @@ void dd::Systems::PadSystem::Update(double dt)
|
||||
|
||||
bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "PadSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "PadSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "PadSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
int val = event.KeyCode;
|
||||
if (val == GLFW_KEY_UP) {
|
||||
@@ -215,14 +227,27 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
} else if (val == GLFW_KEY_R) {
|
||||
Events::ResetBall e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_M) {
|
||||
} else if (val == GLFW_KEY_W) {
|
||||
Events::RaiseWater e;
|
||||
e.Amount = 0.2;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_A) {
|
||||
Events::ResetAll e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_M) {
|
||||
Events::MultiBall e;
|
||||
e.padTransform = Transform();
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_P) {
|
||||
Events::Pause e;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
if (IsPaused()) {
|
||||
Events::Resume e;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
} else {
|
||||
Events::Pause e;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
} else if (val == GLFW_KEY_H) {
|
||||
Events::HitLag e;
|
||||
e.Time = 0.2;
|
||||
@@ -237,22 +262,37 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
e.Time = 3;
|
||||
e.TimeTakenToCoolDown = 10;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_G) {
|
||||
Events::BrickGenerating e;
|
||||
e.Origin = glm::vec3(-5, 7, -10);
|
||||
e.Set = 1;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_L) {
|
||||
Events::Lifebuoy e;
|
||||
e.Transform = Transform();
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_Y) {
|
||||
Events::StickyPad e;
|
||||
e.Times = 3;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
else if (val == GLFW_KEY_I) {
|
||||
} else if (val == GLFW_KEY_I) {
|
||||
Events::InkBlaster e;
|
||||
e.Shots = 5;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
else if (val == GLFW_KEY_K) {
|
||||
} 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) {
|
||||
} else if (val == GLFW_KEY_Q) {
|
||||
Events::Move e;
|
||||
e.Entity = Entity();
|
||||
e.GoalPosition = glm::vec3(0, 0, -10);
|
||||
e.Speed = 5;
|
||||
e.Queue = false;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_SPACE) {
|
||||
Events::ActionButton e;
|
||||
e.Position = Transform()->Position;
|
||||
EventBroker->Publish(e);
|
||||
@@ -380,6 +420,31 @@ bool dd::Systems::PadSystem::OnResetBall(const dd::Events::ResetBall &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnResetAll(const dd::Events::ResetAll &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnRaiseWater(const dd::Events::RaiseWater &event)
|
||||
{
|
||||
auto transform = Transform();
|
||||
glm::vec3 raise = glm::vec3(0, event.Amount, 0);
|
||||
transform->Position += raise;
|
||||
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, event.Amount * 1.6f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKrakenAttack(const dd::Events::KrakenAttack &event)
|
||||
{
|
||||
if (!m_KrakenAttack) {
|
||||
|
||||
@@ -11,6 +11,7 @@ void dd::Systems::ProjectileSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &ProjectileSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ProjectileSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
|
||||
@@ -29,11 +30,12 @@ void dd::Systems::ProjectileSystem::Initialize()
|
||||
physics->Category = CollisionLayer::Type::Projectile;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||
physics->Calculate = true;
|
||||
ctransform->Sticky = true;
|
||||
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Test/Ball/Sid.obj";
|
||||
ctransform->Scale = glm::vec3(0.6f, 0.6f, 0.6f);
|
||||
// auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
// cModel->ModelFile = "Models/Test/Ball/Sid.obj";
|
||||
auto cSprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
cSprite->SpriteFile = "Textures/Particles/OilShot.png";
|
||||
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
@@ -46,7 +48,9 @@ void dd::Systems::ProjectileSystem::Initialize()
|
||||
|
||||
void dd::Systems::ProjectileSystem::Update(double dt)
|
||||
{
|
||||
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
@@ -68,18 +72,23 @@ void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, Ent
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
@@ -110,7 +119,7 @@ bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButto
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
transform->Velocity = glm::vec3(0, 5, 0);
|
||||
transform->Velocity = glm::vec3(0, 7, 0);
|
||||
m_Shots--;
|
||||
if (m_Shots <= 0) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-14.
|
||||
//
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/ScreenShakeSystem.h"
|
||||
|
||||
void dd::Systems::ScreenShakeSystem::Initialize()
|
||||
{
|
||||
std::random_device rd;
|
||||
m_RandomGenerator = std::mt19937(rd());
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ScreenShakeSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &ScreenShakeSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScreenShake, &ScreenShakeSystem::OnScreenShake);
|
||||
|
||||
InitializeObjects();
|
||||
}
|
||||
|
||||
void dd::Systems::ScreenShakeSystem::InitializeObjects()
|
||||
{
|
||||
m_Pause = false;
|
||||
m_ScreenShake = false;
|
||||
m_ShakeIntensity = 0;
|
||||
m_CameraPosition = glm::vec3(0, 0, 0);
|
||||
m_ShakeRepresentativeIntensity = 0;
|
||||
m_ShakeTimer = 0;
|
||||
m_ShakeEndTime = 0;
|
||||
m_TimeTakenToCoolDown = 0;
|
||||
m_CoolerMultiplier = 0;
|
||||
m_Random = glm::vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
void dd::Systems::ScreenShakeSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*auto camera = m_World->GetComponent<Components::Camera>(entity);
|
||||
|
||||
if (camera != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
if (m_ScreenShake) {
|
||||
m_CameraPosition = transform->Position - m_Random;
|
||||
|
||||
m_ShakeTimer += dt;
|
||||
if (m_ShakeTimer >= m_ShakeEndTime) {
|
||||
//std::cout << "Used: " << m_ShakeIntensity << " True: " << m_ShakeRepresentativeIntensity << std::endl;
|
||||
m_ShakeRepresentativeIntensity -= m_ShakeRepresentativeIntensity * m_CoolerMultiplier * dt;
|
||||
m_ShakeIntensity = m_ShakeRepresentativeIntensity;
|
||||
if (m_ShakeIntensity <= 0) {
|
||||
m_ScreenShake = false;
|
||||
transform->Position = glm::vec3(0, 0, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//std::cout << "Timer: " << m_ShakeTimer << " End: " << m_ShakeEndTime << std::endl;
|
||||
}
|
||||
std::uniform_real_distribution<float> dist(-m_ShakeIntensity, m_ShakeIntensity);
|
||||
//float impulseStrength = dist(m_RandomGenerator);
|
||||
m_Random.x = dist(m_RandomGenerator) / 20;
|
||||
m_Random.y = dist(m_RandomGenerator) / 20;
|
||||
|
||||
//float half = m_ShakeIntensity / 2;
|
||||
|
||||
//m_Random.x = (m_Random.x - half) / 20;
|
||||
//m_Random.y = (m_Random.y - half) / 20;
|
||||
|
||||
//std::cout << "X: " << randomX << " Y: " << randomY << std::endl;
|
||||
transform->Position = glm::vec3(m_Random);
|
||||
} else {
|
||||
m_CameraPosition = transform->Position;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
bool dd::Systems::ScreenShakeSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
/*if (event.Type != "ScreenShakeSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
m_Pause = true;
|
||||
return true;
|
||||
}
|
||||
bool dd::Systems::ScreenShakeSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "ScreenShakeSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ScreenShakeSystem::OnScreenShake(const dd::Events::ScreenShake &event)
|
||||
{
|
||||
m_ScreenShake = true;
|
||||
m_ShakeIntensity = event.Intensity;
|
||||
m_ShakeRepresentativeIntensity = event.Intensity;
|
||||
m_ShakeEndTime = event.Time;
|
||||
m_ShakeTimer = 0;
|
||||
m_TimeTakenToCoolDown = event.TimeTakenToCoolDown;
|
||||
m_CoolerMultiplier = m_ShakeIntensity / m_TimeTakenToCoolDown;
|
||||
return true;
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
void dd::Systems::TravellingSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &TravellingSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &TravellingSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &TravellingSystem::OnStageCleared);
|
||||
}
|
||||
|
||||
@@ -17,7 +18,7 @@ void dd::Systems::TravellingSystem::Update(double dt)
|
||||
return;
|
||||
}
|
||||
if (m_Travelling) {
|
||||
if (m_DistanceTravelled > 12.f) {
|
||||
if (m_DistanceTravelled > 12.f) { //NextLevelDistance
|
||||
m_DistanceTravelled = 0;
|
||||
m_Travelling = false;
|
||||
Events::ArrivedAtNewStage e;
|
||||
@@ -30,37 +31,80 @@ void dd::Systems::TravellingSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::TravellingSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
if (m_Travelling) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform != nullptr) {
|
||||
if (!transform->Sticky) {
|
||||
transform->Position.y -= 6.0f * dt;
|
||||
auto travels = m_World->GetComponent<Components::Travels>(entity);
|
||||
if (travels != nullptr) {
|
||||
if (!travels->CurrentlyTraveling) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform != nullptr) {
|
||||
Events::Move e;
|
||||
e.Entity = entity;
|
||||
glm::vec3 position = transform->Position;
|
||||
glm::vec3 goalPosition = position;
|
||||
e.Queue = false;
|
||||
e.Speed = 6;
|
||||
goalPosition.y -= 12; //NextLevelDistance
|
||||
if (goalPosition.y < -34.6) { //Halfpipe Value
|
||||
auto background = m_World->GetComponent<Components::Background>(entity);
|
||||
if (background != nullptr) {
|
||||
float yValue = position.y; // A negative value between -34.6 and -22.6;
|
||||
yValue += 22.6; // A positive value between -12 and 0. The distance it should travel from 34.6;
|
||||
background->distanceLeftToCorrectTravelPosition = yValue;
|
||||
} else {
|
||||
m_World->RemoveEntity(entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.GoalPosition = goalPosition;
|
||||
|
||||
travels->CurrentlyTraveling = true;
|
||||
EventBroker->Publish(e);
|
||||
//transform->Position.y -= 6.0f * dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
transform->Position.y -= 6.0f * dt;
|
||||
} else {
|
||||
auto travels = m_World->GetComponent<Components::Travels>(entity);
|
||||
if (travels != nullptr) {
|
||||
travels->CurrentlyTraveling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::TravellingSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "TravellingSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "TravellingSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
}*/
|
||||
m_Pause = true;
|
||||
return true;
|
||||
}
|
||||
bool dd::Systems::TravellingSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "TravellingSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::TravellingSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
if (event.ClearedStage < 5) {
|
||||
m_Travelling = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::TravellingSystem::OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -23,13 +23,14 @@ void dd::Systems::PhysicsSystem::Initialize()
|
||||
InitializeWater();
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &PhysicsSystem::OnResume);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECreateParticleSequence, &PhysicsSystem::CreateParticleSequence);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &PhysicsSystem::OnContact);
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
{
|
||||
float radius = 0.13f;
|
||||
float radius = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Water.Radius", 0.2f);
|
||||
float gravityScale = 1.0f;
|
||||
|
||||
b2ParticleSystemDef m_ParticleSystemDef;
|
||||
@@ -244,6 +245,10 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto particle = m_World->GetComponent<Components::Particle>(entity);
|
||||
auto pTemplate = m_World->GetComponent<Components::Template>(entity);
|
||||
|
||||
@@ -333,18 +338,22 @@ glm::vec3 dd::Systems::PhysicsSystem::VectorInterpolation(float timeProgress, st
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "PhysicsSystem" && event.Type != "All") {
|
||||
/*if (event.Type != "PhysicsSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Pause) {
|
||||
m_Pause = false;
|
||||
} else {
|
||||
m_Pause = true;
|
||||
}
|
||||
}*/
|
||||
m_Pause = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnResume(const dd::Events::Resume &event)
|
||||
{
|
||||
/*if (event.Type != "PhysicsSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}*/
|
||||
m_Pause = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
||||
{
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||
@@ -477,6 +486,7 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
|
||||
transformChild->Position = glm::vec3(t_ParticlePositions[i].x - transform->Position.x, t_ParticlePositions[i].y - transform->Position.y, -9.5f);
|
||||
transformChild->Scale = glm::vec3(m_WaterParticleSystem->GetRadius())/transform->Scale;
|
||||
transformChild->Scale *= 2;
|
||||
m_World->CommitEntity(t_waterparticle);
|
||||
|
||||
m_EntitiesToWaterParticleHandle.insert(std::make_pair(t_waterparticle, m_WaterParticleSystem->GetParticleHandleFromIndex(i)));
|
||||
|
||||
@@ -9,6 +9,7 @@ void dd::Systems::AnimationSystem::RegisterComponents(ComponentFactory* cf)
|
||||
void dd::Systems::AnimationSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &AnimationSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResume, &AnimationSystem::OnResume);
|
||||
}
|
||||
|
||||
void dd::Systems::AnimationSystem::Update(double dt)
|
||||
@@ -30,6 +31,12 @@ void dd::Systems::AnimationSystem::Update(double dt)
|
||||
|
||||
bool dd::Systems::AnimationSystem::OnPause(const Events::Pause& e)
|
||||
{
|
||||
m_Paused = !m_Paused;
|
||||
m_Paused = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::AnimationSystem::OnResume(const Events::Resume& e)
|
||||
{
|
||||
m_Paused = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@ void dd::Systems::SoundSystem::Initialize()
|
||||
|
||||
m_SFXMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.SFXVolume", 1.f);
|
||||
m_BGMMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.BGMVolume", 1.f);
|
||||
|
||||
//TODO: Move this
|
||||
Events::PlaySound e;
|
||||
e.FilePath = MENU_BGM;
|
||||
e.IsAmbient = true;
|
||||
e.Gain = 0.2f;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void dd::Systems::SoundSystem::Update(double dt)
|
||||
@@ -114,12 +121,13 @@ bool dd::Systems::SoundSystem::OnStopSound(const dd::Events::StopSound &event)
|
||||
{
|
||||
if (item.second->Path() == event.FilePath) {
|
||||
itemToDeleted = item.first;
|
||||
break;
|
||||
alSourceStop(itemToDeleted);
|
||||
alDeleteSources(1, &itemToDeleted);
|
||||
m_BGMSourcesToBuffers.erase(itemToDeleted);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
alSourceStop(itemToDeleted);
|
||||
alDeleteSources(1, &itemToDeleted);
|
||||
m_BGMSourcesToBuffers.erase(itemToDeleted);
|
||||
|
||||
|
||||
//Should not happen because SFX's should be very short.
|
||||
for (auto item : m_SFXSourcesToBuffers)
|
||||
@@ -180,15 +188,20 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
|
||||
|
||||
bool dd::Systems::SoundSystem::OnGameStart(const dd::Events::GameStart &event)
|
||||
{
|
||||
{
|
||||
dd::Events::StopSound e;
|
||||
e.FilePath = MENU_BGM;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
e.FilePath = GAME_BGM;
|
||||
e.IsAmbient = true;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.FilePath = "Sounds/BGM/water-flowing.wav";
|
||||
e.FilePath = WATER_BGM;
|
||||
e.Gain = 0.3f;
|
||||
e.IsAmbient = true;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
@@ -20,12 +20,125 @@
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Core/World.h"
|
||||
|
||||
void dd::Systems::TransformSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMove, &Systems::TransformSystem::OnMove);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ERotate, &Systems::TransformSystem::OnRotate);
|
||||
}
|
||||
|
||||
void dd::Systems::TransformSystem::Update(double dt)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::TransformSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (m_MoveItems.find(entity) != m_MoveItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position);
|
||||
glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt;
|
||||
|
||||
glm::vec3 v1 = m_MoveItems[entity].GoalPosition - transform->Position;
|
||||
glm::vec3 v2 = movement;
|
||||
|
||||
if (glm::length(v2) >= glm::length(v1))
|
||||
{
|
||||
transform->Position = m_MoveItems[entity].GoalPosition;
|
||||
//transform->Velocity = glm::vec3(0, 0, 0);
|
||||
|
||||
m_MoveItems.erase(entity);
|
||||
|
||||
if (m_QueuedMoveItems.find(entity) != m_QueuedMoveItems.end())
|
||||
{
|
||||
auto it = m_QueuedMoveItems.find(entity);
|
||||
m_MoveItems[entity] = it->second;
|
||||
m_QueuedMoveItems.erase(it->first);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transform->Position += movement;
|
||||
//transform->Velocity = movement;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_RotationItems.find(entity) != m_RotationItems.end())
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
auto absolutetransform = AbsoluteTransform(entity);
|
||||
|
||||
float percentage = dt / m_RotationItems[entity].Time;
|
||||
m_RotationItems[entity].Time -= dt;
|
||||
glm::clamp(percentage, 0.f, 1.0f);
|
||||
transform->Orientation = glm::slerp(transform->Orientation, m_RotationItems[entity].GoalRotation, percentage);
|
||||
|
||||
if (m_RotationItems[entity].Time <= 0)
|
||||
{
|
||||
m_RotationItems.erase(entity);
|
||||
|
||||
if (m_QueuedRotationItems.find(entity) != m_QueuedRotationItems.end())
|
||||
{
|
||||
auto it = m_QueuedRotationItems.find(entity);
|
||||
m_RotationItems[entity] = it->second;
|
||||
m_QueuedRotationItems.erase(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::TransformSystem::OnRotate(const Events::Rotate &event)
|
||||
{
|
||||
RotationItems item;
|
||||
item.Entity = event.Entity;
|
||||
item.GoalRotation = event.GoalRotation;
|
||||
item.Time = event.Time;
|
||||
|
||||
if (event.Queue)
|
||||
{
|
||||
if (m_RotationItems.find(event.Entity) != m_RotationItems.end())
|
||||
{
|
||||
m_QueuedRotationItems.insert(std::make_pair(event.Entity, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RotationItems[event.Entity] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RotationItems[event.Entity] = item;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::TransformSystem::OnMove(const Events::Move &event)
|
||||
{
|
||||
MoveItems item;
|
||||
item.Entity = event.Entity;
|
||||
item.GoalPosition = event.GoalPosition;
|
||||
item.Speed = event.Speed;
|
||||
|
||||
if (event.Queue)
|
||||
{
|
||||
if (m_MoveItems.find(event.Entity) != m_MoveItems.end())
|
||||
{
|
||||
m_QueuedMoveItems.insert(std::make_pair(event.Entity, item));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MoveItems[event.Entity] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MoveItems[event.Entity] = item;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
glm::vec3 dd::Systems::TransformSystem::AbsolutePosition(EntityID entity)
|
||||
{
|
||||
glm::vec3 absPosition;
|
||||
|
||||
Reference in New Issue
Block a user