mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 18:35:54 +00:00
Ammo UI system
This commit is contained in:
parent
70c514f1a9
commit
5eb7b578bc
22 changed files with 238 additions and 87 deletions
|
|
@ -2,6 +2,7 @@ using Godot;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class Hud : CanvasLayer
|
||||
|
|
@ -82,12 +83,33 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
Item = item,
|
||||
Container = hbox,
|
||||
//Amount = currentAmount
|
||||
};
|
||||
|
||||
if (item.UiType == UiItemType.IconText)
|
||||
{
|
||||
var label = new Label();
|
||||
label.Text = currentAmount.ToString();
|
||||
// if (item.Item == ItemTypes.Weapon && item.WeaponData != null)
|
||||
// {
|
||||
// // Show ammo instead of item count
|
||||
// var ammoItem = _items.GetValueOrDefault(item.WeaponData.AmmoKey);
|
||||
//
|
||||
// if (ammoItem != null)
|
||||
// {
|
||||
// label.Text = "0";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// label.Text = ammoItem.
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// label.Text = currentAmount.ToString();
|
||||
// }
|
||||
|
||||
label.LabelSettings = new LabelSettings()
|
||||
{
|
||||
FontSize = 8
|
||||
|
|
@ -116,24 +138,26 @@ public partial class Hud : CanvasLayer
|
|||
// _itemsContainer.AddChild(texture);
|
||||
}
|
||||
|
||||
public void RemoveInventoryItem(LootItem item, int currentAmount)
|
||||
public void RemoveInventoryItem(string itemKey, int currentAmount)
|
||||
{
|
||||
|
||||
if (_items.TryGetValue(item.ItemKey, out var itm))
|
||||
if (_items.TryGetValue(itemKey, out var itm))
|
||||
{
|
||||
if (currentAmount <= 0)
|
||||
{
|
||||
itm.Container.QueueFree();
|
||||
_items.Remove(item.ItemKey);
|
||||
_items.Remove(itemKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
itm.Label.Text = currentAmount.ToString();
|
||||
if (itm.Item.UiType == UiItemType.IconText)
|
||||
{
|
||||
itm.Label.Text = currentAmount.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print($"Tried to remove item {item.ItemName} {item.ItemKey} but it was not found");
|
||||
GD.Print($"Tried to remove item {itemKey} but it was not found");
|
||||
}
|
||||
|
||||
// var containerItem = _items.FirstOrDefault(x => x.Item == item);
|
||||
|
|
@ -152,5 +176,7 @@ public partial class Hud : CanvasLayer
|
|||
public LootItem Item { get; set; }
|
||||
public HBoxContainer Container { get; set; }
|
||||
public Label Label { get; set; }
|
||||
|
||||
//public int Amount { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue