Lifebuoy added. Incomplete, but it appears.
This commit is contained in:
@@ -43,9 +43,11 @@
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
@@ -110,6 +112,7 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
@@ -126,6 +129,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::HitLagSystem>(
|
||||
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::HitLagSystem>();
|
||||
m_World->SystemFactory.Register<Systems::LifebuoySystem>(
|
||||
[this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LifebuoySystem>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CLIFEBUOY_H
|
||||
#define DAYDREAM_CLIFEBUOY_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Lifebuoy : Component
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CLIFEBUOY_H
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-09.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class LifebuoySystem : public System
|
||||
{
|
||||
public:
|
||||
LifebuoySystem(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;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
bool m_Pause = false;
|
||||
EntityID m_Template;
|
||||
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Lifebuoy> m_ELifebuoy;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
@@ -59,7 +59,7 @@ void dd::Renderer::Initialize()
|
||||
}
|
||||
|
||||
// Create default camera
|
||||
m_DefaultCamera = std::unique_ptr<dd::Camera>(new dd::Camera((float)m_Resolution.Width / m_Resolution.Height, /*45.f*/ 45.f, 0.01f, 5000.f));
|
||||
m_DefaultCamera = std::unique_ptr<dd::Camera>(new dd::Camera((float)m_Resolution.Width / m_Resolution.Height, /*45.f*/ 46.f, 0.01f, 5000.f));
|
||||
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 0));
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
|
||||
@@ -420,7 +420,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 2, 1, 2, 1,
|
||||
1, 1, 0, 1, 0, 1, 1,
|
||||
1, 0, 0, 1, 0, 0, 1};
|
||||
1, 0, 0, 3, 0, 0, 1};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 1,
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
|
||||
|
||||
void dd::Systems::LifebuoySystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &LifebuoySystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LifebuoySystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifebuoy, &LifebuoySystem::OnLifebuoy);
|
||||
|
||||
//Lifebuoy
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Lifebuoy");
|
||||
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(50.f, -4.8f, -10.f);
|
||||
auto rectangleShape = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto lifebuoyTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
rectangleShape->Dimensions = glm::vec2(1.f, 0.1f);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Type::Other;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Pad | CollisionLayer::Wall | CollisionLayer::Water);
|
||||
physics->Density = 0.001;
|
||||
physics->GravityScale = 1;
|
||||
ctransform->Sticky = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Ship/Ship.obj";
|
||||
auto lifebuoy = m_World->AddComponent<Components::Lifebuoy>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_Template = ent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::LifebuoySystem::Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "LifebuoySystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||
{
|
||||
auto ent = m_World->CloneEntity(m_Template);
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
auto physics = m_World->GetComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
transform->Position = glm::vec3(event.Transform->Position.x, transform->Position.y, -10.f);
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user