BattleSettlementPanel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. public async void CustomInit(bool isWin, System.Action callBack)
  43. {
  44. this.callBack = callBack;
  45. levelBattleCombatType =
  46. CombatDrive.Instance.CombatController.CombatTypeBasic as LevelBattleCombatType;
  47. AudioManager.Instance.PauseBGM();
  48. if (isWin)
  49. {
  50. Btn_Close.enabled = true;
  51. AudioManager.Instance.PlayAudio("combat_win.wav");
  52. WinRoot.SetActive(true);
  53. FailRoot.SetActive(false);
  54. Text_Desc1.gameObject.SetActive(true);
  55. }
  56. else
  57. {
  58. Btn_Close.enabled = false;
  59. AudioManager.Instance.PlayAudio("shibai.wav");
  60. WinRoot.SetActive(false);
  61. FailRoot.SetActive(true);
  62. Text_Desc1.gameObject.SetActive(false);
  63. if (levelBattleCombatType.levelbattleConfig.ID == 1003 ||
  64. levelBattleCombatType.levelbattleConfig.ID == 100004)
  65. {
  66. if (levelBattleCombatType.levelbattleConfig.ID == 1003)
  67. {
  68. SkipToWidget skipToWidget1 =
  69. await UIManager.Instance.CreateGComponentForObject<SkipToWidget>(SkipToWidgetGam, null,
  70. SkipToContent);
  71. skipToWidget1.CustonInit(3);
  72. skipToWidgets.Add(skipToWidget1);
  73. skipToWidget1.OnClick = OnClick;
  74. }
  75. SkipToWidget skipToWidget =
  76. await UIManager.Instance.CreateGComponentForObject<SkipToWidget>(SkipToWidgetGam, null,
  77. SkipToContent);
  78. skipToWidget.CustonInit(1);
  79. skipToWidgets.Add(skipToWidget);
  80. skipToWidget.OnClick = OnClick;
  81. }
  82. }
  83. }
  84. private async void OnClick(ItemWidgetBasic obj)
  85. {
  86. SkipToWidget skipToWidget = obj as SkipToWidget;
  87. await UIManager.Instance.HideUIUIPanel(this);
  88. callBack?.Invoke();
  89. callBack = null;
  90. SkiptoHelper.Skipto(skipToWidget.SkiptoConfig.ID, true);
  91. }
  92. public static async CTask<BattleSettlementPanel> OpenPanel(bool isWin, System.Action callBack)
  93. {
  94. BattleSettlementPanel battleSettlementPanel =
  95. await UIManager.Instance.LoadAndOpenPanel<BattleSettlementPanel>(null, isShowBG: true);
  96. battleSettlementPanel.CustomInit(isWin, callBack);
  97. return battleSettlementPanel;
  98. }
  99. public async override CTask Close()
  100. {
  101. AudioManager.Instance.UnPauseBGM();
  102. foreach (var skipToWidget in skipToWidgets)
  103. {
  104. UIManager.Instance.DormancyGComponent(skipToWidget);
  105. }
  106. skipToWidgets.Clear();
  107. await base.Close();
  108. }
  109. }
  110. }