EnduringGiftBoxView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using ET;
  5. using FairyGUI;
  6. using UI.EnduringGiftBox;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class EnduringGiftBoxView : BaseWindow
  11. {
  12. private UI_EnduringGiftBoxUI _ui;
  13. private int _itemId; //道具id,该页面目前只给:体力,金币使用
  14. private int _count; //本次购买次数
  15. private int _buyTimes = 0; //已购次数
  16. private int _type = 0; //0从别的地方跳转过来. 1从点击TOP菜单栏icon跳转过来
  17. private Action _onSuccess;
  18. private int _maxTimes = 0;
  19. private string _message = "";
  20. private List<ShopCfg> _shopCfgList = new List<ShopCfg>();
  21. private EffectUI _effectUI1;
  22. private EffectUI _effectUI2;
  23. private EffectUI _effectUI3;
  24. private EffectUI _effectUI4;
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_EnduringGiftBoxUI.PACKAGE_NAME;
  29. _ui = UI_EnduringGiftBoxUI.Create();
  30. this.viewCom = _ui.target;
  31. this.viewCom.Center();
  32. this.modal = true;
  33. viewAnimationType = EnumViewAnimationType.None;
  34. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  35. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  36. _ui.m_btnBack.onClick.Add(OnClickBtnCancel);
  37. }
  38. public override void Dispose()
  39. {
  40. if (_ui != null)
  41. {
  42. _ui.Dispose();
  43. _ui = null;
  44. }
  45. EnduringGiftBoxController.Dispose();
  46. base.Dispose();
  47. }
  48. protected override void OnShown()
  49. {
  50. base.OnShown();
  51. AddEffect();
  52. _ui.m_t1.Play();
  53. _ui.m_t2.Play();
  54. _ui.m_t3.Play(CheckGuide);
  55. UpdateView();
  56. }
  57. protected override void AddEventListener()
  58. {
  59. base.AddEventListener();
  60. EventAgent.AddEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, UpDayRebateAndView);
  61. EventAgent.AddEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT, UpdateView);
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. EventAgent.RemoveEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, UpDayRebateAndView);
  66. EventAgent.RemoveEventListener(ConstMessage.CONTINUOUS_REBATE_GIFT, UpdateView);
  67. base.RemoveEventListener();
  68. }
  69. private void AddEffect()
  70. {
  71. //小人
  72. if (_itemId == ConstItemID.POWER)
  73. {
  74. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderBaby, "ui_Activity", "Activity_people02");
  75. }
  76. else
  77. {
  78. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderBaby, "ui_Activity", "Activity_people01");
  79. }
  80. //爆发,大泡泡
  81. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderPaoMax, "ui_Activity", "Activity_baofa");
  82. //持续的小泡泡
  83. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holderPaoMin, "ui_Activity", "Activity_chixu");
  84. //爆发时候的发光
  85. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_holderFg, "ui_Activity", "Activity_glow");
  86. }
  87. public void SetParams(int itemId, int count, Action onSuccess, string message = "", int type = 0)
  88. {
  89. _itemId = itemId;
  90. _count = count;
  91. _onSuccess = onSuccess;
  92. _message = message;
  93. _type = type;
  94. }
  95. private void UpdateView()
  96. {
  97. _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
  98. ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
  99. out int buyNum);
  100. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
  101. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
  102. _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
  103. _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
  104. string showTxt = string.Empty;
  105. _shopCfgList.Clear();
  106. //常驻礼包
  107. if (_itemId == ConstItemID.POWER)
  108. {
  109. //体力礼包
  110. _shopCfgList = ShopCfgArray.Instance
  111. .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_POWER)
  112. .OrderBy(a => a.refreshType).ToList();
  113. _ui.m_txtNeed.align = AlignType.Center;
  114. int maxLimit = ItemExchangeCfgArray.Instance.GetCfg(ConstItemID.POWER).maxLimit;
  115. int lastBuyCount = maxLimit - ItemDataManager.GetItemExchangeTimes(ConstItemID.POWER);
  116. showTxt = string.Format("每5分钟回复1点体力\n今日剩余购买次数{0}/{1}次", lastBuyCount, maxLimit);
  117. }
  118. else
  119. {
  120. //金币礼包
  121. _shopCfgList = ShopCfgArray.Instance
  122. .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_GOLD)
  123. .OrderBy(a => a.refreshType).ToList();
  124. _ui.m_txtNeed.align = AlignType.Right;
  125. if (_maxTimes != 0)
  126. {
  127. showTxt = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
  128. }
  129. }
  130. _ui.m_txtNum.text = showTxt;
  131. _ui.m_txtPromptExt.text = string.Format("除了上述购买{0}的途径,我们还提供了更多的优惠礼包选择", itemCfg.name);
  132. _ui.m_list.itemRenderer = ListItemRender;
  133. _ui.m_list.numItems = _shopCfgList.Count;
  134. _ui.m_list.visible = true;
  135. }
  136. // ReSharper disable Unity.PerformanceAnalysis
  137. private void ListItemRender(int index, GObject obj)
  138. {
  139. ShopCfg shopCfg = _shopCfgList[index];
  140. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); //购买的物品-礼包
  141. UI_ComCurSupplyItem item = UI_ComCurSupplyItem.Proxy(obj);
  142. item.target.data = shopCfg;
  143. //返利包
  144. item.m_txtTitle.text = itemCfg.name;
  145. item.m_txtWeekPrompt.visible = false;
  146. item.m_btnIcoWeekPromptTag.visible = false;
  147. if (itemCfg.param2Arr.Length != 0)
  148. {
  149. item.m_txtWeekPrompt.visible = true;
  150. item.m_btnIcoWeekPromptTag.visible = true;
  151. item.m_txtWeekPrompt.text = string.Format("连续{0}天每日获得", itemCfg.param2Arr[0]);
  152. }
  153. int numItems;
  154. var childItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  155. var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  156. item.m_comLeftGiftBox.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  157. item.m_btnBuy.m_txtOldPrice.text = $"{shopCfg.originalPrice}";
  158. item.m_btnBuy.m_loaIcon.visible = false;
  159. string mTxtOldPrice = string.Empty;
  160. if (shopCfg.costType == CostType.ITEM)
  161. {
  162. //货币
  163. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId);
  164. item.m_btnBuy.m_loaIcon.visible = true;
  165. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetIconPath(costCfg);
  166. }
  167. else if (shopCfg.costType == CostType.RMB)
  168. {
  169. //人民币
  170. mTxtOldPrice = "元";
  171. }
  172. else
  173. {
  174. //免费
  175. mTxtOldPrice = $"免费";
  176. item.m_btnBuy.m_txtOldPrice.text = "";
  177. item.m_btnBuy.m_txtNewPrice.align = AlignType.Left;
  178. item.m_btnBuy.m_txtNewPrice.x = 90;
  179. }
  180. item.m_btnBuy.m_txtNewPrice.text = $"{shopCfg.price + mTxtOldPrice}";
  181. item.m_comLeftGiftBox.target.data = itemCfg;
  182. item.m_comLeftGiftBox.m_loaIcon.onClick.Add(OnListSelectorItemClick);
  183. if (shopCfg.originalPrice != shopCfg.price)
  184. {
  185. var roundedNumStr = NumberUtil.CalculateDiscount(shopCfg.originalPrice, shopCfg.price);
  186. item.m_comLeftGiftBox.m_comDiscount.target.visible = true;
  187. item.m_comLeftGiftBox.m_comDiscount.m_txtDiscountNum.text = $"{roundedNumStr}折"; //之后再计算赋值
  188. }
  189. else
  190. {
  191. item.m_comLeftGiftBox.m_comDiscount.target.visible = false;
  192. }
  193. if (shopCfg.refreshType == RefreshType.DAY) //也可以换成人民币来做条件
  194. {
  195. //日刷
  196. item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = false;
  197. item.m_txtUrc.text = string.Format("今日剩余{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
  198. item.m_txtLrc.text = string.Format("可获得{0}会员积分", shopCfg.price * 10);
  199. item.m_txtWeekPrompt.visible = false;
  200. item.m_btnIcoWeekPromptTag.visible = false;
  201. numItems = childItemCfg.itemsArr.Length;
  202. if (remainBuyNum == 0)
  203. {
  204. //已售完
  205. item.m_btnBuy.target.visible = true;
  206. item.m_btnCurReceive.target.visible = false;
  207. item.m_btnBuy.m_bagYellow.visible = false;
  208. item.m_btnBuy.m_bagGrey.visible = true;
  209. }
  210. else
  211. {
  212. //未售完
  213. item.m_btnBuy.target.visible = true;
  214. item.m_btnCurReceive.target.visible = false;
  215. item.m_btnBuy.m_bagYellow.visible = true;
  216. item.m_btnBuy.m_bagGrey.visible = false;
  217. }
  218. }
  219. else
  220. {
  221. //周刷
  222. var weekGiftBoxState = EnduringGiftBoxDataManager.Instance.DayIsRebateGiftBox(shopCfg.itemId);
  223. item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = true;
  224. var itemArr = itemCfg.itemsArr[0];
  225. ItemCfg getItemCfg = ItemCfgArray.Instance.GetCfg(itemArr[0]); //及时获得的物品,读取第一个显示ICON
  226. item.m_comLeftGiftBox.m_comGouMaiGetText.m_loaIcon.url = ResPathUtil.GetIconPath(getItemCfg);
  227. item.m_comLeftGiftBox.m_comGouMaiGetText.m_txtGetGold.text = itemArr[1].ToString();
  228. item.m_txtUrc.text = string.Format("每周限购{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
  229. int rebateDay = EnduringGiftBoxDataManager.Instance.GetItemRebateDay(itemCfg.id);
  230. string mTxtLrc = string.Empty;
  231. if (rebateDay != 0)
  232. {
  233. mTxtLrc = string.Format("剩余{0}天", rebateDay);
  234. }
  235. item.m_txtLrc.text = mTxtLrc;
  236. item.m_txtWeekPrompt.visible = true;
  237. item.m_txtWeekPrompt.text =
  238. string.Format("连续{0}天每日获得",
  239. itemCfg.param2Arr[0] + 1); //NumberUtil.GetChiniseNumberText(itemCfg.param2Arr[0])
  240. item.m_btnIcoWeekPromptTag.visible = true;
  241. numItems = childItemCfg.param1Arr.Length;
  242. //领取加红点
  243. RedDotController.Instance.SetComRedDot(item.m_btnCurReceive.target, weekGiftBoxState);
  244. //是否需要领取
  245. if (weekGiftBoxState)
  246. {
  247. item.m_btnBuy.target.visible = false;
  248. item.m_btnCurReceive.target.visible = true;
  249. item.m_btnCurReceive.m_receive.visible = true;
  250. item.m_btnCurReceive.m_received.visible = false;
  251. item.m_btnCurReceive.m_txtRec.text = "领取";
  252. }
  253. else
  254. {
  255. //是否能购买
  256. if (remainBuyNum == 0)
  257. {
  258. //已经领取
  259. if (EnduringGiftBoxDataManager.Instance.DayRebateItemIds.Contains(shopCfg.itemId))
  260. {
  261. item.m_btnBuy.target.visible = false;
  262. item.m_btnCurReceive.target.visible = true;
  263. item.m_btnCurReceive.m_receive.visible = false;
  264. item.m_btnCurReceive.m_received.visible = true;
  265. item.m_btnCurReceive.m_txtRec.text = "已领取";
  266. }
  267. else
  268. {
  269. item.m_btnCurReceive.target.visible = false;
  270. item.m_btnBuy.target.visible = true;
  271. item.m_btnBuy.m_bagGrey.visible = true;
  272. item.m_btnBuy.m_bagYellow.visible = false;
  273. }
  274. }
  275. else
  276. {
  277. //未售完
  278. item.m_btnBuy.target.visible = true;
  279. item.m_btnBuy.m_bagGrey.visible = false;
  280. item.m_btnBuy.m_bagYellow.visible = true;
  281. item.m_btnCurReceive.target.visible = false;
  282. }
  283. }
  284. }
  285. item.m_btnIcoWeekPromptTag.onClick.Add(RuleController.ShowRuleView);
  286. item.m_btnIcoWeekPromptTag.data = 300013;
  287. //领取按钮点击事件
  288. item.m_btnCurReceive.target.onClick.Add(OnBtnCurReceiveClick);
  289. //购买按钮点击事件
  290. item.m_btnBuy.target.onClick.Add(OnBtnBuyClick);
  291. item.m_list.data = shopCfg;
  292. item.m_list.itemRenderer = ChildListItemRender;
  293. item.m_list.numItems = numItems;
  294. }
  295. //领取按钮点击事件
  296. // ReSharper disable Unity.PerformanceAnalysis
  297. private void OnBtnCurReceiveClick(EventContext context)
  298. {
  299. GObject sender = context.sender as GObject;
  300. GObject obj = sender.parent;
  301. ShopCfg cfg = obj.data as ShopCfg;
  302. bool isSellOut = EnduringGiftBoxDataManager.Instance.DayIsRebateGiftBox(cfg.itemId);
  303. if (isSellOut)
  304. {
  305. EnduringGiftBoxSProxy.ReqGetGiftBagRebate(cfg.id).Coroutine();
  306. }
  307. else
  308. {
  309. PromptController.Instance.ShowFloatTextPrompt("无法领取");
  310. }
  311. }
  312. //购买按钮点击事件
  313. // ReSharper disable Unity.PerformanceAnalysis
  314. private void OnBtnBuyClick(EventContext context)
  315. {
  316. if (_itemId == ConstItemID.POWER && GuideDataManager.IsGuideFinish(ConstGuideId.BUY_POWER) <= 0)
  317. {
  318. GuideController.TryCompleteGuideIndex(ConstGuideId.BUY_POWER, 1);
  319. GuideController.TryCompleteGuide(ConstGuideId.BUY_POWER, 1);
  320. }
  321. GObject sender = context.sender as GObject;
  322. GObject obj = sender.parent;
  323. ShopCfg cfg = obj.data as ShopCfg;
  324. bool isSellOut = cfg.maxBuyNum > 0 &&
  325. cfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(cfg.id) <= 0;
  326. if (isSellOut)
  327. {
  328. PromptController.Instance.ShowFloatTextPrompt("已售罄");
  329. return;
  330. }
  331. if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id))
  332. {
  333. PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id));
  334. return;
  335. }
  336. if (cfg.costType == CostType.FREE)
  337. {
  338. ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
  339. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  340. }
  341. else
  342. {
  343. ViewManager.Show<ItemExchangeView>(cfg.id);
  344. }
  345. }
  346. // ReSharper disable Unity.PerformanceAnalysis
  347. private void ChildListItemRender(int index, GObject obj)
  348. {
  349. UI_ComRewardIconItem uiItemChild = UI_ComRewardIconItem.Proxy(obj);
  350. var shopCfg = uiItemChild.target.parent.data as ShopCfg;
  351. var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  352. // uiItemChild.m_showRreceives.visible = false;
  353. //var curGiftBoxState = EnduringGiftBoxDataManager.GiftBoxStateDic[shopCfg.id];
  354. int[][] result;
  355. if (shopCfg.refreshType == RefreshType.DAY)
  356. {
  357. result = itemCfg.itemsArr;
  358. uiItemChild.m_bagYellow.visible = false;
  359. uiItemChild.m_bagBlue.visible = true;
  360. uiItemChild.m_bagYellowEx.visible = false;
  361. uiItemChild.m_bagBlueEx.visible = true;
  362. }
  363. else
  364. {
  365. //周刷
  366. result = itemCfg.param1Arr;
  367. uiItemChild.m_bagYellow.visible = true;
  368. uiItemChild.m_bagBlue.visible = false;
  369. uiItemChild.m_bagYellowEx.visible = true;
  370. uiItemChild.m_bagBlueEx.visible = false;
  371. }
  372. // if (curGiftBoxState == EnduringGiftBoxBuyStatus.YesGet)
  373. // {
  374. // uiItemChild.m_showRreceives.visible = true;
  375. // }
  376. // else if (curGiftBoxState == EnduringGiftBoxBuyStatus.NoGet)
  377. // {
  378. // uiItemChild.m_showRreceives.visible = false;
  379. // }
  380. var itemArr = result[index];
  381. var itemCfgChild = ItemCfgArray.Instance.GetCfg(itemArr[0]);
  382. uiItemChild.m_loaIcon.onClick.Add(OnListSelectorItemClick);
  383. uiItemChild.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfgChild);
  384. uiItemChild.m_num.text = itemArr[1].ToString();
  385. uiItemChild.target.data = itemCfgChild;
  386. UI_ComRewardIconItem.ProxyEnd();
  387. }
  388. //弹出物品详细描述框
  389. private void OnListSelectorItemClick(EventContext context)
  390. {
  391. GObject sender = context.sender as GObject;
  392. GObject obj = sender.parent;
  393. ItemCfg itemCfg = obj.data as ItemCfg;
  394. GoodsItemTipsController.ShowItemTips(itemCfg.id);
  395. }
  396. // ReSharper disable Unity.PerformanceAnalysis
  397. // ReSharper disable Unity.PerformanceAnalysis
  398. private async void OnClickBtnSure()
  399. {
  400. if (_maxTimes > 0 && (_buyTimes + _count) > _maxTimes)
  401. {
  402. PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
  403. return;
  404. }
  405. ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
  406. out int buyNum);
  407. Debug.Log(costId + "数量:" + ItemDataManager.GetItemNum(costId));
  408. if (ItemDataManager.GetItemNum(costId) < coustNum)
  409. {
  410. ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
  411. if (_itemId == ConstItemID.DIAMOND_PURPLE)
  412. {
  413. PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
  414. }
  415. else
  416. {
  417. AlertUI.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认",
  418. (AlertWindow.AlertCallback)((object data) =>
  419. {
  420. long costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
  421. BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, null, true, true,
  422. GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
  423. }));
  424. OnClickBtnCancel();
  425. }
  426. return;
  427. }
  428. bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
  429. if (result)
  430. {
  431. PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
  432. if (_onSuccess != null)
  433. {
  434. _onSuccess();
  435. }
  436. }
  437. UpdateView();
  438. //判断一下是不是从主要界面进来的
  439. if (_type == 0)
  440. {
  441. this.Hide();
  442. }
  443. }
  444. //购买连续礼包之后,更新数据+更新界面
  445. // ReSharper disable Unity.PerformanceAnalysis
  446. private void UpDayRebateAndView(EventContext context)
  447. {
  448. ShopCfg shopCfg = context.data as ShopCfg;
  449. var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  450. if (itemCfg.itemType == ConstItemType.USEABLE &&
  451. itemCfg.funType == ConstItemFuncType.CONTINUOUS_REWARD_GIFT)
  452. {
  453. int dayNum = EnduringGiftBoxDataManager.Instance.GetItemRebateDay(itemCfg.id);
  454. int totalDayNum = dayNum + itemCfg.param2Arr[0];
  455. EnduringGiftBoxDataManager.Instance.UpDayAllRebateItemDic(itemCfg.id, totalDayNum);
  456. EnduringGiftBoxDataManager.Instance.AddDayRebateItemIds(itemCfg.id);
  457. }
  458. UpdateView();
  459. }
  460. protected override void OnHide()
  461. {
  462. EffectUIPool.Recycle(_effectUI1);
  463. _effectUI1 = null;
  464. EffectUIPool.Recycle(_effectUI2);
  465. _effectUI2 = null;
  466. EffectUIPool.Recycle(_effectUI3);
  467. _effectUI3 = null;
  468. EffectUIPool.Recycle(_effectUI4);
  469. _effectUI4 = null;
  470. this.RemoveEventListener();
  471. base.Hide();
  472. _onSuccess = null;
  473. Timers.inst.Remove(CheckGuide);
  474. }
  475. private void OnClickBtnCancel()
  476. {
  477. // Dispose();
  478. this.Hide();
  479. }
  480. private void CheckGuide()
  481. {
  482. Timers.inst.AddUpdate(CheckGuide);
  483. }
  484. private void CheckGuide(object param)
  485. {
  486. if (GuideDataManager.IsGuideFinish(ConstGuideId.BUY_POWER) <= 0)
  487. {
  488. UpdateToCheckGuide(null);
  489. }
  490. else
  491. {
  492. Timers.inst.Remove(CheckGuide);
  493. }
  494. }
  495. protected override void UpdateToCheckGuide(object param)
  496. {
  497. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  498. if (_itemId == ConstItemID.POWER)
  499. {
  500. GuideController.TryGuide(_ui.m_list.GetChildAt(1).asCom.GetChild("btnCurReceive").asButton,
  501. ConstGuideId.BUY_POWER, 1, "这里可以购买体力超值返利包,每天都能领体力哦~");
  502. }
  503. }
  504. }
  505. }