public void Show(bool IsBestScore, int oldBestScore, EndGameReason reason) { Debug.LogError("FinishedGamePopup Show"); ResetComponents(); GameState GS = GameSceneManager.Instance.GameState; int StarsToActivate = 0; if (IsBestScore) { StarsToActivate = 3; } else { if (oldBestScore != 0) { float pctToBest = (GS.Score * 100) / oldBestScore; if (pctToBest >= 33f) { StarsToActivate++; } if (pctToBest >= 66f) { StarsToActivate++; } if (pctToBest >= 99f) { StarsToActivate++; } } } if (reason == EndGameReason.OUT_OF_TIME) { GameOverText.SetText(GameUtils.GetTranslatedText("TimeIsUp")); } else { GameOverText.SetText("GAME OVER"); } BestScoreTxt.SetText(oldBestScore.ToString()); ScoreTxt.SetText(GS.Score.ToString()); SavedAliensTxt.SetText(GS.CurrentSavedAliens.ToString()); StolenBriefcasesTxt.SetText(GS.CurrentStolenBriefcases.ToString()); gameObject.SetActive(true); // Debug.LogError("pass 2"); AnimCoroutine = Animate(IsBestScore, StarsToActivate); StartCoroutine(AnimCoroutine); }
void ResetComponents() { if (AnimCoroutine != null) { StopCoroutine(AnimCoroutine); } gameObject.SetActive(false); BG.color = new Color(BG.color.r, BG.color.g, BG.color.b, 0); BriefcaseIcon.color = new Color(BriefcaseIcon.color.r, BriefcaseIcon.color.g, BriefcaseIcon.color.b, 0); AlienIcon.color = new Color(AlienIcon.color.r, AlienIcon.color.g, AlienIcon.color.b, 0); StarsBG.color = new Color(StarsBG.color.r, StarsBG.color.g, StarsBG.color.b, 0); BestScoreTxt.SetText("0"); ScoreTxt.SetText("0"); SavedAliensTxt.SetText("0"); StolenBriefcasesTxt.SetText("0"); CharsUnlockedTxt.color = new Color(CharsUnlockedTxt.color.r, CharsUnlockedTxt.color.g, CharsUnlockedTxt.color.b, 0); GameOverText.color = new Color(GameOverText.color.r, GameOverText.color.g, GameOverText.color.b, 0); NewBestScoreLabel.color = new Color(NewBestScoreLabel.color.r, NewBestScoreLabel.color.g, NewBestScoreLabel.color.b, 0); BestScoreLabel.color = new Color(BestScoreLabel.color.r, BestScoreLabel.color.g, BestScoreLabel.color.b, 0); ScoreLabel.color = new Color(ScoreLabel.color.r, ScoreLabel.color.g, ScoreLabel.color.b, 0); ScoreTxt.color = new Color(ScoreTxt.color.r, ScoreTxt.color.g, ScoreTxt.color.b, 0); BestScoreTxt.color = new Color(BestScoreTxt.color.r, BestScoreTxt.color.g, BestScoreTxt.color.b, 0); SavedAliensTxt.color = new Color(SavedAliensTxt.color.r, SavedAliensTxt.color.g, SavedAliensTxt.color.b, 0); StolenBriefcasesTxt.color = new Color(StolenBriefcasesTxt.color.r, StolenBriefcasesTxt.color.g, StolenBriefcasesTxt.color.b, 0); stars[0].transform.localScale = Vector3.zero; stars[1].transform.localScale = Vector3.zero; stars[2].transform.localScale = Vector3.zero; PlayAgainBtn.transform.localScale = Vector3.zero; SettingsBtn.transform.localScale = Vector3.zero; MainMenuBtn.transform.localScale = Vector3.zero; foreach (Image b in HorizontalBars) { b.color = new Color(b.color.r, b.color.g, b.color.b, 0); } }