blob: 60e1e91a7e10e3c4a100e3a742df22fd209b282f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System.Runtime.InteropServices;
using Godot;
using TheLegendOfGustav.Utils;
namespace TheLegendOfGustav.GUI;
public partial class Hud : CanvasLayer
{
private TextureProgressBar hpBar;
private TextureProgressBar mpBar;
private Label floorLabel;
public override void _Ready()
{
base._Ready();
hpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer/HPbar");
mpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer/AspectRatioContainer/HPbar");
floorLabel = GetNode<Label>("VBoxContainer/InfoBar/Stats/MarginContainer/VBoxContainer/HBoxContainer2/floorLabel");
SignalBus.Instance.DungeonFloorChanged += OnFloorChanged;
}
public override void _Notification(int what)
{
base._Notification(what);
if (what == NotificationPredelete)
{
SignalBus.Instance.DungeonFloorChanged -= OnFloorChanged;
}
}
public void OnHealthChanged(int hp, int maxHp)
{
hpBar.Value = hp;
hpBar.MaxValue = maxHp;
}
public void OnManaChanged(int mp, int maxMp)
{
mpBar.Value = mp;
mpBar.MaxValue = maxMp;
}
public void OnFloorChanged(int floor)
{
floorLabel.Text = $"Andar: {floor}";
}
}
|