Merge remote-tracking branch 'origin/master' into water
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#ifndef ConfigFile_h__
|
||||
#define ConfigFile_h__
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class ConfigFile : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
private:
|
||||
ConfigFile(std::string path);
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
T GetValue(std::string key, T defaultValue);
|
||||
template <typename T>
|
||||
void SetValue(std::string key, T value);
|
||||
|
||||
void SaveToDisk();
|
||||
|
||||
private:
|
||||
boost::filesystem::path m_Path;
|
||||
boost::property_tree::ptree m_PTreeDefaults;
|
||||
boost::property_tree::ptree m_PTreeOverrides;
|
||||
boost::property_tree::ptree m_PTreeMerged;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T ConfigFile::GetValue(std::string key, T defaultValue)
|
||||
{
|
||||
return m_PTreeMerged.get<T>(key, defaultValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ConfigFile::SetValue(std::string key, T value)
|
||||
{
|
||||
m_PTreeOverrides.put<T>(key, value);
|
||||
m_PTreeMerged.put<T>(key, value);
|
||||
}
|
||||
|
||||
};
|
||||
#endif // ConfigFile_h__
|
||||
+40
-8
@@ -32,6 +32,7 @@
|
||||
#include "World.h"
|
||||
#include "CTransform.h"
|
||||
#include "CTemplate.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
@@ -67,6 +68,8 @@
|
||||
#include "Physics/CParticle.h"
|
||||
#include "Physics/CParticleEmitter.h"
|
||||
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
|
||||
#include "Game/EGameStart.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
|
||||
@@ -83,18 +86,34 @@ class Engine
|
||||
|
||||
public:
|
||||
Engine(int argc, char* argv[]) {
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(config->GetValue<int>("Debug.LogLevel", 1));
|
||||
|
||||
m_EventBroker = std::make_shared<EventBroker>();
|
||||
|
||||
m_Renderer = std::make_shared<Renderer>();
|
||||
m_Renderer->SetFullscreen(false);
|
||||
//m_Renderer->SetResolution(Rectangle(0, 0, 1920, 1080));
|
||||
m_Renderer->SetResolution(Rectangle(0, 0, 675, 1080));
|
||||
m_Renderer->SetFullscreen(config->GetValue<bool>("Video.Fullscreen", false));
|
||||
m_Renderer->SetResolution(Rectangle(
|
||||
0,
|
||||
0,
|
||||
config->GetValue<int>("Video.Width", 675),
|
||||
config->GetValue<int>("Video.Height", 1080)
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
|
||||
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
||||
m_FrameStack->Width = 675;
|
||||
m_FrameStack->Height = 1080;
|
||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||
|
||||
if (config->GetValue<bool>("Debug.SkipStory", false)) {
|
||||
Events::GameStart e;
|
||||
m_EventBroker->Publish(e);
|
||||
auto hud = new GUI::HUD(m_FrameStack, "HUD");
|
||||
}
|
||||
else {
|
||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||
}
|
||||
|
||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||
|
||||
@@ -156,6 +175,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
m_World->SystemFactory.Register<Systems::AnimationSystem>(
|
||||
[this]() { return new Systems::AnimationSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::AnimationSystem>();
|
||||
m_World->SystemFactory.Register<Systems::TravellingSystem>(
|
||||
[this]() { return new Systems::TravellingSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TravellingSystem>();
|
||||
@@ -448,7 +470,8 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
|
||||
* glm::toMat4(absoluteTransform.Orientation)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color, modelComponent->ModelFile);
|
||||
Components::Animation* animationComponent = m_World->GetComponent<Components::Animation>(entity);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent, animationComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +527,7 @@ public:
|
||||
}
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color, std::string fileName)
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, const Components::Model* modelComponent, const Components::Animation* animationComponent)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
@@ -517,8 +540,17 @@ public:
|
||||
job.ElementBuffer = model->ElementBuffer;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.ModelMatrix = modelMatrix * model->m_Matrix;
|
||||
job.Color = modelComponent->Color;
|
||||
|
||||
if (model->m_Skeleton != nullptr) {
|
||||
job.Skeleton = model->m_Skeleton;
|
||||
if (animationComponent != nullptr) {
|
||||
job.AnimationName = animationComponent->Name;
|
||||
job.AnimationTime = animationComponent->Time;
|
||||
job.NoRootMotion = animationComponent->NoRootMotion;
|
||||
}
|
||||
}
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ public:
|
||||
std::vector<unsigned int> m_Indices;
|
||||
Skeleton* m_Skeleton = nullptr;
|
||||
|
||||
glm::mat4 m_Matrix;
|
||||
|
||||
private:
|
||||
std::vector<glm::ivec2> BoneIndices;
|
||||
std::vector<glm::vec2> BoneWeights;
|
||||
|
||||
@@ -33,6 +33,10 @@ class PNG : public Image
|
||||
public:
|
||||
PNG(std::string path);
|
||||
~PNG();
|
||||
|
||||
private:
|
||||
static void pngErrorFunction(png_structp png_ptr, png_const_charp error_msg);
|
||||
static void pngWarningFunction(png_structp png_ptr, png_const_charp warning_msg);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ struct ModelJob : RenderJob
|
||||
unsigned int StartIndex;
|
||||
unsigned int EndIndex;
|
||||
|
||||
// Animation
|
||||
dd::Skeleton* Skeleton = nullptr;
|
||||
bool NoRootMotion = true;
|
||||
std::string AnimationName;
|
||||
double AnimationTime = 0;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = TextureID;
|
||||
|
||||
@@ -100,16 +100,17 @@ public:
|
||||
|
||||
int GetBoneID(std::string name);
|
||||
|
||||
std::vector<glm::mat4> GetFrameBones(std::string animationName, double time, bool noRootMotion = false);
|
||||
void AccumulateBoneTransforms(bool noRootMotion, Animation::Keyframe ¤tFrame, Animation::Keyframe &nextFrame, float progress, std::map<int, glm::mat4> &boneMatrices, Bone* bone, glm::mat4 parentMatrix);
|
||||
const Animation* GetAnimation(std::string name);
|
||||
std::vector<glm::mat4> GetFrameBones(const Animation& animation, double time, bool noRootMotion = false);
|
||||
void AccumulateBoneTransforms(bool noRootMotion, const Animation::Keyframe& currentFrame, const Animation::Keyframe& nextFrame, float progress, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
|
||||
void PrintSkeleton();
|
||||
void PrintSkeleton(Bone* parent, int depthCount);
|
||||
void PrintSkeleton(const Bone* parent, int depthCount);
|
||||
std::map<std::string, Animation> Animations;
|
||||
|
||||
private:
|
||||
std::map<std::string, Bone*> m_BonesByName;
|
||||
|
||||
int GetKeyframe(Animation& animation, double time);
|
||||
int GetKeyframe(const Animation& animation, double time);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -40,23 +40,19 @@
|
||||
enum _LOG_LEVEL
|
||||
{
|
||||
LOG_LEVEL_ERROR,
|
||||
LOG_LEVEL_WARNING,
|
||||
LOG_LEVEL_INFO,
|
||||
LOG_LEVEL_WARNING,
|
||||
LOG_LEVEL_DEBUG
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
static _LOG_LEVEL LOG_LEVEL = LOG_LEVEL_DEBUG;
|
||||
#else
|
||||
static _LOG_LEVEL LOG_LEVEL = LOG_LEVEL_DEBUG;
|
||||
#endif
|
||||
extern _LOG_LEVEL LOG_LEVEL;
|
||||
|
||||
const static char* _LOG_LEVEL_PREFIX[] =
|
||||
{
|
||||
"E: ",
|
||||
"W: ",
|
||||
"EE: ",
|
||||
"",
|
||||
"D: "
|
||||
"WW: ",
|
||||
"DD: "
|
||||
};
|
||||
|
||||
static void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int line, const char* format, ...)
|
||||
|
||||
+152
-150
@@ -1,151 +1,153 @@
|
||||
#ifndef DAYDREAM_BALLSYSTEM_H
|
||||
#define DAYDREAM_BALLSYSTEM_H
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EStickyAttachedToPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#ifndef DAYDREAM_BALLSYSTEM_H
|
||||
#define DAYDREAM_BALLSYSTEM_H
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EStickyAttachedToPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class BallSystem : public System
|
||||
{
|
||||
public:
|
||||
BallSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~BallSystem();
|
||||
|
||||
|
||||
|
||||
void RegisterComponents(ComponentFactory *cf) override;
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
// Called once per system every tick
|
||||
void Update(double dt) override;
|
||||
|
||||
// Called once for every entity in the world every tick
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
// Called when components are committed to an entity
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
EntityID CreateBall();
|
||||
void CreateLife(int);
|
||||
EntityID Ball() { return m_Ball; };
|
||||
void SetBall(const EntityID& ball) { m_Ball = ball; }
|
||||
|
||||
float& XMovementMultiplier() { return m_XMovementMultiplier; }
|
||||
void SetXMovementMultiplier(const float& xMovementMultiplier) { m_XMovementMultiplier = xMovementMultiplier; }
|
||||
float& EdgeX() { return m_EdgeX; }
|
||||
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
||||
float& EdgeY() { return m_EdgeY; }
|
||||
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
||||
int& MultiBalls() { return m_MultiBalls; }
|
||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||
int& Lives() { return m_Lives; }
|
||||
void SetLives(const int& lives) { m_Lives = lives; }
|
||||
int& PastLives() { return m_PastLives; }
|
||||
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
||||
bool ReplaceBall() const { return m_ReplaceBall; }
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
float m_EdgeX = 3.2f;
|
||||
float m_EdgeY = 5.2f;
|
||||
int m_MultiBalls = 0;
|
||||
int m_Lives = 3;
|
||||
int m_PastLives = 3;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_Pause = false;
|
||||
bool m_Waiting = true;
|
||||
bool m_Sticky = false;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_InkAttached = false;
|
||||
bool m_InkBlockedWaiting = false;
|
||||
bool m_Restarting = false;
|
||||
int m_StickyCounter = 3;
|
||||
|
||||
bool m_StageBlockedWaiting = false;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
|
||||
EntityID m_Ball;
|
||||
|
||||
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
|
||||
void ResolveContacts();
|
||||
|
||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
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::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class BallSystem : public System
|
||||
{
|
||||
public:
|
||||
BallSystem(World *world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
~BallSystem();
|
||||
|
||||
|
||||
|
||||
void RegisterComponents(ComponentFactory *cf) override;
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
// Called once per system every tick
|
||||
void Update(double dt) override;
|
||||
|
||||
// Called once for every entity in the world every tick
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
// Called when components are committed to an entity
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
EntityID CreateBall();
|
||||
void CreateLife(int);
|
||||
EntityID Ball() { return m_Ball; };
|
||||
void SetBall(const EntityID& ball) { m_Ball = ball; }
|
||||
|
||||
float& XMovementMultiplier() { return m_XMovementMultiplier; }
|
||||
void SetXMovementMultiplier(const float& xMovementMultiplier) { m_XMovementMultiplier = xMovementMultiplier; }
|
||||
float& EdgeX() { return m_EdgeX; }
|
||||
void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; }
|
||||
float& EdgeY() { return m_EdgeY; }
|
||||
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
|
||||
int& MultiBalls() { return m_MultiBalls; }
|
||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||
int& Lives() { return m_Lives; }
|
||||
void SetLives(const int& lives) { m_Lives = lives; }
|
||||
int& PastLives() { return m_PastLives; }
|
||||
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
|
||||
bool ReplaceBall() const { return m_ReplaceBall; }
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
float m_EdgeX = 3.2f;
|
||||
float m_EdgeY = 5.2f;
|
||||
int m_MultiBalls = 0;
|
||||
int m_Lives = 3;
|
||||
int m_PastLives = 3;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_Pause = false;
|
||||
bool m_Waiting = true;
|
||||
bool m_Sticky = false;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_InkAttached = false;
|
||||
bool m_InkBlockedWaiting = false;
|
||||
bool m_Restarting = false;
|
||||
int m_StickyCounter = 3;
|
||||
|
||||
bool m_StageBlockedWaiting = false;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
|
||||
EntityID m_Ball;
|
||||
|
||||
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
|
||||
void ResolveContacts();
|
||||
|
||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
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::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
dd::EventRelay<BallSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedToNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+23
-6
@@ -26,8 +26,14 @@ public:
|
||||
Width = parent->Width;
|
||||
Height = parent->Height;
|
||||
|
||||
m_ScoreBackground = new GUI::TextureFrame(this, "HUDScoreBackgroundFrame");
|
||||
m_ScoreBackground->SetTexture("Textures/GUI/Numbers/Background.png");
|
||||
m_ScoreBackMid = new GUI::TextureFrame(this, "HUDScoreBackgroundFrame");
|
||||
m_ScoreBackMid->SetTexture("Textures/GUI/Numbers/ScoreBackgroundMid.png");
|
||||
|
||||
m_ScoreBackLeft = new GUI::TextureFrame(this, "HUDScoreBackgroundLeftFrame");
|
||||
m_ScoreBackLeft->SetTexture("Textures/GUI/Numbers/ScoreBackgroundLeft.png");
|
||||
|
||||
m_ScoreBackRight = new GUI::TextureFrame(this, "HUDScoreBackgroundRightFrame");
|
||||
m_ScoreBackRight->SetTexture("Textures/GUI/Numbers/ScoreBackgroundRight.png");
|
||||
m_ScoreNumberFrame = new GUI::NumberFrame(this, "HUDScoreNumberFrame");
|
||||
//m_ScoreNumberFrame->X = 15;
|
||||
m_ScoreNumberFrame->Y = 18;
|
||||
@@ -52,7 +58,9 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
TextureFrame* m_ScoreBackground = nullptr;
|
||||
TextureFrame* m_ScoreBackMid = nullptr;
|
||||
TextureFrame* m_ScoreBackLeft = nullptr;
|
||||
TextureFrame* m_ScoreBackRight = nullptr;
|
||||
NumberFrame* m_ScoreNumberFrame = nullptr;
|
||||
FPSCounter* m_FPSCounter = nullptr;
|
||||
TextureFrame* m_GameOverFrame = nullptr;
|
||||
@@ -67,9 +75,18 @@ private:
|
||||
void updateScore()
|
||||
{
|
||||
m_ScoreNumberFrame->SetLeft(Width / 2.f - m_ScoreNumberFrame->Width / 2.f);
|
||||
m_ScoreBackground->SetLeft(m_ScoreNumberFrame->Left() - 20);
|
||||
m_ScoreBackground->Width = m_ScoreNumberFrame->Width + 40;
|
||||
m_ScoreBackground->Height = m_ScoreNumberFrame->Height + 30;
|
||||
|
||||
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left());
|
||||
m_ScoreBackMid->Width = m_ScoreNumberFrame->Width;
|
||||
m_ScoreBackMid->Height = m_ScoreNumberFrame->Height + 35;
|
||||
|
||||
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
|
||||
m_ScoreBackLeft->Width = 40;
|
||||
m_ScoreBackLeft->Height = m_ScoreBackMid->Height;
|
||||
|
||||
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
|
||||
m_ScoreBackRight->Width = 40;
|
||||
m_ScoreBackRight->Height = m_ScoreBackMid->Height;
|
||||
}
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GUI/Slider.h"
|
||||
#include "GUI/ESliderUpdate.h"
|
||||
#include "Sound/EMasterVolume.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -33,7 +34,6 @@ public:
|
||||
m_SFXSlider->SetTexture("Textures/GUI/Menu/SliderBackground.png");
|
||||
m_SFXSlider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png");
|
||||
m_SFXSlider->AlignVertically();
|
||||
m_SFXSlider->SetPercentage(1.f);
|
||||
|
||||
m_TitleBGM = new GUI::TextureFrame(this, "MainMenuOptionsBGMTitle");
|
||||
m_TitleBGM->SetTop(m_SFXSlider->Bottom() + 20);
|
||||
@@ -44,9 +44,12 @@ public:
|
||||
m_BGMSlider->SetTexture("Textures/GUI/Menu/SliderBackground.png");
|
||||
m_BGMSlider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png");
|
||||
m_BGMSlider->AlignVertically();
|
||||
m_BGMSlider->SetPercentage(1.f);
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESliderUpdate, &MainMenuOptions::OnSliderUpdate);
|
||||
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
m_SFXSlider->SetPercentage(config->GetValue<float>("Audio.SFXVolume", 1.f));
|
||||
m_BGMSlider->SetPercentage(config->GetValue<float>("Audio.BGMVolume", 1.f));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -73,6 +76,11 @@ private:
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
config->SetValue("Audio.SFXVolume", m_SFXSlider->Percentage());
|
||||
config->SetValue("Audio.BGMVolume", m_BGMSlider->Percentage());
|
||||
config->SaveToDisk();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,9 +57,6 @@ namespace dd
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
@@ -117,6 +114,8 @@ namespace dd
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
//TODO: Fill struct with info needed.
|
||||
struct EmitterHandler //TODO CHANGE NAMES
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef AnimationSystem_h__
|
||||
#define AnimationSystem_h__
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
#include "Game/EPause.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class AnimationSystem : public System
|
||||
{
|
||||
public:
|
||||
AnimationSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) { }
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
|
||||
private:
|
||||
bool m_Paused = false;
|
||||
|
||||
EventRelay<AnimationSystem, Events::Pause> m_EPause;
|
||||
bool OnPause(const Events::Pause& e);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef COMPONENTS_CANIMATION_H__
|
||||
#define COMPONENTS_CANIMATION_H__
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Animation : Component
|
||||
{
|
||||
std::string Name;
|
||||
double Time = 0.0;
|
||||
double Speed = 0.0;
|
||||
bool NoRootMotion = true;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
#include "Sound/EStopSound.h"
|
||||
|
||||
Reference in New Issue
Block a user