public bool DoesItemExist(BaseResource itemToSearchFor) { for (int i = 0; i < InventoryBag.Count; i++) { //if (InventoryBag[i] != null) //{ if (InventoryBag[i].itemType.baseCollectible.GetName() == itemToSearchFor.GetName()) { return(true); } // } } return(false); }
public itemClass GetItemFromInventory(BaseResource itemToGet, int AmountToGet = 0, bool DestroyItems = false) { for (int i = 0; i < InventoryBag.Count; i++) { //if (InventoryBag[i] != null) //{ if (InventoryBag[i].itemType.baseCollectible.GetName() == itemToGet.GetName()) { if (DestroyItems == true && InventoryBag[i].amountOfItem >= AmountToGet) { itemClass tempItem = InventoryBag[i]; if (InventoryBag[i].amountOfItem > AmountToGet) { InventoryBag[i].AdjustAmount(-AmountToGet); } else if (InventoryBag[i].amountOfItem == AmountToGet) { InventoryBag[i].SetAmount(0); InventoryBag[i] = tempColl; } return(tempItem); } else if (DestroyItems == false && AmountToGet > InventoryBag[i].amountOfItem) { break; } else { return(InventoryBag[i]); } } // } } itemClass empty = new itemClass(); return(empty); }