StoreArenaView.cs 2.9 KB

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