コード例 #1
0
    /**
     * This function will check how many levels has the player cleared and then mark the correct amount of buttons as clickable
     * Additionally this function will hide all the cats that the player has not yet acquired.
     */
    private void checkButtons()
    {
        int clearedlevels = system.getClearedLevels();

        for (int i = 0; i < buttons.Capacity; i++)
        {
            if (clearedlevels >= i)
            {
                buttons[i].interactable = true;
                if (system.isCatCollected(i))
                {
                    GameObject.Find("Main Canvas/Buttons/Level" + (i + 1) + "/cat_l" + (i + 1)).SetActive(true);
                }
            }
            else if (clearedlevels < i)
            {
                buttons[i].interactable = false;
                GameObject.Find("Main Canvas/Buttons/Level" + (i + 1) + "/cat_l" + (i + 1)).SetActive(false);
            }

            /*
             * if(i == (buttons.Capacity - 1) && !system.isCatCollected(i))                                      //makes sure that the number of cats being displayed is correct
             * {
             *  GameObject.Find("Main Canvas/Buttons/Level" + (i+1) + "/cat_l" + (i+1)).SetActive(false);
             * }
             */
        }
    }