mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 11:35:53 +00:00
Health and shield gauges
This commit is contained in:
parent
9e04056800
commit
3682de18d5
14 changed files with 188 additions and 22 deletions
|
|
@ -19,7 +19,14 @@ public partial class Hud : CanvasLayer
|
|||
private Node2D _selector;
|
||||
|
||||
[Export] private Label _healthLabel;
|
||||
[Export] private ProgressBar _healthBar;
|
||||
|
||||
[Export] private Label _shieldLabel;
|
||||
[Export] private ProgressBar _shieldBar;
|
||||
|
||||
[Export] private Container _itemsContainer;
|
||||
|
||||
[Export] private LabelSettings _labelSettings;
|
||||
|
||||
private Dictionary<string, HudItem> _items = new();
|
||||
|
||||
|
|
@ -56,6 +63,19 @@ public partial class Hud : CanvasLayer
|
|||
public void UpdateHealth(float newHealth, float maxHealth)
|
||||
{
|
||||
_healthLabel.Text = $"{newHealth}/{maxHealth}";
|
||||
if (_healthBar != null)
|
||||
{
|
||||
_healthBar.Value = newHealth;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateShield(float newValue, float maxValue)
|
||||
{
|
||||
_shieldLabel.Text = $"{newValue}/{maxValue}";
|
||||
if (_shieldBar != null)
|
||||
{
|
||||
_shieldBar.Value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInteractable(Interactable interactable) {
|
||||
|
|
@ -109,11 +129,8 @@ public partial class Hud : CanvasLayer
|
|||
// {
|
||||
// label.Text = currentAmount.ToString();
|
||||
// }
|
||||
|
||||
label.LabelSettings = new LabelSettings()
|
||||
{
|
||||
FontSize = 8
|
||||
};
|
||||
|
||||
label.LabelSettings = _labelSettings;
|
||||
hbox.AddChild(label);
|
||||
|
||||
hudItem.Label = label;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue