コード例 #1
0
    IEnumerator ExecuteProduction(ProductItem item, BuildSellButtonHandler handler)
    {
        while (currentInventory < maxInventory && itemsBeingProduced[item] && BusinessManager.businessManager.totalMoney >= item.cost)
        {
            yield return(WaitForItemTime(item, handler));

            AddInventory(item, handler);
        }
    }
コード例 #2
0
    IEnumerator WaitForInventorySpace(ProductItem item, BuildSellButtonHandler handler)
    {
        // wait for inventory space to clear
        while (currentInventory >= maxInventory && itemsBeingProduced[item] && BusinessManager.businessManager.totalMoney >= item.cost)
        {
            yield return(null);
        }

        // restart production
        StartCoroutine(ExecuteProduction(item, handler));
    }
コード例 #3
0
    public void StartProduction(ProductItem item, BuildSellButtonHandler handler)
    {
        // called by button handler to start production.
        if (BusinessManager.businessManager.totalMoney < item.cost)
        {
            return;
        }

        timeRemaining[item]      = item.time;
        itemsBeingProduced[item] = true;
        StartCoroutine(ExecuteProduction(item, handler));
    }
コード例 #4
0
    void AddInventory(ProductItem item, BuildSellButtonHandler handler)
    {
        if (currentInventory >= maxInventory)
        {
            return;
        }
        if (!itemsBeingProduced[item])
        {
            return;
        }

        inventory[item]  += 1;
        currentInventory += 1;
        BusinessManager.businessManager.totalMoney -= item.cost;
        StartCoroutine(BusinessManager.businessManager.DecreaseNumbers());
        timeRemaining[item] = item.time;
        handler.UpdateInventory();
        StartCoroutine(inventoryPanel.IncreaseNumbers(item));
    }
コード例 #5
0
    IEnumerator WaitForItemTime(ProductItem item, BuildSellButtonHandler handler)
    {
        // Create custom wait coroutine so we can check if inventory has exceeded capacity every frame instead of every x seconds
        float targetTime = Time.time + item.time;

        while (Time.time < targetTime && currentInventory < maxInventory && itemsBeingProduced[item] && BusinessManager.businessManager.totalMoney >= item.cost)
        {
            timeRemaining[item] = targetTime - Time.time;
            yield return(null);
        }

        if (!itemsBeingProduced[item])
        {
            yield break;
        }

        if (currentInventory >= maxInventory)
        {
            StartCoroutine(WaitForInventorySpace(item, handler));
        }
    }