Exemple #1
0
        /// <summary>
        /// Change result of level (number of stars)
        /// </summary>
        /// <param name="btnGO"></param>
        /// <param name="resultPassing"></param>
        private void ChangeLevelButton(GameObject btnGO, Level.ResultPassing resultPassing)
        {
            //Text btnText = btnGO.GetComponentInChildren<Text>();
            //btnText.text = resultPassing.ToString();

            LevelButton levelButton = btnGO.GetComponent <LevelButton>();

            switch (resultPassing)
            {
            case Level.ResultPassing.Low:
                levelButton.SetLevelStars(1);
                //Debug.Log("Low");
                break;

            case Level.ResultPassing.Middle:
                levelButton.SetLevelStars(2);
                //Debug.Log("Middle");
                break;

            case Level.ResultPassing.High:
                levelButton.SetLevelStars(3);
                //Debug.Log("High");
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Draw UI level button
        /// </summary>
        /// <param name="level"></param>
        private void DrawButton(Level level)
        {
            GameObject newButtonGO = Instantiate(levelButtonPrefab, levelBox.transform, false) as GameObject;

            newButtonGO.name = level.levelName;

            Text btnText = newButtonGO.GetComponentInChildren <Text>();

            btnText.text = level.levelName;

            Button newButton = newButtonGO.GetComponent <Button>();

            switch (level.currentState)
            {
            case Level.LevelState.Locked:
                newButton.interactable = false;
                //Debug.Log("Locked");
                break;

            case Level.LevelState.Unlocked:
                newButton.onClick.AddListener(() => LoadSelectedLevel(level));
                newButton.onClick.AddListener(() => SoundManager.Instance.PlayUIButtonSound());
                //Debug.Log("Unlocked");
                break;
            }

            LevelButton levelButton = newButtonGO.GetComponent <LevelButton>();

            switch (level.currentResult)
            {
            case Level.ResultPassing.NotPassed:
                //Debug.Log("NotPassed");
                break;

            case Level.ResultPassing.Low:
                levelButton.SetLevelStars(1);
                //Debug.Log("Low");
                break;

            case Level.ResultPassing.Middle:
                levelButton.SetLevelStars(2);
                //Debug.Log("Middle");
                break;

            case Level.ResultPassing.High:
                levelButton.SetLevelStars(3);
                //Debug.Log("High");
                break;
            }
        }