StoreGrowthFundView.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  49. }
  50. protected override void OnShown()
  51. {
  52. base.OnShown();
  53. _valueBarController.OnShown();
  54. _ui.m_txtDailyMoneyCount.text = "4800";
  55. UpdateView();
  56. UpdateRedDot();
  57. }
  58. protected override void OnHide()
  59. {
  60. base.OnHide();
  61. _valueBarController.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  67. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  68. }
  69. private void OnBtnBlackRewardClick()
  70. {
  71. ViewManager.Show<StoreBlackCardRewardView>();
  72. }
  73. private void UpdateView()
  74. {
  75. GetGrowthFundBuy();
  76. int count = 0;
  77. for(int i = 0;i < GrowthFundCfgArray.Instance.dataArray.Length;i++)
  78. {
  79. if(RoleDataManager.lvl >= GrowthFundCfgArray.Instance.dataArray[i].level)
  80. {
  81. count += GrowthFundCfgArray.Instance.dataArray[i].bonusArr[0][1];
  82. }
  83. }
  84. _ui.m_txtGiftBag.text = count.ToString();
  85. _ui.m_list.numItems = GrowthFundCfgArray.Instance.dataArray.Length;
  86. }
  87. private void OnBtnBuyClick()
  88. {
  89. //是否购买
  90. if (!GetGrowthFundBuy())
  91. {
  92. int id = ActivityOpenCfgArray.Instance.GetCfg(3002).paramsArr[0];
  93. ShopSProxy.ReqShopBuy(id).Coroutine();
  94. ShopSProxy.ReqGetGrowthFundInfo().Coroutine();
  95. }
  96. }
  97. private async void OnBtnGetClick(EventContext context)
  98. {
  99. GObject obj = context.sender as GObject;
  100. int goodsId = (int)obj.data;
  101. UI_GrowthFundItemUI item = UI_GrowthFundItemUI.Proxy(_ui.m_list.GetChildAt(goodsId - 1));
  102. if(item.m_rewardBtn.m_c1.selectedIndex != 1)
  103. {
  104. return;
  105. }
  106. UI_GrowthFundItemUI.ProxyEnd();
  107. bool result = await ShopSProxy.ReqGetGrowthFundReward(3002,goodsId);
  108. _ui.m_list.numItems = GrowthFundCfgArray.Instance.dataArray.Length;
  109. }
  110. private void ListItemRenderer(int index, GObject obj)
  111. {
  112. UI_GrowthFundItemUI item = UI_GrowthFundItemUI.Proxy(obj);
  113. int num = GrowthFundCfgArray.Instance.dataArray[index].level;
  114. item.m_rewardDesc.text = string.Format("等级达{0}级可领",num);
  115. item.m_rewardBtn.m_c1.selectedIndex = 1;
  116. if (GetGrowthFundBuy())
  117. {
  118. bool isRed = true;
  119. if(RoleDataManager.lvl >= num)
  120. {
  121. foreach (int i in ShopDataManager.Instance.GrowthFundRewardList)
  122. {
  123. if (i == GrowthFundCfgArray.Instance.dataArray[index].id)
  124. {
  125. item.m_rewardBtn.m_c1.selectedIndex = 2;
  126. isRed = false;
  127. break;
  128. }
  129. }
  130. }
  131. else
  132. {
  133. item.m_rewardBtn.m_c1.selectedIndex = 0;
  134. isRed = false;
  135. }
  136. RedDotController.Instance.SetComRedDot(item.m_rewardBtn.target, isRed);
  137. }
  138. else
  139. {
  140. item.m_rewardBtn.m_c1.selectedIndex = 0;
  141. RedDotController.Instance.SetComRedDot(item.m_rewardBtn.target, false);
  142. }
  143. ItemUtil.CreateItemView(GrowthFundCfgArray.Instance.dataArray[index].bonusArr[0], item.m_reward as GComponent);
  144. if (item.m_rewardBtn.target.data == null)
  145. {
  146. item.m_rewardBtn.target.onClick.Add(OnBtnGetClick);
  147. }
  148. item.m_rewardBtn.target.data = index + 1;
  149. UI_GrowthFundItemUI.ProxyEnd();
  150. }
  151. private bool GetGrowthFundBuy()
  152. {
  153. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(ActivityOpenCfgArray.Instance.GetCfg(3002).paramsArr[0]);
  154. var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  155. if (remainBuyNum == 0)
  156. {
  157. //已售完
  158. _ui.m_btnBuy.m_c1.selectedIndex = 1;
  159. return true;
  160. }
  161. else
  162. {
  163. //未售完
  164. _ui.m_btnBuy.m_c1.selectedIndex = 0;
  165. return false;
  166. }
  167. }
  168. private void UpdateRedDot()
  169. {
  170. }
  171. }
  172. }