Item Notifications

This commit is contained in:
Marco 2025-03-06 15:03:14 +01:00
commit 0438ed4a04
8 changed files with 98 additions and 25 deletions

View file

@ -19,7 +19,12 @@ public partial class Hud : CanvasLayer
[Export]
public PackedScene WeaponContainerTemplate { get; private set; }
[Export]
public PackedScene ItemNotificationTemplate { get; private set; }
[Export] public float ItemsNotificationTimeout { get; private set; } = 3f;
[Export]
private Node2D _selector;
@ -60,8 +65,19 @@ public partial class Hud : CanvasLayer
// Assuming the HUD has a Label node named "HealthLabel"
//_healthLabel = GetNode<Label>("HealthLabel");
_gameOverPanel.Hide();
InventoryManager.Instance.ItemAdded += OnItemAdded;
}
private void OnItemAdded(LootItem item, int currentamount)
{
var instance = ItemNotificationTemplate.Instantiate<ItemNotification>();
_itemsContainer.CallDeferred("add_child", instance);
instance.Init(item, currentamount, ItemsNotificationTimeout);
}
public void ShowMessage(string text)
{
var message = GetNode<Label>("Message");