StoreArenaView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. _ui.m_list.itemRenderer = ListItemRenderer;
  36. _valueBarController = new ValueBarController(_ui.m_valueBar);
  37. }
  38. protected override void AddEventListener()
  39. {
  40. base.AddEventListener();
  41. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. int menu2 = (int)this.viewData;
  47. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_ARENA, menu2);
  48. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  49. _valueBarController.OnShown();
  50. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  51. UpdateView();
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. _valueBarController.OnHide();
  57. }
  58. protected override void RemoveEventListener()
  59. {
  60. base.RemoveEventListener();
  61. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  62. }
  63. private void UpdateView()
  64. {
  65. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  66. _ui.m_list.numItems = _shopCfgs.Count;
  67. }
  68. private void ListItemRenderer(int index, GObject obj)
  69. {
  70. ShopCfg shopCfg = _shopCfgs[index];
  71. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  72. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  73. ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.menu2 == 0 || shopCfg.menu2 == ArenaDataManager.Instance.SeasonId ? shopCfg.costId : shopCfg.oldSeasonCostId);
  74. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
  75. UI_ListShopItem.ProxyEnd();
  76. }
  77. }
  78. }