EnduringGiftBoxView.cs 23 KB

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