StoreBlackCardRewardView.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. _ui.m_comBg.GetChild("btnClose").asCom.onClick.Add(Hide);
  32. _ui.m_list.itemRenderer = RenderListItem;
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. if (TimeHelper.ClientNow() < TimeUtil.GetCurDayTime(GlobalCfgArray.globalCfg.refreshTime))
  42. {
  43. if (DateTime.Now.Month == 1)
  44. {
  45. _month = 12;
  46. }
  47. else
  48. {
  49. _month = DateTime.Now.Month - 1;
  50. }
  51. }
  52. else
  53. {
  54. _month = DateTime.Now.Month;
  55. }
  56. MonthlyCardCfg cardCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.BlackGold);
  57. _ui.m_list.numItems = cardCfg.clothesIdArr.Length;
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. }
  67. private void RenderListItem(int index, GObject obj)
  68. {
  69. MonthlyCardCfg cardCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.BlackGold);
  70. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cardCfg.clothesIdArr[index]);
  71. UI_ListBlackRewardtem item = UI_ListBlackRewardtem.Proxy(obj);
  72. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  73. item.m_txtMonth.text = string.Format("{0}月", NumberUtil.GetChiniseNumberText(index + 1));
  74. bool isCurMonth = index + 1 == _month;
  75. item.m_imgMask.visible = !isCurMonth;
  76. item.m_grpMonth.visible = isCurMonth;
  77. item.m_grpName.visible = isCurMonth;
  78. if (item.target.data == null)
  79. {
  80. item.target.onClick.Add(OnBtnGetClick);
  81. }
  82. item.target.data = _month;
  83. UI_ListBlackRewardtem.ProxyEnd();
  84. }
  85. private void OnBtnGetClick(EventContext context)
  86. {
  87. GObject obj = context.sender as GObject;
  88. int month = (int)obj.data;
  89. }
  90. }
  91. }