EnduringGiftBoxView.cs 23 KB

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