AbilityCooldownHUD should now correctly track cooldown for dash ability.

This commit is contained in:
Tleety
2016-03-02 14:46:37 +01:00
parent 502a290d36
commit cdbc348cfa
3 changed files with 44 additions and 5 deletions
@@ -3,7 +3,7 @@
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="AbilityCooldownHUD">
<xs:annotation>
<xs:documentation>HUD element for tracking ability cooldown</xs:documentation>
<xs:documentation>HUD element for tracking ability cooldown. If it has a sprite and fill component it will fill the sprite with chosen color depending on the cooldown.\n A child with text component named "Cooldown"</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
+38 -1
View File
@@ -12,6 +12,7 @@
</Slot>
</c:AssaultWeapon>
<c:Collidable/>
<c:DashAbility/>
<c:DefenderWeapon>
<TimeSinceLastFire>52.867678870419283</TimeSinceLastFire>
</c:DefenderWeapon>
@@ -122,6 +123,7 @@
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
<DepthSort>false</DepthSort>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
@@ -132,7 +134,42 @@
<Orientation X="5.87300014" Y="0" Z="4.71200037"/>
</c:Transform>
</Components>
<Children/>
<Children>
<Entity name="AbilityHUD">
<Components>
<c:AbilityCooldownHUD/>
<c:Fill>
<Color A="1" B="0.392156869" G="0.392156869" R="0.392156869"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
<DepthSort>false</DepthSort>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0.206000015" Y="0.0260000005" Z="0"/>
<Scale X="0.224000007" Y="0.272000015" Z="1"/>
<Orientation X="0" Y="0" Z="1.55100012"/>
</c:Transform>
</Components>
<Children>
<Entity name="Cooldown">
<Components>
<c:Text>
<Content>0.0</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="0" G="0" R="0"/>
</c:Text>
<c:Transform>
<Position X="0" Y="-0.242000014" Z="0"/>
<Scale X="0.363000005" Y="0.810000062" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -17,10 +17,12 @@ void AbilityCooldownHUDSystem::Update(double dt)
if(cooldownTextEntity.Valid()) {
if(cooldownTextEntity.HasComponent("Text"))
{
double abilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(abilityCD).substr(0, 3);
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"] = abilityCD/abilityCD; //TODO: current time needs to be in the component.
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component.
}
}
}