There's now an hp status indicator 'doll' when you click on it your host (character) will tell you how they're doing for HP.
This commit is contained in:
parent
dac9b1b3de
commit
ad1d08ca96
11 changed files with 37 additions and 7 deletions
|
@ -22,7 +22,12 @@
|
|||
"ui_hover": "assets/sounds/ui_hover.ogg",
|
||||
"punch_cartoony": "assets/sounds/punch_cartoony.ogg",
|
||||
"electric_shock_01": "assets/sounds/electric_shock_01.ogg",
|
||||
"fireball_01": "assets/sounds/fireball_01.ogg"
|
||||
"fireball_01": "assets/sounds/fireball_01.ogg",
|
||||
"hp_status_80": "assets/sounds/hp_status_80.ogg",
|
||||
"hp_status_60": "assets/sounds/hp_status_60.ogg",
|
||||
"hp_status_30": "assets/sounds/hp_status_30.ogg",
|
||||
"hp_status_10": "assets/sounds/hp_status_10.ogg",
|
||||
"hp_status_00": "assets/sounds/hp_status_00.ogg"
|
||||
},
|
||||
"sprites": {
|
||||
"gold_savior":
|
||||
|
|
BIN
assets/sounds/hp_status_00.ogg
Normal file
BIN
assets/sounds/hp_status_00.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/hp_status_10.ogg
Normal file
BIN
assets/sounds/hp_status_10.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/hp_status_30.ogg
Normal file
BIN
assets/sounds/hp_status_30.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/hp_status_60.ogg
Normal file
BIN
assets/sounds/hp_status_60.ogg
Normal file
Binary file not shown.
BIN
assets/sounds/hp_status_80.ogg
Normal file
BIN
assets/sounds/hp_status_80.ogg
Normal file
Binary file not shown.
|
@ -12,7 +12,9 @@ namespace gui {
|
|||
{
|
||||
$gui.position(COMBAT_UI_X, COMBAT_UI_Y, COMBAT_UI_WIDTH, COMBAT_UI_HEIGHT);
|
||||
$gui.layout(
|
||||
"[*%(100,150)button_0 | *%(100,150)button_1 | *%(100,150)button_2 | *%(100,150)button_3]");
|
||||
"[button_0 | button_1 | button_2 | button_3"
|
||||
"|button_4 | button_5 | button_6 | hp_gauge ]"
|
||||
);
|
||||
}
|
||||
|
||||
DinkyECS::Entity CombatUI::make_button(std::string name, std::wstring label, Events::GUI event, int action, const std::string &icon_name,
|
||||
|
@ -24,7 +26,7 @@ namespace gui {
|
|||
// $gui.set<Rectangle>(button, {});
|
||||
// $gui.set<Label>(button, {label});
|
||||
$gui.set<Sound>(button, {sound});
|
||||
$gui.set<Effect>(button, {.duration=1.0f, .name=effect_name});
|
||||
$gui.set<Effect>(button, {.duration=0.5f, .name=effect_name});
|
||||
$gui.set<Clickable>(button,
|
||||
guecs::make_action(*$level.world, event, {action}));
|
||||
|
||||
|
@ -41,8 +43,6 @@ namespace gui {
|
|||
std::wstring label = fmt::format(L"Attack {}", slot+1);
|
||||
auto& ritual = the_belt.get(slot);
|
||||
|
||||
|
||||
|
||||
using enum combat::RitualElement;
|
||||
|
||||
switch(ritual.element) {
|
||||
|
@ -52,7 +52,7 @@ namespace gui {
|
|||
break;
|
||||
case LIGHTNING:
|
||||
make_button(name, label, Events::GUI::ATTACK,
|
||||
slot, "stone_doll_cursed-64", "electric_shock_01", "lightning");
|
||||
slot, "pocket_watch-64", "electric_shock_01", "lightning");
|
||||
break;
|
||||
default:
|
||||
make_button(name, label, Events::GUI::ATTACK,
|
||||
|
@ -61,6 +61,11 @@ namespace gui {
|
|||
}
|
||||
}
|
||||
|
||||
auto hp_gauge = $gui.entity("hp_gauge");
|
||||
$gui.set<Sprite>(hp_gauge, {"stone_doll_cursed-64"});
|
||||
$gui.set<Clickable>(hp_gauge,
|
||||
guecs::make_action(*$level.world, Events::GUI::HP_STATUS, {}));
|
||||
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Events {
|
||||
enum GUI {
|
||||
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
|
||||
COMBAT_START, NO_NEIGHBORS,
|
||||
COMBAT_START, NO_NEIGHBORS, HP_STATUS,
|
||||
ATTACK, BLOCK, EVADE, HEAL,
|
||||
UPDATE_SPRITE, ENEMY_SPAWN, NOOP
|
||||
};
|
||||
|
|
|
@ -396,6 +396,9 @@ namespace gui {
|
|||
// std::string(item.data["name"])));
|
||||
$status_ui.log(L"You picked up an item.");
|
||||
} break;
|
||||
case eGUI::HP_STATUS: {
|
||||
System::player_status($level);
|
||||
} break;
|
||||
case eGUI::EVADE:
|
||||
case eGUI::BLOCK:
|
||||
case eGUI::HEAL:
|
||||
|
|
16
systems.cpp
16
systems.cpp
|
@ -408,6 +408,22 @@ std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, int
|
|||
return result;
|
||||
}
|
||||
|
||||
void System::player_status(GameLevel &level) {
|
||||
auto& combat = level.world->get<Combat>(level.player);
|
||||
float percent = float(combat.hp) / float(combat.max_hp);
|
||||
|
||||
if(percent > 0.8) {
|
||||
sound::play("hp_status_80");
|
||||
} else if(percent > 0.6) {
|
||||
sound::play("hp_status_60");
|
||||
} else if(percent > 0.3) {
|
||||
sound::play("hp_status_30");
|
||||
} else if(percent > 0.1) {
|
||||
sound::play("hp_status_10");
|
||||
} else {
|
||||
sound::play("hp_status_00");
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<sf::Shader> System::sprite_effect(GameLevel &level, DinkyECS::Entity entity) {
|
||||
if(level.world->has<SpriteEffect>(entity)) {
|
||||
|
|
|
@ -23,5 +23,6 @@ namespace System {
|
|||
void combat(GameLevel &level, int attack_id);
|
||||
|
||||
std::shared_ptr<sf::Shader> sprite_effect(GameLevel &level, DinkyECS::Entity entity);
|
||||
void player_status(GameLevel &level);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue