From 047e71a4e15001ca028b6f7ce60ae4da4d26b57d Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 16:18:54 +0100 Subject: [PATCH] Added BoostAssault,BoostDefender components. Added their effects in HealthSystem,PlayerMovementSystem --- resources/Schema/Components.xsd | 2 + resources/Schema/Components/BoostAssault.xml | 16 ++ resources/Schema/Components/BoostAssault.xsd | 18 ++ resources/Schema/Components/BoostDefender.xml | 16 ++ resources/Schema/Components/BoostDefender.xsd | 18 ++ .../Schema/Entities/BoostAssaultTest.xml | 243 ++++++++++++++++++ src/Game/Systems/HealthSystem.cpp | 3 + src/Game/Systems/PlayerMovementSystem.cpp | 9 +- 8 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 resources/Schema/Components/BoostAssault.xml create mode 100644 resources/Schema/Components/BoostAssault.xsd create mode 100644 resources/Schema/Components/BoostDefender.xml create mode 100644 resources/Schema/Components/BoostDefender.xsd create mode 100644 resources/Schema/Entities/BoostAssaultTest.xml diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index ab46b0ea..36060753 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -29,4 +29,6 @@ + + \ No newline at end of file diff --git a/resources/Schema/Components/BoostAssault.xml b/resources/Schema/Components/BoostAssault.xml new file mode 100644 index 00000000..099d3b0c --- /dev/null +++ b/resources/Schema/Components/BoostAssault.xml @@ -0,0 +1,16 @@ + + + + + + 5 + + + 5 + + + + + + + diff --git a/resources/Schema/Components/BoostAssault.xsd b/resources/Schema/Components/BoostAssault.xsd new file mode 100644 index 00000000..f7d348b7 --- /dev/null +++ b/resources/Schema/Components/BoostAssault.xsd @@ -0,0 +1,18 @@ + + + + + + + + This is the assault's class boost component + + + + + This is the strength of the boost effect + + + + + diff --git a/resources/Schema/Components/BoostDefender.xml b/resources/Schema/Components/BoostDefender.xml new file mode 100644 index 00000000..489d30cd --- /dev/null +++ b/resources/Schema/Components/BoostDefender.xml @@ -0,0 +1,16 @@ + + + + + + 10 + + + 5 + + + + + + + diff --git a/resources/Schema/Components/BoostDefender.xsd b/resources/Schema/Components/BoostDefender.xsd new file mode 100644 index 00000000..167b41dd --- /dev/null +++ b/resources/Schema/Components/BoostDefender.xsd @@ -0,0 +1,18 @@ + + + + + + + + This is the defender's class boost component + + + + + This is the strength of the boost effect + + + + + diff --git a/resources/Schema/Entities/BoostAssaultTest.xml b/resources/Schema/Entities/BoostAssaultTest.xml new file mode 100644 index 00000000..97fd3f4d --- /dev/null +++ b/resources/Schema/Entities/BoostAssaultTest.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + Models\MapVersion1.mesh + + + + + + + + + 2 + + + Models/DirectionalLightWidget.mesh + false + + + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 9e118070..3f64d7b9 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -49,6 +49,9 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) { ComponentWrapper cHealth = e.Player["Health"]; double& health = cHealth["Health"]; + if (e.Player.HasComponent("BoostDefender")) { + e.Damage -= (double)e.Player["BoostDefender"]["StrengthOfEffect"]; + } health -= e.Damage; if (health <= 0.0) { diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 72900d7a..bb50942d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -1,6 +1,6 @@ #include "Systems/PlayerMovementSystem.h" -PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) +PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) : System(world, eventBroker) , PureSystem("Player") { @@ -72,6 +72,10 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; accelerationSpeed = glm::min(accelerationSpeed, addSpeed); + //if player has Boost from an Assault class, accelerate the player faster + if (player.HasComponent("BoostAssault")) { + accelerationSpeed *= (double) player["BoostAssault"]["StrengthOfEffect"]; + } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } @@ -79,8 +83,7 @@ void PlayerMovementSystem::Update(double dt) if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { controller->SetDoubleJumping(false); - } - else { + } else { controller->SetDoubleJumping(true); } velocity.y += 4.f;