static public bool InventoryHasItem(ItemsUniqueID uniqueID, out Item item) { Vector2Int indexOfRessource = new Vector2Int(-1, -1); for (int i = 0; i < inventoryWidth; i++) { indexOfRessource.y = Inventory[i].FindIndex(x => x.UniqueID == uniqueID); if (indexOfRessource.y != -1) { indexOfRessource.x = i; i = inventoryWidth; } } if (indexOfRessource.x == -1 && indexOfRessource.y == -1) { item = null; return(false); } else { item = Inventory[indexOfRessource.x][indexOfRessource.y]; return(true); } }
static public void AddItemToInventory(ItemsUniqueID uniqueID, uint quantity = 1) { Item newItem; switch (uniqueID) { case ItemsUniqueID.littleRock: newItem = new Weapon(0); break; case ItemsUniqueID.bow: newItem = new Weapon(1); break; case ItemsUniqueID.arrow: newItem = new Item(0, quantity); break; case ItemsUniqueID.axe: newItem = new Weapon(2); break; case ItemsUniqueID.pickaxe: newItem = new Weapon(3); break; case ItemsUniqueID.fist: newItem = new Weapon(4); break; case ItemsUniqueID.spear: newItem = new Weapon(5); break; case ItemsUniqueID.cudgel: newItem = new Weapon(6); break; case ItemsUniqueID.blowpipe: newItem = new Weapon(7); break; case ItemsUniqueID.thorn: newItem = new Item(1, quantity); break; case ItemsUniqueID.wood: case ItemsUniqueID.stone: case ItemsUniqueID.iron: case ItemsUniqueID.coal: case ItemsUniqueID.silex: case ItemsUniqueID.blood: newItem = new Ressource((Ressource.RessourceType)((int)uniqueID - 10), quantity); break; default: return; } newItem.UniqueID = uniqueID; AddItemInInventory(newItem); }