From b81bb9eeead495e600517d9ec5b54d806512a398 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 15:17:19 +0100 Subject: [PATCH] Changed SprintAbility to take StrengthOfEffect. PlayerMovementSystem: if Sniper is sprinting he will now move faster. --- include/Engine/Input/FirstPersonInputController.h | 9 +++++++++ resources/Schema/Components/SprintAbility.xml | 2 +- resources/Schema/Components/SprintAbility.xsd | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 12 +++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 7dc24a2c..21833864 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -28,6 +28,7 @@ public: virtual void Reset(); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); + bool SniperSprintingCheck(); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -241,4 +242,12 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_EventBroker->Publish(e); } +template +bool FirstPersonInputController::SniperSprintingCheck() { + if (m_SpecialAbilityKeyDown) { + return true; + } else { + return false; + } +} #endif \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml index 2aac99d6..5cc59a3a 100644 --- a/resources/Schema/Components/SprintAbility.xml +++ b/resources/Schema/Components/SprintAbility.xml @@ -1,4 +1,4 @@ - 2.0 + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd index 4207dee2..9eabb450 100644 --- a/resources/Schema/Components/SprintAbility.xsd +++ b/resources/Schema/Components/SprintAbility.xsd @@ -9,8 +9,8 @@ - - This is the cooldown on sprint + + This is the strength of the sprint effect diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index cb28c7e6..ee2f9ca3 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -58,7 +58,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt) playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } - + bool sniperSprinting = false; + if (player.HasComponent("SprintAbility")) { + if (controller->SniperSprintingCheck()) { + playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + sniperSprinting = true; + } + } if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; @@ -114,6 +121,9 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (playerBoostAssaultEntity.Valid()) { accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } + if (sniperSprinting) { + accelerationSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); }