summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-11-04 12:54:13 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-11-04 12:54:13 -0300
commit63e4f75e9292e1276cc0b5d11ebad010f147aa68 (patch)
tree4b6c9a1c39b7e2fedb0ba27a8df47631bb2abea9 /scripts
parent5d2f66f1e7f8a9f35456e0f6acc478d1b2ecb294 (diff)
Display de andar
Diffstat (limited to 'scripts')
-rw-r--r--scripts/GUI/Hud.cs23
-rw-r--r--scripts/Map/Map.cs7
-rw-r--r--scripts/Utils/SignalBus.cs3
3 files changed, 26 insertions, 7 deletions
diff --git a/scripts/GUI/Hud.cs b/scripts/GUI/Hud.cs
index a1511b8..60e1e91 100644
--- a/scripts/GUI/Hud.cs
+++ b/scripts/GUI/Hud.cs
@@ -1,5 +1,6 @@
using System.Runtime.InteropServices;
using Godot;
+using TheLegendOfGustav.Utils;
namespace TheLegendOfGustav.GUI;
@@ -7,12 +8,25 @@ 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/HBoxContainer/AspectRatioContainer/HPbar");
- mpBar = GetNode<TextureProgressBar>("VBoxContainer/InfoBar/Stats/MarginContainer/HBoxContainer/AspectRatioContainer2/MPbar");
+ 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)
@@ -26,4 +40,9 @@ public partial class Hud : CanvasLayer
mpBar.Value = mp;
mpBar.MaxValue = maxMp;
}
+
+ public void OnFloorChanged(int floor)
+ {
+ floorLabel.Text = $"Andar: {floor}";
+ }
}
diff --git a/scripts/Map/Map.cs b/scripts/Map/Map.cs
index 2913c1f..104d658 100644
--- a/scripts/Map/Map.cs
+++ b/scripts/Map/Map.cs
@@ -32,9 +32,6 @@ public partial class Map : Node2D
/// </summary>
public MapData MapData { get; private set; }
- [Signal]
- public delegate void DungeonFloorChangedEventHandler(int floor);
-
private SignalBus.PlayerDescentEventHandler joinSignal;
public override void _Ready()
{
@@ -83,7 +80,7 @@ public partial class Map : Node2D
PlaceTiles();
PlaceEntities();
- EmitSignal(SignalName.DungeonFloorChanged, currentFloor);
+ SignalBus.Instance.EmitSignal(SignalBus.SignalName.DungeonFloorChanged, currentFloor);
}
/// <summary>
@@ -142,7 +139,7 @@ public partial class Map : Node2D
PlaceEntities();
MapData.EntityPlaced += OnEntityPlaced;
- EmitSignal(SignalName.DungeonFloorChanged, MapData.CurrentFloor);
+ SignalBus.Instance.EmitSignal(SignalBus.SignalName.DungeonFloorChanged, MapData.CurrentFloor);
return true;
}
diff --git a/scripts/Utils/SignalBus.cs b/scripts/Utils/SignalBus.cs
index a7eccf8..db3e390 100644
--- a/scripts/Utils/SignalBus.cs
+++ b/scripts/Utils/SignalBus.cs
@@ -37,6 +37,9 @@ public partial class SignalBus : Node
[Signal]
public delegate void PlayerDescentEventHandler();
+ [Signal]
+ public delegate void DungeonFloorChangedEventHandler(int floor);
+
public override void _Ready()
{
base._Ready();