BattleSettlementPanel.cs 2.8 KB

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