BlindBoxRewardView.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using FairyGUI;
  2. using UI.BlindBox;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using cfg.GfgCfg;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class BlindBoxRewardView : BaseWindow
  11. {
  12. private UI_BlindBoxRewardUI _ui;
  13. private List<DropOutCfg> _rewardNormal = null;
  14. private List<DropOutCfg> _rewardSpecial = null;
  15. public override void Dispose()
  16. {
  17. if (_ui != null)
  18. {
  19. _ui.Dispose();
  20. _ui = null;
  21. }
  22. base.Dispose();
  23. }
  24. protected override void OnInit()
  25. {
  26. base.OnInit();
  27. packageName = UI_BlindBoxRewardUI.PACKAGE_NAME;
  28. _ui = UI_BlindBoxRewardUI.Create();
  29. this.viewCom = _ui.target;
  30. modal = true;
  31. this.viewCom.Center();
  32. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  33. _ui.m_normalList.itemRenderer = NormalRewardList;
  34. _ui.m_specialList.itemRenderer = SpecialRewardList;
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. BlindBoxCfg blindBoxCfg = CommonDataManager.Tables.TblBlindBoxCfg.GetOrDefault(2);
  40. int id1 = blindBoxCfg.OrdinaryDropDisplay; //(int)(this.viewData as object[])[0];
  41. int id2 = blindBoxCfg.HideDropDisplay; //(int)(this.viewData as object[])[1];
  42. _rewardNormal = CommonDataManager.Tables.TblDropOutCfg.DataList.Where(a => a.Id == id1).ToList();
  43. _ui.m_normalList.numItems = _rewardNormal.Count;
  44. _rewardSpecial = CommonDataManager.Tables.TblDropOutCfg.DataList.Where(a => a.Id == id2).ToList();
  45. _ui.m_specialList.numItems = _rewardSpecial.Count;
  46. }
  47. protected override void OnHide()
  48. {
  49. base.OnHide();
  50. }
  51. protected override void AddEventListener()
  52. {
  53. base.AddEventListener();
  54. }
  55. protected override void RemoveEventListener()
  56. {
  57. base.RemoveEventListener();
  58. }
  59. private void NormalRewardList(int index, GObject obj)
  60. {
  61. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  62. int id = _rewardNormal[index].Item;
  63. ItemCfg itemcfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  64. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  65. item.m_name.text = itemcfg.Name;
  66. if (item.target.data == null)
  67. {
  68. item.target.onClick.Add(OnClickItem);
  69. }
  70. item.target.data = id;
  71. UI_Itemitem.ProxyEnd();
  72. }
  73. private void SpecialRewardList(int index, GObject obj)
  74. {
  75. UI_Itemitem item = UI_Itemitem.Proxy(obj);
  76. int id = _rewardSpecial[index].Item;
  77. ItemCfg itemcfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  78. item.m_icon.url = ResPathUtil.GetIconPath(itemcfg);
  79. item.m_name.text = itemcfg.Name;
  80. if (item.target.data == null)
  81. {
  82. item.target.onClick.Add(OnClickItem);
  83. }
  84. item.target.data = id;
  85. UI_Itemitem.ProxyEnd();
  86. }
  87. private void OnClickItem(EventContext context)
  88. {
  89. GObject obj = context.sender as GObject;
  90. int id = (int)obj.data;
  91. GoodsItemTipsController.ShowItemTips(id);
  92. }
  93. }
  94. }