StoreArenaView.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using cfg.GfgCfg;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class StoreArenaView : BaseWindow
  11. {
  12. private UI_StoreExchangeUI _ui;
  13. private ValueBarController _valueBarController;
  14. private List<ShopCfg> _shopCfgs;
  15. public override void Dispose()
  16. {
  17. if (_valueBarController != null)
  18. {
  19. _valueBarController.Dispose();
  20. _valueBarController = null;
  21. }
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. }
  26. _ui = null;
  27. base.Dispose();
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. packageName = UI_StoreExchangeUI.PACKAGE_NAME;
  33. _ui = UI_StoreExchangeUI.Create();
  34. this.viewCom = _ui.target;
  35. isfullScreen = true;
  36. this.clickBlankToClose = false;
  37. this.bringToFontOnClick = false;
  38. _ui.m_storeExchangeList.m_list.itemRenderer = ListItemRenderer;
  39. _valueBarController = new ValueBarController(_ui.m_valueBar);
  40. }
  41. protected override void AddEventListener()
  42. {
  43. base.AddEventListener();
  44. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. int menu2 = (int)this.viewData;
  50. _shopCfgs = CommonDataManager.Tables.TblShopCfg.DataList
  51. .Where(a => a.Menu1 == ConstStoreTabId.STORE_ARENA && a.Menu2 == menu2).ToList();
  52. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  53. _valueBarController.OnShown();
  54. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  55. UpdateView();
  56. }
  57. protected override void OnHide()
  58. {
  59. base.OnHide();
  60. ShopViewManager.Instance.ClearItemEff();
  61. _valueBarController.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  67. }
  68. private void UpdateView()
  69. {
  70. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  71. ShopViewManager.Instance.ClearItemEff();
  72. _ui.m_storeExchangeList.m_list.numItems = _shopCfgs.Count;
  73. }
  74. private void ListItemRenderer(int index, GObject obj)
  75. {
  76. ShopCfg shopCfg = _shopCfgs[index];
  77. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  78. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  79. ItemCfg costItemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(
  80. shopCfg.Menu2 == 0 || shopCfg.Menu2 == ArenaDataManager.Instance.SeasonId
  81. ? shopCfg.CostIdReal
  82. : shopCfg.OldSeasonCostId);
  83. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(costItemCfg.Res);
  84. UI_ListShopItem.ProxyEnd();
  85. }
  86. }
  87. }