StoreGrowthFundView.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. using System;
  7. namespace GFGGame
  8. {
  9. public class StoreGrowthFundView : BaseWindow
  10. {
  11. private UI_StoreGrowthFundUI _ui;
  12. private ValueBarController _valueBarController;
  13. private int menu2;
  14. private EffectUI _effectUI1;
  15. public override void Dispose()
  16. {
  17. EffectUIPool.Recycle(_effectUI1);
  18. _effectUI1 = null;
  19. if (_valueBarController != null)
  20. {
  21. _valueBarController.Dispose();
  22. _valueBarController = null;
  23. }
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. }
  28. _ui = null;
  29. base.Dispose();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. packageName = UI_StoreGrowthFundUI.PACKAGE_NAME;
  35. _ui = UI_StoreGrowthFundUI.Create();
  36. this.viewCom = _ui.target;
  37. isfullScreen = true;
  38. this.clickBlankToClose = false;
  39. this.bringToFontOnClick = false;
  40. _valueBarController = new ValueBarController(_ui.m_valueBar);
  41. _ui.m_list.itemRenderer = ListItemRenderer;
  42. _ui.m_btnBuy.target.onClick.Add(OnBtnBuyClick);
  43. }
  44. protected override void AddEventListener()
  45. {
  46. base.AddEventListener();
  47. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  48. }
  49. protected override void OnShown()
  50. {
  51. base.OnShown();
  52. _valueBarController.OnShown();
  53. UpdateView();
  54. UpdateRedDot();
  55. }
  56. protected override void OnHide()
  57. {
  58. base.OnHide();
  59. _valueBarController.OnHide();
  60. }
  61. protected override void RemoveEventListener()
  62. {
  63. base.RemoveEventListener();
  64. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  65. }
  66. private void OnBtnBlackRewardClick()
  67. {
  68. ViewManager.Show<StoreBlackCardRewardView>();
  69. }
  70. private void UpdateView()
  71. {
  72. _ui.m_btnBuy.m_c1.selectedIndex = RedDotDataManager.Instance.GetGrowthFundBuy()?0:1;
  73. int count = 0;
  74. for(int i = 0;i < GrowthFundCfgArray.Instance.dataArray.Length;i++)
  75. {
  76. if(RoleDataManager.lvl >= GrowthFundCfgArray.Instance.dataArray[i].level)
  77. {
  78. count += GrowthFundCfgArray.Instance.dataArray[i].bonusArr[0][1];
  79. }
  80. }
  81. _ui.m_txtGiftBag.text = count.ToString();
  82. _ui.m_list.numItems = GrowthFundCfgArray.Instance.dataArray.Length;
  83. }
  84. private void OnBtnBuyClick()
  85. {
  86. //是否购买
  87. if (RedDotDataManager.Instance.GetGrowthFundBuy())
  88. {
  89. int id = ActivityOpenCfgArray.Instance.GetCfg(3002).paramsArr[0];
  90. ShopSProxy.ReqShopBuy(id).Coroutine();
  91. _ui.m_btnBuy.m_c1.selectedIndex = 1;
  92. _ui.m_list.numItems = GrowthFundCfgArray.Instance.dataArray.Length;
  93. }
  94. }
  95. private async void OnBtnGetClick(EventContext context)
  96. {
  97. GObject obj = context.sender as GObject;
  98. int goodsId = (int)obj.data;
  99. UI_GrowthFundItemUI item = UI_GrowthFundItemUI.Proxy(_ui.m_list.GetChildAt(goodsId - 1));
  100. if(item.m_rewardBtn.m_c1.selectedIndex != 1)
  101. {
  102. return;
  103. }
  104. UI_GrowthFundItemUI.ProxyEnd();
  105. bool result = await ShopSProxy.ReqGetGrowthFundReward(3002,goodsId);
  106. if (result)
  107. {
  108. _ui.m_list.numItems = GrowthFundCfgArray.Instance.dataArray.Length;
  109. }
  110. }
  111. private void ListItemRenderer(int index, GObject obj)
  112. {
  113. UI_GrowthFundItemUI item = UI_GrowthFundItemUI.Proxy(obj);
  114. int num = GrowthFundCfgArray.Instance.dataArray[index].level;
  115. item.m_rewardDesc.text = string.Format("等级达{0}级可领",num);
  116. item.m_rewardBtn.m_c1.selectedIndex = 1;
  117. if (!RedDotDataManager.Instance.GetGrowthFundBuy())
  118. {
  119. bool isRed = true;
  120. if(RoleDataManager.lvl >= num)
  121. {
  122. foreach (int i in ShopDataManager.Instance.GrowthFundRewardList)
  123. {
  124. if (i == GrowthFundCfgArray.Instance.dataArray[index].id)
  125. {
  126. item.m_rewardBtn.m_c1.selectedIndex = 2;
  127. isRed = false;
  128. break;
  129. }
  130. }
  131. }
  132. else
  133. {
  134. item.m_rewardBtn.m_c1.selectedIndex = 0;
  135. isRed = false;
  136. }
  137. RedDotController.Instance.SetComRedDot(item.m_rewardBtn.target, isRed);
  138. }
  139. else
  140. {
  141. item.m_rewardBtn.m_c1.selectedIndex = 0;
  142. RedDotController.Instance.SetComRedDot(item.m_rewardBtn.target, false);
  143. }
  144. ItemUtil.CreateItemView(GrowthFundCfgArray.Instance.dataArray[index].bonusArr[0], item.m_reward as GComponent);
  145. if (item.m_rewardBtn.target.data == null)
  146. {
  147. item.m_rewardBtn.target.onClick.Add(OnBtnGetClick);
  148. }
  149. item.m_rewardBtn.target.data = index + 1;
  150. UI_GrowthFundItemUI.ProxyEnd();
  151. }
  152. private void UpdateRedDot()
  153. {
  154. }
  155. }
  156. }