From 050ce57e24a09aa8e87b4a40604d08d9b0f7e4f0 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 00:32:07 +0100 Subject: [PATCH] Fixed AbilityUI for player and changed so the AbilityCooldown system wont need a child with text, instead just write if it has one. --- resources/Schema/Entities/Player.xml | 105 ++++++++++++------ src/Game/Systems/AbilityCooldownHUDSystem.cpp | 14 ++- 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 34692605..c93989d8 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -12,6 +12,9 @@ + + 3 + 52.867678870419283 @@ -70,8 +73,8 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png - false + false @@ -94,42 +97,22 @@ - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - 1 + Textures/HealthHUD3.png - - + @@ -146,8 +129,8 @@ Textures/Core/White.png - false + false @@ -164,8 +147,8 @@ Textures/Core/White.png - false + false @@ -182,8 +165,8 @@ Textures/Core/White.png - false + false @@ -195,8 +178,62 @@ + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + @@ -233,8 +270,8 @@ - + @@ -267,8 +304,8 @@ - + @@ -302,8 +339,8 @@ - + @@ -336,8 +373,8 @@ - + @@ -369,8 +406,8 @@ - + @@ -446,8 +483,8 @@ + - @@ -605,8 +642,8 @@ - + @@ -615,8 +652,8 @@ Textures/Icons/Arrow.png - false + false diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index 44180a62..7226019f 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -14,17 +14,19 @@ void AbilityCooldownHUDSystem::Update(double dt) if (!abilityEntity.Valid()) return; EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown"); + + double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; + double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; + if(cooldownTextEntity.Valid()) { if(cooldownTextEntity.HasComponent("Text")) { - double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; - double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; - currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); - if(entity.HasComponent("Fill")) { - entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component. - } } } + if (entity.HasComponent("Fill")) { + currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; + entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; + } } }