ShiftIcon should now track ability depending on what ability the player has and change icon accordingly.

This commit is contained in:
Tleety
2016-03-07 13:55:37 +01:00
parent 388fe7c259
commit 99d663d5a2
2 changed files with 41 additions and 8 deletions
@@ -12,6 +12,7 @@ public:
{ }
virtual void Update(double dt) override;
private:
};
#endif
+40 -8
View File
@@ -11,21 +11,53 @@ void AbilityCooldownHUDSystem::Update(double dt)
for (auto& abilityHUDC : *abilityHUDs) {
EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID);
EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility");
if (!abilityEntity.Valid())
return;
std::string abilityName = "";
if (!abilityEntity.Valid()) {
//If we dont have a dash ability on player, we check for Sprint ability
abilityEntity = entity.FirstParentWithComponent("SprintAbility");
if (!abilityEntity.Valid()) {
//If we dont have a sprint ability on player, we check for shield ability
abilityEntity = entity.FirstParentWithComponent("ShieldAbility");
if (!abilityEntity.Valid()) {
//If we dont have a shield ability, we return, since we cannot do anything.
return;
} else {
//If we have a shield ability, we set the right icon
abilityName = "ShieldAbility";
if (entity.HasComponent("Sprite")) {
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\SheildDots-01.png";
}
}
} else {
//If we do have a sprint ability, we change the icon
abilityName = "SprintAbility";
if (entity.HasComponent("Sprite")) {
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\Dash-01.png";
}
}
} else {
//If we have a dash ability, we set the icon to the correct one.
abilityName = "DashAbility";
if (entity.HasComponent("Sprite")) {
(std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\Superman-01.png";
}
}
EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown");
double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"];
double maxAbilityCD = (double)abilityEntity[abilityName]["CoolDownMaxTimer"];
double currentAbilityCD = (double)abilityEntity[abilityName]["CoolDownTimer"];
currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0;
if(cooldownTextEntity.Valid()) {
if(cooldownTextEntity.HasComponent("Text"))
{
if (cooldownTextEntity.Valid()) {
if (cooldownTextEntity.HasComponent("Text")) {
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3);
}
}
if (entity.HasComponent("Fill")) {
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD;
}