Example #1
0
    public void StartBuilding(string buttonContent)
    {
        Debug.Log("button click: " + buttonContent);
        if (buttonContent == "add-stall")
        {
            if (PlayerEconomy.Money >= Prices.GetStallConstructionPrice(unlockedStalls))
            {
                PlayerEconomy.PayMoney(Prices.GetStallConstructionPrice(unlockedStalls));


                //enable GO, construction
                stalls [unlockedStalls].gameObject.SetActive(true);
                stalls [unlockedStalls].underConstruction.SetActive(true);
                for (int i = 0; i < stalls [unlockedStalls].finished.Length; ++i)
                {
                    stalls [unlockedStalls].finished [i].SetActive(false);
                }

                //store in duration dict. index is nr of unlocked stalls
                constructionDaysRemainingPerStallIndex.Add(unlockedStalls, Durations.GetStallConstructionDuration(unlockedStalls));
                UI.instance.constructionUI.underConstructionDaysRemaining.text = constructionDaysRemainingPerStallIndex[unlockedStalls].ToString() + " " + GetDayPluralSingular(constructionDaysRemainingPerStallIndex[unlockedStalls]) + " remaining";

                unlockedStalls++;

                UI.instance.constructionUI.hideOnConstruction.SetActive(false);
                UI.instance.constructionUI.showOnConstruction.SetActive(true);
            }
            else
            {
                Debug.Log("not enough money for stall construction!");
            }
        }
    }
Example #2
0
    private void OpenConstructionWindow()
    {
        UI.instance.constructionUI.gameObject.SetActive(true);


        if (constructionDaysRemainingPerStallIndex.Count > 0)
        {
            UI.instance.constructionUI.showOnConstruction.SetActive(true);
            UI.instance.constructionUI.hideOnConstruction.SetActive(false);
            UI.instance.constructionUI.underConstructionDaysRemaining.text = constructionDaysRemainingPerStallIndex [unlockedStalls - 1].ToString() + " " + GetDayPluralSingular(constructionDaysRemainingPerStallIndex [unlockedStalls - 1]) + " remaining";
        }
        else
        {
            UI.instance.constructionUI.showOnConstruction.SetActive(false);
            UI.instance.constructionUI.hideOnConstruction.SetActive(true);
        }



        //the number of unlocked stalls (i.e. 1 at the start) equals the index of the next to unlock
        UI.instance.constructionUI.priceForNextStall.text    = Prices.GetStallConstructionPrice(unlockedStalls).ToString() + "ยข";
        UI.instance.constructionUI.durationForNextStall.text = Durations.GetStallConstructionDuration(unlockedStalls).ToString() + " " + GetDayPluralSingular(Durations.GetStallConstructionDuration(unlockedStalls));

        //partition text
        if (unlockedStalls == 1)
        {
            UI.instance.constructionUI.partitionText.text = "You only have one stall, all walls are needed.";
        }
        else
        {
            UI.instance.constructionUI.partitionText.text = "Click the white/brown toggles to enable or disable the partitions between paddocks.";
        }

        for (int i = 0; i < UI.instance.constructionUI.paddockToggles.Length; ++i)
        {
            if (i < unlockedStalls)
            {
                UI.instance.constructionUI.paddockToggles [i].gameObject.SetActive(true);
                UI.instance.constructionUI.paddockToggles [i].toggle.isOn = partitionsEnabled [i];
            }
            else
            {
                UI.instance.constructionUI.paddockToggles [i].gameObject.SetActive(false);
            }
            //enable all here so I can disable the right one below, otherwise it won't work again after changes
            if (constructionDaysRemainingPerStallIndex.ContainsKey(i + 1) && constructionDaysRemainingPerStallIndex [i + 1] > 0)
            {
                UI.instance.constructionUI.paddockToggles [i].toggle.gameObject.SetActive(false);
            }
            else
            {
                UI.instance.constructionUI.paddockToggles [i].toggle.gameObject.SetActive(true);
            }
        }

        UI.instance.constructionUI.paddockToggles [unlockedStalls - 1].toggle.gameObject.SetActive(false);
    }