StoreExchangeView.cs 2.7 KB

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