BattleSettlementPanel.cs 2.6 KB

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