BlindBoxRewardView.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. private const int _blindBoxId = 3;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_BlindBoxRewardUI.PACKAGE_NAME;
  27. _ui = UI_BlindBoxRewardUI.Create();
  28. this.viewCom = _ui.target;
  29. modal = true;
  30. this.viewCom.Center();
  31. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  32. _ui.m_normalList.itemRenderer = NormalRewardList;
  33. _ui.m_specialList.itemRenderer = SpecialRewardList;
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. BlindBoxCfg blindBoxCfg = BlindBoxCfgArray.Instance.GetCfg(_blindBoxId);
  39. int id1 = blindBoxCfg.OrdinaryDropDisplay; //(int)(this.viewData as object[])[0];
  40. int id2 = blindBoxCfg.HideDropDisplay; //(int)(this.viewData as object[])[1];
  41. _rewardNormal = DropOutCfgArray.Instance.GetCfgsByid(id1);
  42. _ui.m_normalList.numItems = _rewardNormal.Count;
  43. _rewardSpecial = DropOutCfgArray.Instance.GetCfgsByid(id2);
  44. _ui.m_specialList.numItems = _rewardSpecial.Count;
  45. }
  46. protected override void OnHide()
  47. {
  48. base.OnHide();
  49. }
  50. protected override void AddEventListener()
  51. {
  52. base.AddEventListener();
  53. }
  54. protected override void RemoveEventListener()
  55. {
  56. base.RemoveEventListener();
  57. }
  58. private void NormalRewardList(int index, GObject obj)
  59. {
  60. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  61. int id = _rewardNormal[index].item;
  62. ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(id);
  63. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  64. item.m_name.text = itemcfg.name;
  65. if (item.target.data == null)
  66. {
  67. item.target.onClick.Add(OnClickItem);
  68. }
  69. item.target.data = id;
  70. UI_Itemitem.ProxyEnd();
  71. }
  72. private void SpecialRewardList(int index, GObject obj)
  73. {
  74. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  75. int id = _rewardSpecial[index].item;
  76. ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(id);
  77. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  78. item.m_name.text = itemcfg.name;
  79. if (item.target.data == null)
  80. {
  81. item.target.onClick.Add(OnClickItem);
  82. }
  83. item.target.data = id;
  84. UI_Itemitem.ProxyEnd();
  85. }
  86. private void OnClickItem(EventContext context)
  87. {
  88. GObject obj = context.sender as GObject;
  89. int id = (int)obj.data;
  90. GoodsItemTipsController.ShowItemTips(id);
  91. }
  92. }
  93. }