Merge remote-tracking branch 'origin/master' into LevelSystemAndSuch
This commit is contained in:
@@ -9,4 +9,4 @@ BGMVolume=0.5
|
|||||||
[Video]
|
[Video]
|
||||||
Fullscreen=false
|
Fullscreen=false
|
||||||
Width=675
|
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.
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Executable
BIN
Binary file not shown.
@@ -206,6 +206,7 @@ public:
|
|||||||
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
|
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
|
|
||||||
|
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||||
m_EventBroker->Subscribe(m_EGameStart);
|
m_EventBroker->Subscribe(m_EGameStart);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
#include "Game/EScreenShake.h"
|
#include "Game/EScreenShake.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "RenderQueue.h"
|
#include "RenderQueue.h"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ protected:
|
|||||||
e.FrameName = m_Name;
|
e.FrameName = m_Name;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
Events::PlaySound soundEvent;
|
Events::PlaySound soundEvent;
|
||||||
soundEvent.FilePath = "Sounds/GUI/hover.wav";
|
soundEvent.FilePath = "Sounds/GUI/hover-n.wav";
|
||||||
EventBroker->Publish(soundEvent);
|
EventBroker->Publish(soundEvent);
|
||||||
|
|
||||||
} else if (!isOver && m_MouseIsOver) { // Leave
|
} else if (!isOver && m_MouseIsOver) { // Leave
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Events::PlaySound e;
|
Events::PlaySound e;
|
||||||
e.FilePath = "Sounds/GUI/click.wav";
|
e.FilePath = "Sounds/GUI/click-n.wav";
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
#include "Physics/CPhysics.h"
|
#include "Physics/CPhysics.h"
|
||||||
#include "Physics/CCircleShape.h"
|
#include "Physics/CCircleShape.h"
|
||||||
#include "Physics/CRectangleShape.h"
|
#include "Physics/CRectangleShape.h"
|
||||||
@@ -109,6 +111,7 @@ private:
|
|||||||
bool m_InkBlockedWaiting = false;
|
bool m_InkBlockedWaiting = false;
|
||||||
bool m_Restarting = false;
|
bool m_Restarting = false;
|
||||||
int m_StickyCounter = 3;
|
int m_StickyCounter = 3;
|
||||||
|
bool m_GodMode = false;
|
||||||
|
|
||||||
bool m_StageBlockedWaiting = false;
|
bool m_StageBlockedWaiting = false;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
#include "Rendering/CSprite.h"
|
#include "Rendering/CSprite.h"
|
||||||
#include "Rendering/CModel.h"
|
#include "Rendering/CModel.h"
|
||||||
#include "Rendering/CPointLight.h"
|
#include "Rendering/CPointLight.h"
|
||||||
@@ -153,6 +155,7 @@ private:
|
|||||||
float m_SpaceToEdge = 0.25f;
|
float m_SpaceToEdge = 0.25f;
|
||||||
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
|
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
|
||||||
float m_NotResettingTheStage = 5.f;
|
float m_NotResettingTheStage = 5.f;
|
||||||
|
bool m_GodMode = false;
|
||||||
|
|
||||||
const int EmptyBrickSpace = 0;
|
const int EmptyBrickSpace = 0;
|
||||||
const int StandardBrick = 1;
|
const int StandardBrick = 1;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
||||||
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/CTransform.h"
|
#include "Core/CTransform.h"
|
||||||
#include "Core/CTemplate.h"
|
#include "Core/CTemplate.h"
|
||||||
@@ -19,8 +21,7 @@
|
|||||||
#include "Game/ELifebuoy.h"
|
#include "Game/ELifebuoy.h"
|
||||||
#include "Game/ELifebuoyHit.h"
|
#include "Game/ELifebuoyHit.h"
|
||||||
#include "Game/CLifebuoy.h"
|
#include "Game/CLifebuoy.h"
|
||||||
#include <fstream>
|
#include "Physics/ECreateParticleSequence.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "Game/EHitPad.h"
|
#include "Game/EHitPad.h"
|
||||||
#include "Game/CProjectile.h"
|
#include "Game/CProjectile.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
|
#include "Rendering/CSprite.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <Box2D/Box2D.h>
|
#include <Box2D/Box2D.h>
|
||||||
|
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public:
|
|||||||
void Update(double dt) override;
|
void Update(double dt) override;
|
||||||
|
|
||||||
private:
|
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_BGMMasterVolume = 1.f;
|
||||||
float m_SFXMasterVolume = 1.f;
|
float m_SFXMasterVolume = 1.f;
|
||||||
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
std::map<ALuint, Sound*> m_BGMSourcesToBuffers;
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ void dd::Renderer::CreateBuffers()
|
|||||||
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
||||||
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
||||||
m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.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);
|
glGenRenderbuffers(1, &m_RbDepthBuffer);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 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);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//Fill water pass
|
//Fill water pass
|
||||||
glGenFramebuffers(1, &m_FbWater);
|
glGenFramebuffers(1, &m_FbWater);
|
||||||
@@ -557,7 +558,9 @@ void dd::Renderer::DrawWater(RenderQueue &rq)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
m_SpWater2->Bind();
|
m_SpWater2->Bind();
|
||||||
//TODO: Add this in water particle component. Blurradius
|
//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)));
|
glUniform2fv(glGetUniformLocation(shaderProgramHandle, "dir"), 1, glm::value_ptr(glm::vec2(1.0f, 0.0f)));
|
||||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "res"), m_Resolution.Width);
|
glUniform1f(glGetUniformLocation(shaderProgramHandle, "res"), m_Resolution.Width);
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
for (int i = 0; i < Lives(); i++) {
|
for (int i = 0; i < Lives(); i++) {
|
||||||
CreateLife(i);
|
CreateLife(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<bool>("Cheat.GodMode", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::Update(double dt)
|
void dd::Systems::BallSystem::Update(double dt)
|
||||||
@@ -445,8 +447,9 @@ void dd::Systems::BallSystem::CreateLife(int number)
|
|||||||
|
|
||||||
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
bool dd::Systems::BallSystem::OnLifeLost(const dd::Events::LifeLost &event)
|
||||||
{
|
{
|
||||||
SetLives(Lives() - 1);
|
if (!m_GodMode){
|
||||||
|
SetLives(Lives() - 1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ void dd::Systems::LevelSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating);
|
EVENT_SUBSCRIBE_MEMBER(m_EBrickGenerating, &LevelSystem::OnBrickGenerating);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &LevelSystem::OnKrakenDefeated);
|
EVENT_SUBSCRIBE_MEMBER(m_EKrakenDefeated, &LevelSystem::OnKrakenDefeated);
|
||||||
|
|
||||||
|
m_GodMode = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue("Cheat.GodMode", false);
|
||||||
|
|
||||||
//PointLightTest
|
//PointLightTest
|
||||||
{
|
{
|
||||||
auto t_Light = m_World->CreateEntity();
|
auto t_Light = m_World->CreateEntity();
|
||||||
@@ -137,8 +139,11 @@ void dd::Systems::LevelSystem::Initialize()
|
|||||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||||
physics->CollisionType = CollisionType::Type::Static;
|
physics->CollisionType = CollisionType::Type::Static;
|
||||||
physics->Category = CollisionLayer::Wall;
|
physics->Category = CollisionLayer::Wall;
|
||||||
physics->Calculate = true;
|
if (m_GodMode) {
|
||||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy | CollisionLayer::Ball);
|
||||||
|
} else {
|
||||||
|
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||||
|
}
|
||||||
m_World->CommitEntity(BottomWall);
|
m_World->CommitEntity(BottomWall);
|
||||||
|
|
||||||
m_World->SetProperty(BottomWall, "Name", "BottomWall");
|
m_World->SetProperty(BottomWall, "Name", "BottomWall");
|
||||||
@@ -291,7 +296,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
} else if (brick->Type == InkBlasterBrick) {
|
} else if (brick->Type == InkBlasterBrick) {
|
||||||
Events::InkBlaster e;
|
Events::InkBlaster e;
|
||||||
e.Shots = 5;
|
e.Shots = 5;
|
||||||
e.Speed = 5;
|
e.Speed = 7;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if(brick->Type == KrakenAttackBrick) {
|
} else if(brick->Type == KrakenAttackBrick) {
|
||||||
Events::KrakenAttack e;
|
Events::KrakenAttack e;
|
||||||
@@ -680,7 +685,7 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr
|
|||||||
Events::InkBlaster e;
|
Events::InkBlaster e;
|
||||||
e.Transform = transformComponentBrick;
|
e.Transform = transformComponentBrick;
|
||||||
e.Shots = 5;
|
e.Shots = 5;
|
||||||
e.Speed = 5;
|
e.Speed = 7;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1019,7 +1024,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
|||||||
1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 0, 1, 2, 1, 0, 1,
|
1, 0, 1, 2, 1, 0, 1,
|
||||||
0, 1, 0, 1, 0, 1, 0,
|
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};
|
0, 0, 0, 0, 0, 0, 0};
|
||||||
color =
|
color =
|
||||||
{w, w, w, w, w, w, w,
|
{w, w, w, w, w, w, w,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -132,9 +132,30 @@ bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
|||||||
|
|
||||||
bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &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);
|
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(event.Lifebuoy);
|
||||||
lifebuoyComponent->Hits -= 1;
|
lifebuoyComponent->Hits -= 1;
|
||||||
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
|
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
|
||||||
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
|||||||
} else if (val == GLFW_KEY_I) {
|
} else if (val == GLFW_KEY_I) {
|
||||||
Events::InkBlaster e;
|
Events::InkBlaster e;
|
||||||
e.Shots = 5;
|
e.Shots = 5;
|
||||||
e.Speed = 5;
|
e.Speed = 7;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_K) {
|
} else if (val == GLFW_KEY_K) {
|
||||||
Events::KrakenAttack e;
|
Events::KrakenAttack e;
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ void dd::Systems::ProjectileSystem::Initialize()
|
|||||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||||
physics->Calculate = true;
|
physics->Calculate = true;
|
||||||
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||||
ctransform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
ctransform->Scale = glm::vec3(0.6f, 0.6f, 0.6f);
|
||||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
// auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||||
cModel->ModelFile = "Models/Test/Ball/Sid.obj";
|
// 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);
|
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
|
||||||
|
|
||||||
m_World->CommitEntity(ent);
|
m_World->CommitEntity(ent);
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-10-08.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "Game/ProjectileSystem.h"
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
//Ink Blast
|
||||||
|
{
|
||||||
|
auto ent = m_World->CreateEntity();
|
||||||
|
m_World->SetProperty(ent, "Name", "Projectile");
|
||||||
|
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||||
|
|
||||||
|
auto circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||||
|
auto inkBlastTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||||
|
circleShape->Radius = 0.1f;
|
||||||
|
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||||
|
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||||
|
physics->Category = CollisionLayer::Type::Projectile;
|
||||||
|
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||||
|
physics->Calculate = true;
|
||||||
|
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||||
|
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);
|
||||||
|
|
||||||
|
m_InkBlastTemplate = ent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::ProjectileSystem::Update(double dt)
|
||||||
|
{
|
||||||
|
if (m_Pause) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
|
{
|
||||||
|
if (IsPaused()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if (templateCheck != nullptr){ return; }
|
||||||
|
|
||||||
|
auto shot = m_World->GetComponent<Components::Projectile>(entity);
|
||||||
|
if (shot != nullptr) {
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
if (transform->Position.y > 8) {
|
||||||
|
m_World->RemoveEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
/*if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
m_Pause = 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||||
|
{
|
||||||
|
m_InkBlaster = true;
|
||||||
|
m_Shots = event.Shots;
|
||||||
|
m_InkBlasterSpeed = event.Speed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||||
|
{
|
||||||
|
if (m_InkBlaster) {
|
||||||
|
m_SquidLoaded = true;
|
||||||
|
m_AttachedSquid = event.Ball;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||||
|
{
|
||||||
|
if (m_InkBlaster && m_SquidLoaded) {
|
||||||
|
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
||||||
|
m_World->RemoveComponent<Components::Template>(ent);
|
||||||
|
auto projectile = m_World->GetComponent<Components::Projectile>(ent);
|
||||||
|
projectile->Speed = m_InkBlasterSpeed;
|
||||||
|
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||||
|
transform->Position = event.Position;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
transform->Velocity = glm::vec3(0, projectile->Speed, 0);
|
||||||
|
=======
|
||||||
|
transform->Velocity = glm::vec3(0, 7, 0);
|
||||||
|
>>>>>>> origin/master
|
||||||
|
m_Shots--;
|
||||||
|
if (m_Shots <= 0) {
|
||||||
|
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||||
|
m_InkBlaster = false;
|
||||||
|
m_SquidLoaded = false;
|
||||||
|
ball->InkBlaster = false;
|
||||||
|
ball->Sticky = false;
|
||||||
|
ball->Waiting = true;
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::InkBlasterOver e;
|
||||||
|
e.Ball = m_AttachedSquid;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::ActionButton e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ void dd::Systems::PhysicsSystem::Initialize()
|
|||||||
|
|
||||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
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;
|
float gravityScale = 1.0f;
|
||||||
|
|
||||||
b2ParticleSystemDef m_ParticleSystemDef;
|
b2ParticleSystemDef m_ParticleSystemDef;
|
||||||
@@ -486,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->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 = glm::vec3(m_WaterParticleSystem->GetRadius())/transform->Scale;
|
||||||
|
transformChild->Scale *= 2;
|
||||||
m_World->CommitEntity(t_waterparticle);
|
m_World->CommitEntity(t_waterparticle);
|
||||||
|
|
||||||
m_EntitiesToWaterParticleHandle.insert(std::make_pair(t_waterparticle, m_WaterParticleSystem->GetParticleHandleFromIndex(i)));
|
m_EntitiesToWaterParticleHandle.insert(std::make_pair(t_waterparticle, m_WaterParticleSystem->GetParticleHandleFromIndex(i)));
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ void dd::Systems::SoundSystem::Initialize()
|
|||||||
|
|
||||||
m_SFXMasterVolume = ResourceManager::Load<ConfigFile>("Config.ini")->GetValue<float>("Audio.SFXVolume", 1.f);
|
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);
|
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)
|
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) {
|
if (item.second->Path() == event.FilePath) {
|
||||||
itemToDeleted = item.first;
|
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.
|
//Should not happen because SFX's should be very short.
|
||||||
for (auto item : m_SFXSourcesToBuffers)
|
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)
|
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;
|
dd::Events::PlaySound e;
|
||||||
e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
e.FilePath = GAME_BGM;
|
||||||
e.IsAmbient = true;
|
e.IsAmbient = true;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dd::Events::PlaySound e;
|
dd::Events::PlaySound e;
|
||||||
e.FilePath = "Sounds/BGM/water-flowing.wav";
|
e.FilePath = WATER_BGM;
|
||||||
e.Gain = 0.3f;
|
e.Gain = 0.3f;
|
||||||
e.IsAmbient = true;
|
e.IsAmbient = true;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user