コード例 #1
0
        /// <summary>
        /// Shows the end game screen
        /// </summary>
        protected void OpenEndGameScreen(string endResultText)
        {
            LevelItem level = GameManager.instance.GetLevelForCurrentScene();

            endGameCanvas.enabled = true;

            int score = CalculateFinalScore();

            scorePanel.SetStars(score);
            if (level != null)
            {
                //endGameMessageText.text = string.Format (endResultText, level.name.ToUpper ());
                GameManager.instance.CompleteLevel(level.id, score);
            }
            else
            {
                // If the level is not in LevelList, we should just use the name of the scene. This will not store the level's score.
                //string levelName = SceneManager.GetActiveScene ().name;
                //endGameMessageText.text = string.Format (endResultText, levelName.ToUpper ());
            }

            if (!TowerDefense.UI.HUD.GameUI.instanceExists)
            {
                return;
            }
            if (TowerDefense.UI.HUD.GameUI.instance.state == TowerDefense.UI.HUD.GameUI.State.Building)
            {
                TowerDefense.UI.HUD.GameUI.instance.CancelGhostPlacement();
            }
            TowerDefense.UI.HUD.GameUI.instance.GameOver();
        }