BattleSettlementPanel.cs 2.9 KB

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