BlindBoxRewardView.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using FairyGUI;
  2. using UI.BlindBox;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class BlindBoxRewardView : BaseWindow
  9. {
  10. private UI_BlindBoxRewardUI _ui;
  11. private List<DropOutCfg> _rewardNormal = null;
  12. private List<DropOutCfg> _rewardSpecial = null;
  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_BlindBoxRewardUI.PACKAGE_NAME;
  26. _ui = UI_BlindBoxRewardUI.Create();
  27. this.viewCom = _ui.target;
  28. modal = true;
  29. this.viewCom.Center();
  30. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  31. _ui.m_normalList.itemRenderer = NormalRewardList;
  32. _ui.m_specialList.itemRenderer = SpecialRewardList;
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. BlindBoxCfg blindBoxCfg = BlindBoxCfgArray.Instance.GetCfg(2);
  38. int id1 = blindBoxCfg.OrdinaryDropDisplay; //(int)(this.viewData as object[])[0];
  39. int id2 = blindBoxCfg.HideDropDisplay; //(int)(this.viewData as object[])[1];
  40. _rewardNormal = DropOutCfgArray.Instance.GetCfgsByid(id1);
  41. _ui.m_normalList.numItems = _rewardNormal.Count;
  42. _rewardSpecial = DropOutCfgArray.Instance.GetCfgsByid(id2);
  43. _ui.m_specialList.numItems = _rewardSpecial.Count;
  44. }
  45. protected override void OnHide()
  46. {
  47. base.OnHide();
  48. }
  49. protected override void AddEventListener()
  50. {
  51. base.AddEventListener();
  52. }
  53. protected override void RemoveEventListener()
  54. {
  55. base.RemoveEventListener();
  56. }
  57. private void NormalRewardList(int index, GObject obj)
  58. {
  59. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  60. int id = _rewardNormal[index].item;
  61. ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(id);
  62. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  63. item.m_name.text = itemcfg.name;
  64. if (item.target.data == null)
  65. {
  66. item.target.onClick.Add(OnClickItem);
  67. }
  68. item.target.data = id;
  69. UI_Itemitem.ProxyEnd();
  70. }
  71. private void SpecialRewardList(int index, GObject obj)
  72. {
  73. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  74. int id = _rewardSpecial[index].item;
  75. ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(id);
  76. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  77. item.m_name.text = itemcfg.name;
  78. if (item.target.data == null)
  79. {
  80. item.target.onClick.Add(OnClickItem);
  81. }
  82. item.target.data = id;
  83. UI_Itemitem.ProxyEnd();
  84. }
  85. private void OnClickItem(EventContext context)
  86. {
  87. GObject obj = context.sender as GObject;
  88. int id = (int)obj.data;
  89. GoodsItemTipsController.ShowItemTips(id);
  90. }
  91. }
  92. }