BattleSettlementPanel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System.Collections.Generic;
  2. using Core.Audio;
  3. using Fort23.Core;
  4. using GameLogic.Combat;
  5. using GameLogic.Combat.CombatType;
  6. using GameUI.Combat;
  7. using Mono.Utility;
  8. namespace Fort23.Mono
  9. {
  10. [UIBinding(prefab = "BattleSettlementPanel")]
  11. public partial class BattleSettlementPanel : UIPanel
  12. {
  13. private System.Action callBack;
  14. List<SkipToWidget> skipToWidgets = new List<SkipToWidget>();
  15. LevelBattleCombatType levelBattleCombatType ;
  16. private void Init()
  17. {
  18. isAddStack = false;
  19. }
  20. protected override void AddEvent()
  21. {
  22. }
  23. protected override void DelEvent()
  24. {
  25. }
  26. public override void AddButtonEvent()
  27. {
  28. Btn_Close.onClick.AddListener(async () =>
  29. {
  30. await UIManager.Instance.HideUIUIPanel(this);
  31. callBack?.Invoke();
  32. callBack = null;
  33. });
  34. Btn_Close2.onClick.AddListener(async() =>
  35. {
  36. await UIManager.Instance.HideUIUIPanel(this);
  37. callBack?.Invoke();
  38. callBack = null;
  39. });
  40. Btn_cxtz.onClick.AddListener(() =>
  41. {
  42. });
  43. }
  44. public async void CustomInit(bool isWin, System.Action callBack)
  45. {
  46. this.callBack = callBack;
  47. levelBattleCombatType =
  48. CombatDrive.Instance.CombatController.CombatTypeBasic as LevelBattleCombatType;
  49. AudioManager.Instance.PauseBGM();
  50. if (isWin)
  51. {
  52. Btn_Close.enabled = true;
  53. AudioManager.Instance.PlayAudio("combat_win.wav");
  54. WinRoot.SetActive(true);
  55. FailRoot.SetActive(false);
  56. Text_Desc1.gameObject.SetActive(true);
  57. }
  58. else
  59. {
  60. Btn_Close.enabled = false;
  61. AudioManager.Instance.PlayAudio("shibai.wav");
  62. WinRoot.SetActive(false);
  63. FailRoot.SetActive(true);
  64. Text_Desc1.gameObject.SetActive(false);
  65. if (levelBattleCombatType.levelbattleConfig.ID == 1003 || levelBattleCombatType.levelbattleConfig.ID == 100004)
  66. {
  67. if (levelBattleCombatType.levelbattleConfig.ID == 1003
  68. {
  69. SkipToWidget skipToWidget1 = await UIManager.Instance.CreateGComponentForObject<SkipToWidget>(SkipToWidgetGam, null, SkipToContent);
  70. skipToWidget1.CustonInit(3);
  71. skipToWidgets.Add(skipToWidget1);
  72. skipToWidget1.OnClick = OnClick;
  73. }
  74. SkipToWidget skipToWidget = await UIManager.Instance.CreateGComponentForObject<SkipToWidget>(SkipToWidgetGam, null, SkipToContent);
  75. skipToWidget.CustonInit(1);
  76. skipToWidgets.Add(skipToWidget);
  77. skipToWidget.OnClick = OnClick;
  78. }
  79. }
  80. }
  81. private async void OnClick(ItemWidgetBasic obj)
  82. {
  83. SkipToWidget skipToWidget = obj as SkipToWidget;
  84. await UIManager.Instance.HideUIUIPanel(this);
  85. callBack?.Invoke();
  86. callBack = null;
  87. SkiptoHelper.Skipto(skipToWidget.SkiptoConfig.ID);
  88. }
  89. public static async CTask<BattleSettlementPanel> OpenPanel(bool isWin, System.Action callBack)
  90. {
  91. BattleSettlementPanel battleSettlementPanel =
  92. await UIManager.Instance.LoadAndOpenPanel<BattleSettlementPanel>(null, isShowBG: true);
  93. battleSettlementPanel.CustomInit(isWin, callBack);
  94. return battleSettlementPanel;
  95. }
  96. public async override CTask Close()
  97. {
  98. AudioManager.Instance.UnPauseBGM();
  99. foreach (var skipToWidget in skipToWidgets)
  100. {
  101. UIManager.Instance.DormancyGComponent(skipToWidget);
  102. }
  103. skipToWidgets.Clear();
  104. await base.Close();
  105. }
  106. }
  107. }