コード例 #1
0
    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';
        }
    }
コード例 #2
0
    public void Upgrade()
    {
        foreach (Item_And_Quantity requiredItemAndQuantity in GetRequiredItemsToUpgrade())
        {
            storageManager.SubtractQuantity(requiredItemAndQuantity);
        }

        ++currentHouseLevel;
    }
コード例 #3
0
    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);
    }