mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 15:25:54 +00:00
Item Notifications
This commit is contained in:
parent
fc35baeaba
commit
0438ed4a04
8 changed files with 98 additions and 25 deletions
40
Scripts/UI/ItemNotification.cs
Normal file
40
Scripts/UI/ItemNotification.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.UI;
|
||||
|
||||
public partial class ItemNotification : Container
|
||||
{
|
||||
public LootItem Item { get; private set; }
|
||||
[Export]
|
||||
public TextureRect Icon { get; private set; }
|
||||
[Export]
|
||||
public Label DescriptionLabel { get; private set; }
|
||||
|
||||
private double _counter = 0;
|
||||
private double _timeout = 0;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_counter += delta;
|
||||
if (_counter >= _timeout)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public void Init(LootItem item, int total, float timeout)
|
||||
{
|
||||
_timeout = timeout;
|
||||
_counter = 0;
|
||||
Item = item;
|
||||
|
||||
UpdateCounter(item, total);
|
||||
}
|
||||
|
||||
private void UpdateCounter(LootItem item, int total)
|
||||
{
|
||||
DescriptionLabel.Text = $"{item.ItemName} +{item.Amount} ({total})";
|
||||
Icon.Texture = item.InventorySprite;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue