StoreBlackCardRewardView.cs 4.2 KB

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