mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
Ability to switch weapons through the menu
This commit is contained in:
parent
12b8d4a70f
commit
ff6d46ebcd
11 changed files with 61 additions and 4 deletions
|
|
@ -11,13 +11,16 @@ public partial class InventoryManager : Node2D
|
|||
|
||||
private Dictionary<string, ItemContainer> _itemsDict = new Dictionary<string, ItemContainer>();
|
||||
|
||||
public Dictionary<string, ItemContainer> Items => _itemsDict;
|
||||
public List<ItemContainer> Items => _itemsDict.Where(x => x.Value.Count > 0).Select(x => x.Value).ToList();
|
||||
|
||||
[Signal]
|
||||
public delegate void ItemAddedEventHandler(LootItem item, int currentAmount);
|
||||
|
||||
[Signal]
|
||||
public delegate void ItemRemovedEventHandler(string itemKey, int currentAmount);
|
||||
|
||||
[Signal]
|
||||
public delegate void WeaponEquipEventHandler(string itemKey);
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
|
|
@ -105,6 +108,37 @@ public partial class InventoryManager : Node2D
|
|||
{
|
||||
RedKeycard = false;
|
||||
}
|
||||
|
||||
public bool UseItem(string itemKey)
|
||||
{
|
||||
if (!_itemsDict.TryGetValue(itemKey, out var itm)) return false;
|
||||
|
||||
if (itm.Count == 0) return false;
|
||||
|
||||
switch (itm.Item.Item)
|
||||
{
|
||||
case ItemTypes.Medkit:
|
||||
// Heal
|
||||
break;
|
||||
case ItemTypes.FrogBomb:
|
||||
// Use Bomb
|
||||
break;
|
||||
case ItemTypes.Bomb:
|
||||
// Bomb
|
||||
break;
|
||||
case ItemTypes.Mine:
|
||||
break;
|
||||
case ItemTypes.Battery:
|
||||
break;
|
||||
case ItemTypes.Weapon:
|
||||
// Equip weapon
|
||||
EmitSignal(SignalName.WeaponEquip, itm.Item.ItemKey);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemContainer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue