public void InitializeUI(StarConfig pStarConfig, int pSaved, int pScore, int pDead, bool pPassed) { GameController.InMenuScreen = true; SceneLoader = FindObjectOfType <SceneLoader>(); LvlCtrl = new LevelController(SceneLoader); SavedText.text = pSaved.ToString(); LostText.text = pDead.ToString(); StarAnimator.updateMode = AnimatorUpdateMode.UnscaledTime; StartCoroutine(ProgressBarFill(pStarConfig, pScore)); if (pPassed) { if (SceneManager.GetActiveScene().buildIndex < SceneManager.sceneCountInBuildSettings - 1) { NextLvlBtnObj.gameObject.SetActive(true); LevelSelectionBtnObj.gameObject.SetActive(false); RestartLevelBtnObj.gameObject.SetActive(false); StaticLvlSelectBtnObj.gameObject.SetActive(true); } else { NextLvlBtnObj.gameObject.SetActive(false); LevelSelectionBtnObj.gameObject.SetActive(true); RestartLevelBtnObj.gameObject.SetActive(false); StaticLvlSelectBtnObj.gameObject.SetActive(false); } } else { RestartLevelBtnObj.gameObject.SetActive(true); NextLvlBtnObj.gameObject.SetActive(false); LevelSelectionBtnObj.gameObject.SetActive(false); StaticLvlSelectBtnObj.gameObject.SetActive(true); } }
private IEnumerator ProgressBarFill(StarConfig pStarConfig, int pScore) { ProgressBar.fillAmount = CurrFillPoint; MaxLevelScore = (int)(pStarConfig.PointsForGold * 1.1f); while (true) { CurrFillPoint = ProgressBar.fillAmount * MaxLevelScore; ProgressBar.fillAmount += FillSpeed * Time.unscaledDeltaTime; ScoreText.text = CurrFillPoint.ToString("0"); if (CurrFillPoint >= pStarConfig.PointsForBronze && StarCount == 0) { GiveOneStar(); StarCount += 1; } if (CurrFillPoint >= pStarConfig.PointsForSilver && StarCount == 1) { GiveTwoStars(); StarCount += 1; } if (CurrFillPoint >= pStarConfig.PointsForGold && StarCount == 2) { GiveThreeStars(); StarCount += 1; } if (CurrFillPoint >= MaxLevelScore || CurrFillPoint >= pScore) { ScoreText.text = pScore.ToString(); break; } yield return(null); } }