StoreArenaView.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 List<ShopCfg> _shopCfgs;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. }
  18. _ui = null;
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_StoreExchangeUI.PACKAGE_NAME;
  25. _ui = UI_StoreExchangeUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. this.clickBlankToClose = false;
  29. _ui.m_list.itemRenderer = ListItemRenderer;
  30. }
  31. protected override void AddEventListener()
  32. {
  33. base.AddEventListener();
  34. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. int menu2 = (int)this.viewData;
  40. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_ARENA, menu2);
  41. UpdateView();
  42. }
  43. protected override void OnHide()
  44. {
  45. base.OnHide();
  46. }
  47. protected override void RemoveEventListener()
  48. {
  49. base.RemoveEventListener();
  50. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  51. }
  52. private void UpdateView()
  53. {
  54. _shopCfgs = ShopDataManager.Instance.SortGiftBagCfgs(_shopCfgs);
  55. _ui.m_list.numItems = _shopCfgs.Count;
  56. }
  57. private void ListItemRenderer(int index, GObject obj)
  58. {
  59. ShopCfg shopCfg = _shopCfgs[index];
  60. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  61. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  62. ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.menu2 == 0 || shopCfg.menu2 == ArenaDataManager.Instance.SeasonId ? shopCfg.costId : shopCfg.oldSeasonCostId);
  63. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
  64. UI_ListShopItem.ProxyEnd();
  65. }
  66. }
  67. }