Example #1
0
 public bool Show(Level levelProfile)
 {
     base.Show();
     GameManager.main.Gameplay.SetActive(true);
     currScore          = 0;
     AddScoreText.text  = "";
     Balls.Score        = 0;
     ScoreText.text     = string.Format("{0}", currScore);
     BestScoreText.text = string.Format("{0}", GameData.GetLevelBestScore(levelProfile.Num));
     Balls.LoadLevel(levelProfile);
     return(true);
 }
Example #2
0
        private IEnumerator ShowScoreRoutine()
        {
            processing = true;
            NewBest.gameObject.SetActive(false);
            completedLevelProfile = Balls.main.CurrLevelProfile;

            levelBestScore = GameData.GetLevelBestScore(completedLevelProfile.Num);
            MainMenuBtn.SetActive(false);
            RestartBtn.SetActive(false);
            NextLevelBtn.SetActive(false);
            LevelNumText.text  = string.Format("LEVEL: {0}", completedLevelProfile.Num);
            BestScoreText.text = string.Format("{0}", levelBestScore);
            GameData.MaxLevel  = completedLevelProfile.Num + 1;
            int   currScore   = 0;
            float targetScore = Balls.Score;

            Balls.Active = false;
            Stars.Show(completedLevelProfile.FirstStarScore, completedLevelProfile.SecondStarScore, completedLevelProfile.ThirdStarScore);
            int starsCount = Stars.GetStarsCount((int)targetScore);

            GameData.SetLevelStars(completedLevelProfile.Num, starsCount);

            for (float f = 0f; f <= 1f; f += 0.01f)
            {
                currScore = (int)Mathf.Lerp(0f, targetScore, f);
                Stars.UpdateState(currScore);
                ScoreText.text = string.Format("{0}", currScore);
                yield return(null);
            }
            ScoreText.text = string.Format("{0}", (int)targetScore);
            if (Balls.Score > levelBestScore)
            {
                yield return(new WaitForSeconds(0.5f));

                GameData.SetLevelBestScore(completedLevelProfile.Num, Balls.Score);
                NewBest.gameObject.SetActive(true);
                NewBest.gameObject.ScaleFrom(Vector3.zero, 0.5f, 0f);
                BestScoreText.text = string.Format("{0}", Balls.Score);
            }
            yield return(new WaitForSeconds(0.1f));

            MainMenuBtn.SetActive(true);
            yield return(new WaitForSeconds(0.1f));

            RestartBtn.SetActive(true);
            yield return(new WaitForSeconds(0.1f));

            NextLevelBtn.SetActive(true);
            processing = false;
            yield return(null);
        }