StoreBlackCardRewardView.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. if (clothesCfg.clothesArr.Length == 0)
  59. {
  60. item.m_showItemType.selectedIndex = 1;
  61. }
  62. else {
  63. item.m_showItemType.selectedIndex = 0;
  64. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(clothesCfg.clothesArr[0]);
  65. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  66. item.m_txtMonth.text = string.Format("{0}月", clothesCfg.month);
  67. bool isCurMonth = clothesCfg.month == _month;
  68. item.m_imgMask.visible = !isCurMonth;
  69. item.m_grpMonth.visible = isCurMonth;
  70. item.m_grpName.visible = isCurMonth;
  71. item.m_imggot.visible = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardExclusiveClothesMouth), clothesCfg.month);
  72. if (item.target.data == null)
  73. {
  74. item.target.onClick.Add(OnBtnGetClick);
  75. }
  76. item.target.data = clothesCfg.month;
  77. }
  78. UI_ListBlackRewardtem.ProxyEnd();
  79. }
  80. private void OnBtnGetClick(EventContext context)
  81. {
  82. GObject obj = context.sender as GObject;
  83. int month = (int)obj.data;
  84. if (month < _month)
  85. {
  86. PromptController.Instance.ShowFloatTextPrompt("逾期单品不可领取");//奖励不可领
  87. return;
  88. }
  89. if (month > _month)
  90. {
  91. PromptController.Instance.ShowFloatTextPrompt("领取时间未到");
  92. return;
  93. }
  94. if (MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardExclusiveClothesMouth), month))
  95. {
  96. PromptController.Instance.ShowFloatTextPrompt("奖励已领取");
  97. return;
  98. }
  99. if (GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime) < TimeHelper.ServerNow())
  100. {
  101. PromptController.Instance.ShowFloatTextPrompt("开通阿福卡可领");
  102. return;
  103. }
  104. ShopSProxy.ReqGetMonthCardItem(month).Coroutine();
  105. }
  106. }
  107. }