コード例 #1
0
    public void GoToLevelMenu()
    {
        int LevelNum = PlayerPrefs.GetInt("currentLevelNum");

        if (WinToggle.isOn)
        {
            LevelData.setWon(LevelNum, true);

            if (LevelData.getScore(LevelNum) < (int)ScoreSlider.value)
            {
                LevelData.setScore(LevelNum, (int)ScoreSlider.value);
            }

            if (LevelData.getStarCount(LevelNum) < (int)StarSlider.value)
            {
                LevelData.setStarCount(LevelNum, (int)StarSlider.value);
                LevelData.AnimateStars(LevelNum);
            }

            if (UnLockNextLevel.isOn)
            {
                LevelData.Unlock(LevelNum + 1);
            }
        }

        LevelData.goToLevelMenu();
    }
コード例 #2
0
    public void GoToNextLevel()
    {
        int LevelNum     = PlayerPrefs.GetInt("currentLevelNum");
        int NextLevelNum = LevelNum + 1;

        if (WinToggle.isOn)
        {
            LevelData.setWon(LevelNum, true);

            if (LevelData.getScore(LevelNum) < (int)ScoreSlider.value)
            {
                LevelData.setScore(LevelNum, (int)ScoreSlider.value);
            }

            if (LevelData.getStarCount(LevelNum) < (int)StarSlider.value)
            {
                LevelData.setStarCount(LevelNum, (int)StarSlider.value);
                LevelData.AnimateStars(LevelNum);
            }

            if (UnLockNextLevel.isOn)
            {
                LevelData.Unlock(NextLevelNum);
            }
        }


        LevelData.goToLevel(NextLevelNum); //go to Level automatically unlocks the Level
    }
コード例 #3
0
    //set the Stars
    private void SetStars()
    {
        if (starsGO == null)
        {
            Debug.LogWarning("Stars doesn't exist");
            return;
        }

        bool animateStars = LevelData.getAnimateStars(levelNum);

        //if the starGO is not active then return
        if (!starsGO.activeSelf)
        {
            return;
        }

        //active of deactivate stars based on the number of stars collected in the level
        for (int i = 0; i < starsGO.transform.childCount; i++)
        {
            if (stars >= i + 1)
            {
                starsGO.transform.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                starsGO.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        //set animator with bool values
        starsGO.GetComponent <Animator>().SetBool("Animate", animateStars);
        starsGO.GetComponent <Animator>().SetBool("IsOn", true);

        //set animate stars to false
        LevelData.AnimateStars(levelNum, false);
    }