StoreGiftBagView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 StoreGiftBagView : BaseWindow
  9. {
  10. private UI_StoreGiftBagUI _ui;
  11. private ValueBarController _valueBarController;
  12. private List<ShopCfg> _shopCfgs;
  13. private int menu2;
  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_StoreGiftBagUI.PACKAGE_NAME;
  32. _ui = UI_StoreGiftBagUI.Create();
  33. this.viewCom = _ui.target;
  34. isfullScreen = true;
  35. this.clickBlankToClose = false;
  36. this.bringToFontOnClick = false;
  37. _ui.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. menu2 = (int)this.viewData;
  49. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_GIFT_BAG, 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. _ui.m_list.numItems = _shopCfgs.Count;
  70. }
  71. private void ListItemRenderer(int index, GObject obj)
  72. {
  73. ShopCfg shopCfg = _shopCfgs[index];
  74. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  75. RedDotController.Instance.SetComRedDot(obj.asCom, menu2 == ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY && shopCfg.price == 0 && ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.maxBuyNum, "", 0, 70);
  76. }
  77. }
  78. }