GameEndState.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Comp;
  2. using UnityEngine;
  3. namespace Game
  4. {
  5. public class GameEndState : GameState
  6. {
  7. public override void PlayBattle()
  8. {
  9. // 啥都不做
  10. }
  11. public override void BattleStart()
  12. {
  13. // 啥都不做
  14. }
  15. public override void LiftCock()
  16. {
  17. // 啥都不做
  18. }
  19. public override void ExitBattle()
  20. {
  21. _gameCore.Exit();
  22. }
  23. public override void EndBattle()
  24. {
  25. // 啥都不做
  26. }
  27. public override void EnterState()
  28. {
  29. Debug.Log("执行结束");
  30. if (_gameCore.showResultPanel)
  31. ShowResultPanel();
  32. _gameCore.pendingState.ExitBattle();
  33. _gameCore.battleState.ExitBattle();
  34. _gameCore.liftState.ExitBattle();
  35. _gameCore.endState.ExitBattle();
  36. }
  37. public override void ExitState()
  38. {
  39. // 啥都不做
  40. }
  41. public GameEndState(GameCore gameCore) : base(gameCore)
  42. {
  43. }
  44. private void ShowResultPanel()
  45. {
  46. _gameCore.resultPanel.SetActive(true);
  47. var isWin = _gameCore.localPlayer.playerId == _gameCore.winPlayerId;
  48. var resultComps = _gameCore.resultPanel.GetComponentsInChildren<BattleResultComp>();
  49. foreach (var battleResultComp in resultComps)
  50. {
  51. if (battleResultComp.IsWin() == isWin)
  52. {
  53. battleResultComp.gameObject.SetActive(true);
  54. battleResultComp.SetValue(_gameCore.diamond + "");
  55. }
  56. else
  57. {
  58. battleResultComp.gameObject.SetActive(false);
  59. }
  60. }
  61. }
  62. }
  63. }