BattleSettlementPanel.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. }
  37. public async void CustomInit(bool isWin, System.Action callBack)
  38. {
  39. this.callBack = callBack;
  40. AudioManager.Instance.PauseBGM();
  41. if (isWin)
  42. {
  43. Btn_Close.enabled = true;
  44. AudioManager.Instance.PlayAudio("combat_win.wav");
  45. WinRoot.SetActive(true);
  46. FailRoot.SetActive(false);
  47. // f
  48. // Text_Desc.gameObject.SetActive(false);
  49. // Text_Settlement.text = "胜利";
  50. }
  51. else
  52. {
  53. Btn_Close.enabled = false;
  54. AudioManager.Instance.PlayAudio("shibai.wav");
  55. WinRoot.SetActive(false);
  56. FailRoot.SetActive(true);
  57. SkipToWidget skipToWidget =
  58. await UIManager.Instance.CreateGComponentForObject<SkipToWidget>(SkipToWidgetGam, null,
  59. SkipToContent);
  60. skipToWidget.CustonInit(1);
  61. skipToWidgets.Add(skipToWidget);
  62. skipToWidget.OnClick = OnClick;
  63. // Text_Desc.gameObject.SetActive(true);
  64. // Text_Settlement.text = "失败";
  65. }
  66. }
  67. private async void OnClick(ItemWidgetBasic obj)
  68. {
  69. SkipToWidget skipToWidget = obj as SkipToWidget;
  70. await UIManager.Instance.HideUIUIPanel(this);
  71. callBack?.Invoke();
  72. callBack = null;
  73. SkiptoHelper.Skipto(skipToWidget.SkiptoConfig.ID);
  74. }
  75. public static async CTask<BattleSettlementPanel> OpenPanel(bool isWin, System.Action callBack)
  76. {
  77. BattleSettlementPanel battleSettlementPanel =
  78. await UIManager.Instance.LoadAndOpenPanel<BattleSettlementPanel>(null, isShowBG: true);
  79. battleSettlementPanel.CustomInit(isWin, callBack);
  80. return battleSettlementPanel;
  81. }
  82. public async override CTask Close()
  83. {
  84. AudioManager.Instance.UnPauseBGM();
  85. foreach (var skipToWidget in skipToWidgets)
  86. {
  87. UIManager.Instance.DormancyGComponent(skipToWidget);
  88. }
  89. skipToWidgets.Clear();
  90. await base.Close();
  91. }
  92. }
  93. }