StoreBlackCardRewardView.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. _month = TimeUtil.GetCurMonth();
  42. _ui.m_list.numItems = MonthlyCardClothesCfgArray.Instance.GetCfgsByyear(TimeUtil.GetCurYear()).Count;
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. }
  48. protected override void RemoveEventListener()
  49. {
  50. base.RemoveEventListener();
  51. }
  52. private void RenderListItem(int index, GObject obj)
  53. {
  54. UI_ListBlackRewardtem item = UI_ListBlackRewardtem.Proxy(obj);
  55. MonthlyCardClothesCfg clothesCfg = MonthlyCardClothesCfgArray.Instance.GetCfgsByyear(TimeUtil.GetCurYear())[index];
  56. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(clothesCfg.clothesArr[0]);
  57. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  58. item.m_txtMonth.text = string.Format("{0}月", clothesCfg.month);
  59. bool isCurMonth = clothesCfg.month == _month;
  60. item.m_imgMask.visible = !isCurMonth;
  61. item.m_grpMonth.visible = isCurMonth;
  62. item.m_grpName.visible = isCurMonth;
  63. if (item.target.data == null)
  64. {
  65. item.target.onClick.Add(OnBtnGetClick);
  66. }
  67. item.target.data = clothesCfg.month;
  68. UI_ListBlackRewardtem.ProxyEnd();
  69. }
  70. private void OnBtnGetClick(EventContext context)
  71. {
  72. GObject obj = context.sender as GObject;
  73. int month = (int)obj.data;
  74. }
  75. }
  76. }