Merge remote-tracking branch 'origin/master' into water
Conflicts: src/game/Game/LevelSystem.cpp
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Bricks.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture.png
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 122 B |
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Bricks.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd StickyTexture.png
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 122 B |
@@ -44,10 +44,12 @@
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
@@ -113,6 +115,7 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||
m_World->ComponentFactory.Register<Components::Projectile>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
@@ -132,6 +135,9 @@ public:
|
||||
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::ProjectileSystem>(
|
||||
[this]() { return new Systems::ProjectileSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::ProjectileSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitPad.h"
|
||||
@@ -94,8 +95,8 @@ private:
|
||||
bool m_Pause = false;
|
||||
bool m_Waiting = true;
|
||||
bool m_Sticky = false;
|
||||
bool m_InkBlaster = false;
|
||||
int m_StickyCounter = 5;
|
||||
EntityID m_LastCollision = 999999;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
@@ -110,6 +111,7 @@ private:
|
||||
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::Pause> m_EPause;
|
||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
@@ -120,6 +122,7 @@ private:
|
||||
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 OnPause(const dd::Events::Pause &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@ struct Ball : Component
|
||||
int Combo = 0;
|
||||
bool Paused = false;
|
||||
bool Waiting = true;
|
||||
bool InkBlaster = false;
|
||||
bool Sticky = false;
|
||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CPROJECTILE_H
|
||||
#define DAYDREAM_CPROJECTILE_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Projectile : Component
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CPROJECTILE_H
|
||||
@@ -15,7 +15,7 @@ namespace Events
|
||||
|
||||
struct ActionButton : Event
|
||||
{
|
||||
|
||||
glm::vec3 Position;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define DAYDREAM_EHITPAD_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -13,7 +14,8 @@ namespace Events
|
||||
{
|
||||
struct HitPad : Event
|
||||
{
|
||||
|
||||
EntityID Pad;
|
||||
EntityID Ball;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EINKBLASTER_H
|
||||
#define DAYDREAM_EINKBLASTER_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct InkBlaster : Event
|
||||
{
|
||||
Components::Transform* Transform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EINKBLASTER_H
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-17.
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ELIFEBUOY_H
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
@@ -129,6 +131,7 @@ private:
|
||||
const int MultiBallBrick = 2;
|
||||
const int LifebuoyBrick = 3;
|
||||
const int StickyBrick = 4;
|
||||
const int InkBlasterBrick = 5;
|
||||
|
||||
EntityID m_BrickTemplate;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||
|
||||
struct LifeBuoyInfo
|
||||
struct LifebuoyInfo
|
||||
{
|
||||
EntityID Entity;
|
||||
float TimeToLive = 15.f;
|
||||
@@ -61,7 +61,8 @@ private:
|
||||
|
||||
float m_LeftEdge = -3.8f;
|
||||
float m_RightEdge = 3.8f;
|
||||
std::list<LifeBuoyInfo> m_LifeBuoys;
|
||||
float m_DownEdge = -9.2f;
|
||||
std::list<LifebuoyInfo> m_Lifebuoys;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-09.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_PROJECTILESYSTEM_H
|
||||
#define DAYDREAM_PROJECTILESYSTEM_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/CCircleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBall.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class ProjectileSystem : public System
|
||||
{
|
||||
public:
|
||||
ProjectileSystem(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;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_SquidLoaded = false;
|
||||
int m_Shots = 0;
|
||||
EntityID m_InkBlastTemplate;
|
||||
EntityID m_AttachedSquid;
|
||||
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||
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 OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_PROJECTILESYSTEM_H
|
||||
@@ -16,7 +16,8 @@ enum Type
|
||||
PowerUp = 1 << 4,
|
||||
Other = 1 << 5,
|
||||
Wall = 1 << 6,
|
||||
LifeBuoy = 1 << 7
|
||||
LifeBuoy = 1 << 7,
|
||||
Projectile = 1 << 8
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||
|
||||
@@ -44,9 +45,6 @@ void dd::Systems::BallSystem::Initialize()
|
||||
physics->Calculate = true;
|
||||
transform->Sticky = true;
|
||||
|
||||
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
//plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
SetBall(ent);
|
||||
@@ -114,7 +112,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (m_Waiting == false) {
|
||||
ballComponent->Waiting = false;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::normalize(glm::vec3(-0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||
if (ballComponent->Sticky) {
|
||||
transform->Velocity = ballComponent->SavedSpeed;
|
||||
m_StickyCounter--;
|
||||
@@ -260,6 +258,8 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
|
||||
Events::HitPad e;
|
||||
e.Ball = ballEntity;
|
||||
e.Pad = otherEntitiy;
|
||||
EventBroker->Publish(e);
|
||||
// Events::HitLag el;
|
||||
// el.Time = 0.1f;
|
||||
@@ -272,12 +272,17 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
|
||||
ballComponent->Combo = 0;
|
||||
|
||||
if (m_Sticky) {
|
||||
if (m_InkBlaster) {
|
||||
m_InkBlaster = false;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
} else if (m_Sticky) {
|
||||
m_Sticky = false;
|
||||
m_Waiting = true;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->Waiting = true;
|
||||
ballComponent->StickyPlacement = padTransform->Position - ballTransform->Position;
|
||||
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity *= -1;
|
||||
return true;
|
||||
@@ -304,13 +309,6 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
normalList.push_back(event.Normal);
|
||||
m_Contacts[ballEntity] = normalList;
|
||||
}
|
||||
|
||||
auto brick = m_World->GetComponent<Components::Brick>(otherEntitiy);
|
||||
if (brick != nullptr) {
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(otherEntitiy);
|
||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -427,6 +425,12 @@ bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||
{
|
||||
m_InkBlaster = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
m_Waiting = false;
|
||||
|
||||
@@ -30,7 +30,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
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::Wall | CollisionLayer::LifeBuoy);
|
||||
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";
|
||||
@@ -90,6 +90,9 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
} else if (brick->Type == StickyBrick) {
|
||||
Events::StickyPad e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (brick->Type == InkBlasterBrick) {
|
||||
Events::InkBlaster e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
m_LooseBricks--;
|
||||
m_World->RemoveEntity(entity);
|
||||
@@ -198,11 +201,15 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
} else if (typeInt == LifebuoyBrick) {
|
||||
cBrick->Type = LifebuoyBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->Color = glm::vec4(1.f, 0.f, 0.f, 1.f);
|
||||
model->ModelFile = "Models/Brick/LifeBuoyBrick.obj";
|
||||
} else if (typeInt == StickyBrick) {
|
||||
cBrick->Type = StickyBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->Color = glm::vec4(0.f, 0.f, 1.f, 1.f);
|
||||
model->ModelFile = "Models/Brick/StickyBrick.obj";
|
||||
} else if (typeInt == InkBlasterBrick) {
|
||||
cBrick->Type = InkBlasterBrick;
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, .0f);
|
||||
}
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
@@ -218,8 +225,10 @@ void dd::Systems::LevelSystem::OnEntityRemoved(EntityID entity)
|
||||
|
||||
bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
LOG_DEBUG("Collision happened!");
|
||||
EntityID entityBrick;
|
||||
EntityID entityBall;
|
||||
EntityID entityShot = 0;
|
||||
auto ball = m_World->GetComponent<Components::Ball>(event.Entity2);
|
||||
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
|
||||
if (brick != nullptr) {
|
||||
@@ -239,7 +248,19 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
if (ball != nullptr) {
|
||||
entityBall = event.Entity1;
|
||||
} else {
|
||||
return false;
|
||||
auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
|
||||
if (shot != nullptr) {
|
||||
LOG_DEBUG("Entity1 is a shot!");
|
||||
entityShot = event.Entity1;
|
||||
} else {
|
||||
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
|
||||
if (shot != nullptr) {
|
||||
LOG_DEBUG("Entity2 is a shot!");
|
||||
entityShot = event.Entity2;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,13 +269,37 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*auto power = m_World->GetComponent<Components::PowerUpBrick>(entityBrick);
|
||||
if (power != nullptr && NumberOfBricks() > 1) {
|
||||
Events::CreatePowerUp e;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
e.Position = transform->Position;
|
||||
EventBroker->Publish(e);
|
||||
}*/
|
||||
if (entityShot != 0) {
|
||||
// For when a brick gets shot.
|
||||
brick->Removed = true;
|
||||
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
physicsComponent->GravityScale = 1.f;
|
||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||
|
||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
auto transformComponentShot = m_World->GetComponent<Components::Transform>(entityShot);
|
||||
|
||||
Events::SetImpulse e;
|
||||
e.Entity = entityBrick;
|
||||
|
||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentShot->Position.x - transformComponentBrick->Position.x) / 4),
|
||||
transformComponentBrick->Position.y + ((transformComponentShot->Position.y - transformComponentBrick->Position.y) / 4));
|
||||
|
||||
e.Impulse = glm::normalize(point)*5.f;
|
||||
e.Point = point;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
Events::ScoreEvent es;
|
||||
es.Score = brick->Score;
|
||||
EventBroker->Publish(es);
|
||||
|
||||
m_World->RemoveEntity(entityShot);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Restarting() && !brick->Removed) {
|
||||
brick->Removed = true;
|
||||
@@ -268,6 +313,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
||||
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
physicsComponent->GravityScale = 1.f;
|
||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||
|
||||
@@ -303,7 +349,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
ep.Position = transformComponentBrick->Position;
|
||||
ep.Radius = 0.05;
|
||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||
ep.Color = brickModel->Color + glm::vec4(1);
|
||||
ep.Color = brickModel->Color + glm::vec4(1);
|
||||
ep.Speed = 50;
|
||||
EventBroker->Publish(ep);
|
||||
|
||||
@@ -397,6 +443,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
// 2 is multiball brick.
|
||||
// 3 is lifebuoy brick.
|
||||
// 4 is sticky brick.
|
||||
// 5 is ink blaster brick.
|
||||
if (m_CurrentCluster == 0) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
@@ -447,7 +494,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,
|
||||
4, 0, 0, 3, 0, 0, 1};
|
||||
4, 0, 0, 3, 0, 0, 5};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 1,
|
||||
|
||||
@@ -43,20 +43,27 @@ void dd::Systems::LifebuoySystem::Initialize()
|
||||
|
||||
void dd::Systems::LifebuoySystem::Update(double dt)
|
||||
{
|
||||
for (auto it = m_LifeBuoys.begin(); it != m_LifeBuoys.end();) {
|
||||
for (auto it = m_Lifebuoys.begin(); it != m_Lifebuoys.end();) {
|
||||
it->TimeToLive -= dt;
|
||||
if (it->TimeToLive < 0.f) {
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(it->Entity);
|
||||
|
||||
if (transformComponent->Position.y < m_DownEdge) {
|
||||
m_World->RemoveEntity(it->Entity);
|
||||
m_LifeBuoys.erase(it++);
|
||||
m_Lifebuoys.erase(it++);
|
||||
}
|
||||
else {
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(it->Entity);
|
||||
|
||||
|
||||
if (transformComponent->Position.x > m_RightEdge) {
|
||||
transformComponent->Position = glm::vec3(m_LeftEdge + 0.1f, transformComponent->Position.y, transformComponent->Position.z);
|
||||
}
|
||||
else if (transformComponent->Position.x < m_LeftEdge) {
|
||||
} else if (transformComponent->Position.x < m_LeftEdge) {
|
||||
transformComponent->Position = glm::vec3(m_RightEdge - 0.1f, transformComponent->Position.y, transformComponent->Position.z);
|
||||
} else if (it->TimeToLive < 0.f) {
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(it->Entity);
|
||||
physicsComponent->Mask = CollisionLayer::Type::LifeBuoy;
|
||||
physicsComponent->GravityScale = 10.f;
|
||||
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(it->Entity);
|
||||
modelComponent->Color = glm::vec4(0.5f, 0.5f, 0.5f, 0.f);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
@@ -101,11 +108,11 @@ bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||
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 + 2.f, -10.f);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
transform->Velocity = glm::vec3(20.f, 3.f, 0.f);
|
||||
LifeBuoyInfo info;
|
||||
LifebuoyInfo info;
|
||||
info.Entity = ent;
|
||||
m_LifeBuoys.push_back(info);
|
||||
m_Lifebuoys.push_back(info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,8 +63,7 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
if (ball->Sticky) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Position = Transform()->Position;
|
||||
transform->Position -= ball->StickyPlacement;
|
||||
transform->Orientation = glm::quat();
|
||||
transform->Position += ball->StickyPlacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,6 +169,7 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_SPACE) {
|
||||
Events::ActionButton e;
|
||||
e.Position = Transform()->Position;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_D) {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// 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_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->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";
|
||||
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_InkBlastTemplate = ent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
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 = 5;
|
||||
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 transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
transform->Velocity = glm::vec3(0, 5, 0);
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user