mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
graphics and ammo counting
This commit is contained in:
parent
7548cf7d84
commit
dfe936461e
11 changed files with 45 additions and 35 deletions
|
|
@ -333,7 +333,7 @@ public partial class Hud : CanvasLayer
|
|||
// Clear all items
|
||||
foreach (var hudItem in _items)
|
||||
{
|
||||
hudItem.Value.QueueFree();
|
||||
hudItem.Value.Delete();
|
||||
}
|
||||
_items.Clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -65,9 +65,10 @@ public partial class InventoryManager : Node2D
|
|||
|
||||
itm.Count -= amount;
|
||||
|
||||
if (itm.Count <= 0)
|
||||
if (itm.Count < 0)
|
||||
{
|
||||
_itemsDict.Remove(itemKey);
|
||||
itm.Count = 0;
|
||||
//_itemsDict.Remove(itemKey);
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.ItemRemoved, itemKey, itm.Count);
|
||||
|
|
@ -118,17 +119,7 @@ public partial class InventoryManager : Node2D
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddRedKeycard()
|
||||
{
|
||||
RedKeycard = true;
|
||||
}
|
||||
|
||||
public void RemoveRedKeycard()
|
||||
{
|
||||
RedKeycard = false;
|
||||
}
|
||||
|
||||
|
||||
public bool UseItem(string itemKey)
|
||||
{
|
||||
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return false;
|
||||
|
|
|
|||
|
|
@ -37,13 +37,31 @@ public partial class WeaponAmmoCounter : Container
|
|||
return;
|
||||
}
|
||||
|
||||
if (InventoryManager.Instance.TryGetItem(item.WeaponData.AmmoKey, out var ammoItem))
|
||||
{
|
||||
AmmoIcon.Texture = ammoItem.Item.InventorySprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
AmmoIcon.Hide();
|
||||
}
|
||||
//AmmoIcon.Texture = InventoryManager.Instance.
|
||||
|
||||
UpdateCounter();
|
||||
// Register this only if there's ammo
|
||||
InventoryManager.Instance.TotalAmmoChanged += (ammoKey, count) =>
|
||||
{
|
||||
if (ammoKey != Item.WeaponData.AmmoKey) return;
|
||||
TotalAmmoLabel.Text = count.ToString();
|
||||
};
|
||||
InventoryManager.Instance.TotalAmmoChanged += OnInstanceOnTotalAmmoChanged;
|
||||
}
|
||||
|
||||
private void OnInstanceOnTotalAmmoChanged(StringName ammoKey, int count)
|
||||
{
|
||||
if (ammoKey != Item.WeaponData.AmmoKey) return;
|
||||
TotalAmmoLabel.Text = count.ToString();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
InventoryManager.Instance.TotalAmmoChanged -= OnInstanceOnTotalAmmoChanged;
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
private void UpdateCounter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue