ZCJBBuyTipsView.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using UI.ActivityMain;
  4. using FairyGUI;
  5. using UI.CommonGame;
  6. namespace GFGGame
  7. {
  8. public class ZCJBBuyTipsView : BaseWindow
  9. {
  10. private UI_ZCJBBuyTips _ui;
  11. private string Desc;
  12. private int limitID;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. BuyTipsController.Dispose();
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. _ui = UI_ZCJBBuyTips.Create();
  27. this.viewCom = _ui.target;
  28. this.viewCom.Center();
  29. this.modal = true;
  30. _ui.m_btnRight.onClick.Add(OnClickBtnSure);
  31. _ui.m_btnLeft.onClick.Add(OnClickBtnCancel);
  32. _ui.m_graphBg.onClick.Add(OnClickBtnCancel);
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. Desc = (string)(this.viewData as object[])[0];
  38. limitID = (int)(this.viewData as object[])[1];
  39. UpdateView();
  40. }
  41. protected override void AddEventListener()
  42. {
  43. base.AddEventListener();
  44. EventAgent.AddEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, LimitChanged);
  45. }
  46. protected override void RemoveEventListener()
  47. {
  48. base.RemoveEventListener();
  49. EventAgent.RemoveEventListener(ConstMessage.NOTICE_LIMIT_CHANGED, LimitChanged);
  50. }
  51. private void UpdateView()
  52. {
  53. _ui.m_txtContent.text = Desc;
  54. _ui.m_txtTips.text = "(购买的次数请及时使用,次日5:00重置)";
  55. }
  56. private void OnClickBtnSure()
  57. {
  58. RoleLimitSProxy.ReqBuyLimitPlayTimes(limitID, 1, 1).Coroutine();
  59. }
  60. private void LimitChanged(EventContext context = null)
  61. {
  62. if ((int)context.data != limitID)
  63. {
  64. return;
  65. }
  66. PromptController.Instance.ShowFloatTextPrompt("次数+1");
  67. }
  68. private void OnClickBtnCancel()
  69. {
  70. this.Hide();
  71. }
  72. }
  73. }