void Start() { Storage_Manager storageManager = GameObject.Find("Storage_Manager").GetComponent <Storage_Manager>(); textToDisplayLostItems.text += "\n"; foreach (Lost_Item lostItem in items) { Item_And_Quantity stored = storageManager.GetStoredItemAndQuantity(lostItem.itemToLose); Item_And_Quantity toLose = new Item_And_Quantity(stored.item, 0); int randomAmount = Random.Range(lostItem.minimumLost, lostItem.maximumLost); if (stored.quantity > randomAmount) { toLose.quantity = ( uint )randomAmount; storageManager.SubtractQuantity(toLose); } else if (stored.quantity == 0) { } else { // lose all storageManager.SubtractQuantity(stored); } textToDisplayLostItems.text += toLose.item.name + " x" + toLose.quantity.ToString() + '\n'; } }
public void Upgrade() { foreach (Item_And_Quantity requiredItemAndQuantity in GetRequiredItemsToUpgrade()) { storageManager.SubtractQuantity(requiredItemAndQuantity); } ++currentHouseLevel; }
void OnClickCraft() { Item_And_Quantity craftedItem = new Item_And_Quantity(selectedItemToCraft, 1); storageManager.AddQuantity(craftedItem); foreach (Item_And_Quantity requiredItem in selectedItemToCraft.requiredMaterialsToCraft.requiredItems) { storageManager.SubtractQuantity(requiredItem); } RepopulateItems(); OnClickCraftableItem(selectedItemToCraft); }