TipsPanle.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Core.Language;
  2. using Fort23.Core;
  3. using GameLogic.Combat.CombatTool;
  4. namespace Fort23.Mono
  5. {
  6. [UIBinding(prefab = "TipsPanle")]
  7. public partial class TipsPanle : UIPanel
  8. {
  9. private CTask<bool> _cTask;
  10. private void Init()
  11. {
  12. }
  13. protected override void AddEvent()
  14. {
  15. }
  16. protected override void DelEvent()
  17. {
  18. }
  19. public override void AddButtonEvent()
  20. {
  21. Btn_Cancel.onClick.AddListener(() =>
  22. {
  23. _cTask?.SetResult(false);
  24. UIManager.Instance.HideUIUIPanel(this);
  25. });
  26. Btn_Comfire.onClick.AddListener(() =>
  27. {
  28. _cTask?.SetResult(true);
  29. UIManager.Instance.HideUIUIPanel(this);
  30. });
  31. }
  32. public override void Close()
  33. {
  34. _cTask = null;
  35. base.Close();
  36. }
  37. public void CustomInit(string title,string tips, CTask<bool> cTask,int showButCount)
  38. {
  39. Text_Title.text = title;
  40. Text_Tips.text = tips;
  41. _cTask = cTask;
  42. if (showButCount == 1)
  43. {
  44. Btn_Cancel.gameObject.SetActive(false);
  45. Btn_Comfire.gameObject.SetActive(true);
  46. }
  47. else
  48. {
  49. Btn_Cancel.gameObject.SetActive(true);
  50. Btn_Comfire.gameObject.SetActive(true);
  51. }
  52. }
  53. public async static CTask<bool> OpenPnael(string title, string tips,int showButCount = 2)
  54. {
  55. CTask<bool> cTask = CTask<bool>.Create();
  56. TipsPanle tipsPanle = await UIManager.Instance.LoadAndOpenPanel<TipsPanle>(null,UILayer.Top);
  57. tipsPanle.CustomInit(title,tips, cTask,showButCount);
  58. return await cTask;
  59. }
  60. public async static CTask<bool> OpenPnael(int tips,int showButCount = 2)
  61. {
  62. CTask<bool> cTask = CTask<bool>.Create();
  63. TipsPanle tipsPanle = await UIManager.Instance.LoadAndOpenPanel<TipsPanle>(null,UILayer.Top);
  64. tipsPanle.CustomInit("",LanguageManager.Instance.Text(tips), cTask,showButCount);
  65. return await cTask;
  66. }
  67. }
  68. }