Skip to content

Commit

Permalink
Update HUD for player death
Browse files Browse the repository at this point in the history
  • Loading branch information
justindriggers committed Dec 27, 2023
1 parent 4cc9020 commit 0ad0e45
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions linguine/src/systems/HudSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "components/Ability.h"
#include "components/AbilityLabel.h"
#include "components/GameOver.h"
#include "components/HealthBar.h"
#include "components/HudDetails.h"
#include "components/Party.h"
Expand Down Expand Up @@ -79,21 +80,34 @@ void HudSystem::update(float deltaTime) {

findEntities<Text, AbilityLabel>()->each([this](const Entity& entity) {
auto text = entity.get<Text>();

auto isGameOver = false;

findEntities<Player>()->each([&isGameOver](const Entity& playerEntity) {
isGameOver = playerEntity.has<GameOver>();
});

auto abilityLabel = entity.get<AbilityLabel>();
auto abilityEntity = getEntityById(abilityLabel->abilityId);
auto ability = abilityEntity->get<Ability>();
auto progressable = abilityEntity->get<Progressable>();

if (ability->remainingCooldown > 0.0f) {
text->feature->text = "Recharging";
if (isGameOver) {
text->feature->text = "Signal Lost...";
progressable->feature->color = { 1.0f, 0.0f, 0.0f };
} else {
text->feature->text = "Ready";
}
auto ability = abilityEntity->get<Ability>();

auto progress = 1.0f - ability->remainingCooldown / ability->spell.cooldown;
auto progressable = abilityEntity->get<Progressable>();
auto red = 1.0f - (progress > 0.5 ? (progress - 0.5f) * 2.0f : 0.0f);
auto green = 0.0f + (progress < 0.5 ? progress * 2.0f : 1.0f);
progressable->feature->color = { red, green, 0.0f };
if (ability->remainingCooldown > 0.0f) {
text->feature->text = "Recharging";
} else {
text->feature->text = "Ready";
}

auto progress = 1.0f - ability->remainingCooldown / ability->spell.cooldown;
auto red = 1.0f - (progress > 0.5 ? (progress - 0.5f) * 2.0f : 0.0f);
auto green = 0.0f + (progress < 0.5 ? progress * 2.0f : 1.0f);
progressable->feature->color = { red, green, 0.0f };
}
});
}

Expand Down

0 comments on commit 0ad0e45

Please sign in to comment.