StoreBlackCardRewardView.cs 4.1 KB

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