StoreBlackCardRewardView.cs 3.5 KB

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