private void GameEnd() { Debug.Log("Game End"); m_AudioSource.Stop(); m_AudioSource.loop = false; ScoreManagerInstance.Stop(); BombManagerInstance.Stop(); float delay = 0f; if (m_GameResult) { if (GameWinClip != null) { AudioSource.PlayClipAtPoint(GameWinClip, this.transform.position); delay = GameWinClip.length; } } else { if (GameLoseClip != null) { AudioSource.PlayClipAtPoint(GameLoseClip, this.transform.position); delay = GameLoseClip.length; } } GameResultPanel.SetActive(true); // 播放完音效之后,删除场景中所有的Generator Destroy(Generator, delay); }
// 游戏结束 private void GameEnd() { // 停止播放背景音乐 m_AudioSource.Stop(); m_AudioSource.loop = false; // 让管理器停止工作 ScoreManagerInstance.Stop(); BombManagerInstance.Stop(); float delay = 0f; // 播放胜利或者失败的音效 if (m_GameResult) { if (GameWinClip != null) { AudioSource.PlayClipAtPoint(GameWinClip, this.transform.position); delay = GameWinClip.length; } else { Debug.LogError("请设置GameWinClip"); } // 设置游戏结果 GameResultText.text = "You Win!!!"; } else { if (GameLoseClip != null) { AudioSource.PlayClipAtPoint(GameLoseClip, this.transform.position); delay = GameLoseClip.length; } else { Debug.LogError("请设置GameLoseClip"); } // 设置游戏结果 GameResultText.text = "You Lose!!!"; } // 显示游戏结束界面 GameResultPanel.SetActive(true); // 播放完音效之后,删除场景中的所有Generator Destroy(Generator, delay); }