StoreBlackCardRewardView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using ET;
  3. using FairyGUI;
  4. using Hutool;
  5. using UI.Store;
  6. using UI.CommonGame;
  7. namespace GFGGame
  8. {
  9. public class StoreBlackCardRewardView : BaseWindow
  10. {
  11. private UI_StoreBlackCardRewardUI _ui;
  12. private int _month;
  13. private int _day;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_StoreBlackCardRewardUI.PACKAGE_NAME;
  27. _ui = UI_StoreBlackCardRewardUI.Create();
  28. this.viewCom = _ui.target;
  29. this.viewCom.Center();
  30. this.modal = true;
  31. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  32. this.bringToFontOnClick = false;
  33. _ui.m_list.itemRenderer = RenderListItem;
  34. _ui.m_btnClose.onClick.Add(Hide);
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _month = TimeUtil.GetCurMonth();
  44. _ui.m_list.numItems = MonthlyCardClothesCfgArray.Instance.GetCfgsByyear(TimeUtil.GetCurYear()).Count;
  45. }
  46. protected override void OnHide()
  47. {
  48. base.OnHide();
  49. }
  50. protected override void RemoveEventListener()
  51. {
  52. base.RemoveEventListener();
  53. }
  54. private void RenderListItem(int index, GObject obj)
  55. {
  56. UI_ListBlackRewardtem item = UI_ListBlackRewardtem.Proxy(obj);
  57. MonthlyCardClothesCfg clothesCfg = MonthlyCardClothesCfgArray.Instance.GetCfgsByyear(TimeUtil.GetCurYear())[index];
  58. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(clothesCfg.clothesArr[0]);
  59. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  60. item.m_txtMonth.text = string.Format("{0}月", clothesCfg.month);
  61. bool isCurMonth = clothesCfg.month == _month;
  62. item.m_imgMask.visible = !isCurMonth;
  63. item.m_grpMonth.visible = isCurMonth;
  64. item.m_grpName.visible = isCurMonth;
  65. item.m_imggot.visible = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardExclusiveClothesMouth), clothesCfg.month);
  66. if (item.target.data == null)
  67. {
  68. item.target.onClick.Add(OnBtnGetClick);
  69. }
  70. item.target.data = clothesCfg.month;
  71. UI_ListBlackRewardtem.ProxyEnd();
  72. }
  73. private void OnBtnGetClick(EventContext context)
  74. {
  75. GObject obj = context.sender as GObject;
  76. int month = (int)obj.data;
  77. if (month < _month)
  78. {
  79. PromptController.Instance.ShowFloatTextPrompt("逾期单品不可领取");//奖励不可领
  80. return;
  81. }
  82. if (month > _month)
  83. {
  84. PromptController.Instance.ShowFloatTextPrompt("领取时间未到");
  85. return;
  86. }
  87. if (MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardExclusiveClothesMouth), month))
  88. {
  89. PromptController.Instance.ShowFloatTextPrompt("奖励已领取");
  90. return;
  91. }
  92. if (GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime) < TimeHelper.ServerNow())
  93. {
  94. PromptController.Instance.ShowFloatTextPrompt("开通璇玑卡可领");
  95. return;
  96. }
  97. ShopSProxy.ReqGetMonthCardItem(month).Coroutine();
  98. }
  99. }
  100. }