mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
84 lines
2 KiB
C#
84 lines
2 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Cirno.Scripts;
|
|
using Cirno.Scripts.Resources;
|
|
|
|
public partial class InventoryManager : Node2D
|
|
{
|
|
public bool RedKeycard { get; set; }
|
|
|
|
private List<LootItem> _items = new List<LootItem>();
|
|
|
|
// Called when the node enters the scene tree for the first time.
|
|
public override void _Ready()
|
|
{
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
}
|
|
|
|
public bool HasItems(List<ItemTypes> items)
|
|
{
|
|
return items.Aggregate(false, (current, item) => current || HasItem(item));
|
|
}
|
|
|
|
public bool HasItem(ItemTypes type)
|
|
{
|
|
return _items.Any(x => x.Item == type && x.Amount > 0);
|
|
}
|
|
|
|
public bool AddItem(ItemTypes type, int amount = 1)
|
|
{
|
|
_items.Add(new LootItem() { Item = type, Amount = amount });
|
|
GD.Print($"Added {type} x{amount}");
|
|
// switch (type)
|
|
// {
|
|
// // case ItemTypes.KeycardRed:
|
|
// // RedKeycard = true;
|
|
// // GD.Print($"Red Keycard x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.KeycardBlue:
|
|
// // GD.Print($"Blue Keycard x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.KeycardGreen:
|
|
// // GD.Print($"Green Keycard x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.Ammo:
|
|
// // GD.Print($"Ammo x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.Medkit:
|
|
// // GD.Print($"Medkit x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.CrabBomb:
|
|
// // GD.Print($"CrabBomb x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.Bomb:
|
|
// // GD.Print($"Bomb x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.Mine:
|
|
// // GD.Print($"Mine x{amount}");
|
|
// // break;
|
|
// // case ItemTypes.Battery:
|
|
// // GD.Print($"Battery x{amount}");
|
|
// // break;
|
|
// // default:
|
|
// // return false;
|
|
// }
|
|
|
|
return true; // TODO: Return false if could not be added
|
|
}
|
|
|
|
public void AddRedKeycard()
|
|
{
|
|
RedKeycard = true;
|
|
}
|
|
|
|
public void RemoveRedKeycard()
|
|
{
|
|
RedKeycard = false;
|
|
}
|
|
}
|