StoreExchangeView.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 StoreExchangeView : 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_EXCHANGE, menu2);
  48. _valueBarController.OnShown();
  49. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  50. UpdateView();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. _valueBarController.OnHide();
  56. }
  57. protected override void RemoveEventListener()
  58. {
  59. base.RemoveEventListener();
  60. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  61. }
  62. private void UpdateView()
  63. {
  64. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  65. _ui.m_list.numItems = _shopCfgs.Count;
  66. }
  67. private void ListItemRenderer(int index, GObject obj)
  68. {
  69. ShopCfg shopCfg = _shopCfgs[index];
  70. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  71. }
  72. }
  73. }