GameEndState.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. _gameCore.resultPanel.SetActive(true);
  31. var isWin = _gameCore.localPlayer.playerId == _gameCore.winPlayerId;
  32. var resultComps = _gameCore.resultPanel.GetComponentsInChildren<BattleResultComp>();
  33. foreach (var battleResultComp in resultComps)
  34. {
  35. if (battleResultComp.IsWin() == isWin)
  36. {
  37. battleResultComp.gameObject.SetActive(true);
  38. battleResultComp.SetValue(_gameCore.diamond + "");
  39. }
  40. else
  41. {
  42. battleResultComp.gameObject.SetActive(false);
  43. }
  44. }
  45. _gameCore.pendingState.ExitBattle();
  46. _gameCore.battleState.ExitBattle();
  47. _gameCore.liftState.ExitBattle();
  48. _gameCore.endState.ExitBattle();
  49. }
  50. public override void ExitState()
  51. {
  52. // 啥都不做
  53. }
  54. public GameEndState(GameCore gameCore) : base(gameCore)
  55. {
  56. }
  57. }
  58. }