LuckyBoxBonusShowView.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. using FairyGUI;
  2. using UI.LuckyBox;
  3. using System.Collections.Generic;
  4. using System.Collections;
  5. using cfg.GfgCfg;
  6. using ET;
  7. using System;
  8. using UnityEngine;
  9. namespace GFGGame
  10. {
  11. public class LuckyBoxBonusShowView : BaseWindow
  12. {
  13. private UI_LuckBoxBonusShowUI _ui;
  14. private List<ItemData> _rewardList = new List<ItemData>();
  15. private List<ItemData> _rewardItemList = new List<ItemData>();
  16. private Dictionary<int, Dictionary<int, EffectUI>> _effListTen =
  17. new Dictionary<int, Dictionary<int, EffectUI>>();
  18. private Dictionary<int, EffectUI> _effList = new Dictionary<int, EffectUI>();
  19. private Dictionary<int, bool> _itemHasNew = new Dictionary<int, bool>();
  20. private Dictionary<int, int> _itemIdList = new Dictionary<int, int>();
  21. private Dictionary<int, GComponent> _itemObjList = new Dictionary<int, GComponent>();
  22. private List<int> _recordOpenIndex = new List<int>(); //记录打开过得item位置
  23. private List<int> _recordTurnIndex = new List<int>(); //记录播放过item位置
  24. private int _chooseIndex = -1; //当前选中的index
  25. private int _countShow = 0; //第几次展示
  26. private bool _handClick = false; //手动点击开启
  27. private bool _AnimationWait = true; //抽卡动画等待加载完毕
  28. bool _touchLoaBg = true; //防止点击背景事件太快
  29. private EffectUI _effectUI1;
  30. private EffectUI _effectUI2;
  31. private EffectUI _effectUI3;
  32. private Dictionary<string, EffectUI> _effectUIDic = new Dictionary<string, EffectUI>();
  33. private bool _allEffectsLoaded = false;
  34. private int _loadingEffectCount = 0;
  35. public override void Dispose()
  36. {
  37. try
  38. {
  39. EffectUIPool.Recycle(_effectUI1);
  40. _effectUI1 = null;
  41. EffectUIPool.Recycle(_effectUI2);
  42. _effectUI2 = null;
  43. EffectUIPool.Recycle(_effectUI3);
  44. _effectUI3 = null;
  45. ClearAllEffects();
  46. if (_ui != null)
  47. {
  48. _ui.Dispose();
  49. _ui = null;
  50. }
  51. base.Dispose();
  52. }
  53. catch (Exception e)
  54. {
  55. Debug.LogError(e);
  56. }
  57. }
  58. private void ClearAllEffects()
  59. {
  60. try
  61. {
  62. for (int key = 0; key < _effListTen.Count; key++)
  63. {
  64. if (_effListTen.ContainsKey(key))
  65. {
  66. for (int key1 = 0; key1 < _effListTen[key].Count; key1++)
  67. {
  68. if (_effListTen[key].ContainsKey(key1))
  69. {
  70. EffectUIPool.Recycle(_effListTen[key][key1]);
  71. _effListTen[key][key1] = null;
  72. }
  73. }
  74. }
  75. }
  76. _effListTen.Clear();
  77. for (int key = 0; key < _effList.Count; key++)
  78. {
  79. if (_effList.ContainsKey(key))
  80. {
  81. EffectUIPool.Recycle(_effList[key]);
  82. _effList[key] = null;
  83. }
  84. }
  85. _effList.Clear();
  86. foreach (var v in _effectUIDic)
  87. {
  88. EffectUIPool.Recycle(v.Value);
  89. }
  90. _effectUIDic.Clear();
  91. }
  92. catch (Exception e)
  93. {
  94. Debug.LogError(e);
  95. }
  96. }
  97. protected override void OnInit()
  98. {
  99. try
  100. {
  101. base.OnInit();
  102. packageName = UI_LuckBoxBonusShowUI.PACKAGE_NAME;
  103. _ui = UI_LuckBoxBonusShowUI.Create();
  104. this.viewCom = _ui.target;
  105. isfullScreen = true;
  106. _ui.m_loaBg.onClick.Add(OnClickLoaBg);
  107. _ui.m_BtnPass.onClick.Add(OnClickBtnPass);
  108. }
  109. catch (Exception e)
  110. {
  111. Debug.LogError(e);
  112. }
  113. }
  114. protected override void AddEventListener()
  115. {
  116. try
  117. {
  118. base.AddEventListener();
  119. EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_REWARD_SHOW, ReferNextShow);
  120. EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_ANIMATION_WAIT, SetAnimationWait);
  121. EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE, OthershowViewClose);
  122. }
  123. catch (Exception e)
  124. {
  125. Debug.LogError(e);
  126. }
  127. }
  128. protected override void RemoveEventListener()
  129. {
  130. try
  131. {
  132. base.RemoveEventListener();
  133. EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_REWARD_SHOW, ReferNextShow);
  134. EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_ANIMATION_WAIT, SetAnimationWait);
  135. EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE, OthershowViewClose);
  136. }
  137. catch (Exception e)
  138. {
  139. Debug.LogError(e);
  140. }
  141. }
  142. protected override void OnShown()
  143. {
  144. try
  145. {
  146. base.OnShown();
  147. _allEffectsLoaded = false;
  148. _touchLoaBg = false;
  149. _rewardList.Clear();
  150. _rewardList.AddRange(this.viewData as List<ItemData>);
  151. _itemIdList.Clear();
  152. _itemObjList.Clear();
  153. _recordOpenIndex.Clear();
  154. _recordTurnIndex.Clear();
  155. _itemHasNew.Clear();
  156. _ui.m_BtnPass.visible = false;
  157. _ui.m_touchFlipOpen.touchable = false;
  158. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
  159. // 异步加载所有特效
  160. Timers.inst.StartCoroutine(LoadAllEffects(() =>
  161. {
  162. _allEffectsLoaded = true;
  163. SetupViewAfterEffectsLoaded();
  164. }));
  165. }
  166. catch (Exception e)
  167. {
  168. Debug.LogError(e);
  169. }
  170. }
  171. private IEnumerator LoadAllEffects(Action onComplete)
  172. {
  173. // 加载背景特效
  174. EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing",
  175. onComplete: (effect) =>
  176. {
  177. if (effect != null)
  178. {
  179. _effectUI1 = effect;
  180. }
  181. });
  182. EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI",
  183. onComplete: (effect) =>
  184. {
  185. if (effect != null)
  186. {
  187. _effectUI2 = effect;
  188. }
  189. });
  190. EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud",
  191. onComplete: (effect) =>
  192. {
  193. if (effect != null)
  194. {
  195. _effectUI3 = effect;
  196. }
  197. });
  198. // 等待所有背景特效加载完成
  199. while (_effectUI1.GetObj() == null || _effectUI2.GetObj() == null ||
  200. _effectUI3.GetObj() == null)
  201. {
  202. yield return null;
  203. }
  204. onComplete?.Invoke();
  205. }
  206. private void SetupViewAfterEffectsLoaded()
  207. {
  208. try
  209. {
  210. if (!_allEffectsLoaded) return;
  211. if (_rewardList.Count == 1)
  212. {
  213. _ui.m_c1.selectedIndex = 0;
  214. UpdateItem(_ui.m_itemOne.target, 0, 1);
  215. }
  216. else
  217. {
  218. _ui.m_c1.selectedIndex = 1;
  219. for (int i = 0; i < _rewardList.Count; i++)
  220. {
  221. UpdateItem(_ui.target.GetChild("item" + i).asCom, i, 10);
  222. }
  223. }
  224. // 修改,因为加了抽奖动画,在进入后就直接筛选掉所有不是新的
  225. for (int i = 0; i < _rewardList.Count; i++)
  226. {
  227. UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[i]);
  228. if (!item.m_comIcon.m_imgNew.visible)
  229. {
  230. _recordTurnIndex.Add(i);
  231. _recordOpenIndex.Add(i);
  232. }
  233. UI_LuckyBoxBonusShowItem.ProxyEnd();
  234. }
  235. if (GetSuitItemController.isAuto)
  236. {
  237. OnClickBtnPass();
  238. }
  239. Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
  240. }
  241. catch (Exception e)
  242. {
  243. Debug.LogError(e);
  244. }
  245. }
  246. protected override void OnHide()
  247. {
  248. try
  249. {
  250. _rewardList.Clear();
  251. base.OnHide();
  252. Timers.inst.Remove(UpDataTime);
  253. Timers.inst.Remove(UpClickDataTime);
  254. Timers.inst.Remove(touchFlipOpen);
  255. Timers.inst.Remove(UpDataTimeTouchLoaBg);
  256. GetSuitItemController.isAuto = false;
  257. _touchLoaBg = true;
  258. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_BONUS_VIEW_CLOSE);
  259. }
  260. catch (Exception e)
  261. {
  262. Debug.LogError(e);
  263. }
  264. }
  265. private void UpdateItem(GComponent com, int index, int countType)
  266. {
  267. try
  268. {
  269. if (!_allEffectsLoaded) return;
  270. UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(com);
  271. ItemData itemData = _rewardList[index];
  272. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemData.id);
  273. item.m_comIcon.m_c1.selectedIndex = itemCfg.Rarity;
  274. item.m_comIcon.m_txtName.text = itemCfg.Name;
  275. item.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  276. item.m_comIcon.m_FlipOpenType.selectedIndex = 0;
  277. item.m_comIcon.m_t1.Play();
  278. // 圆盘出现时等待玩家点击的特效
  279. switch (itemCfg.Rarity)
  280. {
  281. case 3:
  282. if (!_effectUIDic.ContainsKey("CK_Loop_Wait_Chen" + index))
  283. {
  284. EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Chen",
  285. onComplete: (effect) =>
  286. {
  287. if (effect != null)
  288. {
  289. _effectUIDic.Add("CK_Loop_Wait_Chen" + index, effect);
  290. }
  291. });
  292. }
  293. break;
  294. case 4:
  295. if (!_effectUIDic.ContainsKey("CK_Loop_Wait_GS" + index))
  296. {
  297. EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_GS",
  298. onComplete: (effect) =>
  299. {
  300. if (effect != null)
  301. {
  302. _effectUIDic.Add("CK_Loop_Wait_GS" + index, effect);
  303. }
  304. });
  305. }
  306. break;
  307. case 5:
  308. if (!_effectUIDic.ContainsKey("CK_Loop_Wait_Jin" + index))
  309. {
  310. EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Jin",
  311. onComplete: (effect) =>
  312. {
  313. if (effect != null)
  314. {
  315. _effectUIDic.Add("CK_Loop_Wait_Jin" + index, effect);
  316. }
  317. });
  318. }
  319. break;
  320. }
  321. int count = 0;
  322. bool isFirst = false;
  323. for (int i = 0; i < _rewardList.Count; i++)
  324. {
  325. if (_rewardList[i].id == itemData.id) count++;
  326. if (count == 1 && i == index) isFirst = true;
  327. }
  328. item.m_comIcon.m_imgNew.visible = count == ItemDataManager.GetItemNum(itemData.id) && isFirst;
  329. if (_itemHasNew.ContainsKey(index))
  330. _itemHasNew[index] = item.m_comIcon.m_imgNew.visible;
  331. else
  332. _itemHasNew.Add(index, item.m_comIcon.m_imgNew.visible);
  333. item.m_t0.Play();
  334. if (item.target.data == null)
  335. {
  336. item.target.onClick.Add(ShowItemTips);
  337. }
  338. item.target.data = index;
  339. _itemIdList.Add(index, itemCfg.Id);
  340. _itemObjList.Add(index, com);
  341. UI_LuckyBoxBonusShowItem.ProxyEnd();
  342. }
  343. catch (Exception e)
  344. {
  345. Debug.LogError(e);
  346. }
  347. }
  348. private void ShowItemTips(EventContext context)
  349. {
  350. try
  351. {
  352. if (!_allEffectsLoaded || !_touchLoaBg) return;
  353. _touchLoaBg = false;
  354. Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
  355. GObject obj = context.sender as GObject;
  356. int index = (int)obj.data;
  357. _chooseIndex = index;
  358. GoodsItemTipsController.ShowItemTips(_itemIdList[index]);
  359. }
  360. catch (Exception e)
  361. {
  362. Debug.LogError(e);
  363. }
  364. }
  365. private void HandClickItem(int index)
  366. {
  367. try
  368. {
  369. if (!_allEffectsLoaded) return;
  370. _ui.m_touchFlipOpen.touchable = true;
  371. _handClick = true;
  372. ClickItem(index);
  373. //翻牌动画
  374. Timers.inst.Add(1f, 1, UpClickDataTime, index);
  375. }
  376. catch (Exception e)
  377. {
  378. Debug.LogError(e);
  379. }
  380. }
  381. private void UpClickDataTime(object param = null)
  382. {
  383. try
  384. {
  385. if (!_allEffectsLoaded) return;
  386. int index = (int)param;
  387. Timers.inst.Remove(UpClickDataTime);
  388. if (_recordTurnIndex.Contains(index) && _recordOpenIndex.Contains(index))
  389. {
  390. HideOtherShowWindow();
  391. _ui.m_touchFlipOpen.touchable = false;
  392. }
  393. else
  394. ClickItem(index);
  395. }
  396. catch (Exception e)
  397. {
  398. Debug.LogError(e);
  399. }
  400. }
  401. void ClickItem(int index)
  402. {
  403. try
  404. {
  405. if (!_allEffectsLoaded) return;
  406. if (_recordOpenIndex.Count >= _rewardList.Count)
  407. _ui.m_BtnPass.visible = false;
  408. if (!_recordOpenIndex.Contains(index))
  409. {
  410. TurnItem(index);
  411. }
  412. else
  413. {
  414. if (!_recordTurnIndex.Contains(index))
  415. ShowTurnItem(index);
  416. else
  417. GoodsItemTipsController.ShowItemTips(_itemIdList[index]);
  418. }
  419. }
  420. catch (Exception e)
  421. {
  422. Debug.LogError(e);
  423. }
  424. }
  425. private void UpDataTimeTouchLoaBg(object param = null)
  426. {
  427. try
  428. {
  429. _touchLoaBg = true;
  430. }
  431. catch (Exception e)
  432. {
  433. Debug.LogError(e);
  434. }
  435. }
  436. private void OnClickLoaBg(EventContext context)
  437. {
  438. try
  439. {
  440. if (!_allEffectsLoaded || !_touchLoaBg) return;
  441. _touchLoaBg = false;
  442. Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
  443. if (_recordOpenIndex.Count >= _rewardList.Count)
  444. {
  445. _chooseIndex = -1;
  446. this.Hide();
  447. }
  448. else
  449. {
  450. for (int index = 0; index < _rewardList.Count; index++)
  451. {
  452. if (!_recordOpenIndex.Contains(index))
  453. {
  454. _chooseIndex = index;
  455. HandClickItem(index);
  456. break;
  457. }
  458. }
  459. }
  460. }
  461. catch (Exception e)
  462. {
  463. Debug.LogError(e);
  464. }
  465. }
  466. private void OnClickBtnPass()
  467. {
  468. try
  469. {
  470. if (!_allEffectsLoaded) return;
  471. for (int index = 0; index < _rewardList.Count; index++)
  472. {
  473. if (!_recordOpenIndex.Contains(index))
  474. {
  475. int count = 0;
  476. bool isFirst = false;
  477. for (int i = 0; i < _rewardList.Count; i++)
  478. {
  479. if (_rewardList[i].id == _rewardList[index].id) count++;
  480. if (count == 1 && i == index) isFirst = true;
  481. }
  482. bool open = count == ItemDataManager.GetItemNum(_rewardList[index].id) && isFirst;
  483. if (!open)
  484. {
  485. _chooseIndex = -1;
  486. ClickItem(index);
  487. }
  488. }
  489. }
  490. ClickPass();
  491. }
  492. catch (Exception e)
  493. {
  494. Debug.LogError(e);
  495. }
  496. }
  497. private void ClickPass()
  498. {
  499. try
  500. {
  501. if (!_allEffectsLoaded) return;
  502. GetSuitItemController.isAuto = true;
  503. _ui.m_touchFlipOpen.touchable = true;
  504. _ui.m_BtnPass.visible = false;
  505. for (int i = 0; i < _rewardList.Count; i++)
  506. {
  507. TurnItem(i);
  508. }
  509. //展示获得物品
  510. Timers.inst.Add(LuckyBoxDataManager.ANIMATION_TIME, 0, UpDataTime);
  511. }
  512. catch (Exception e)
  513. {
  514. Debug.LogError(e);
  515. }
  516. }
  517. private void UpDataTime(object param = null)
  518. {
  519. try
  520. {
  521. if (!_allEffectsLoaded) return;
  522. _ui.m_touchFlipOpen.touchable = true;
  523. if (_recordTurnIndex.Count >= _rewardList.Count)
  524. {
  525. Timers.inst.Remove(UpDataTime);
  526. HideOtherShowWindow();
  527. _ui.m_touchFlipOpen.touchable = false;
  528. GetSuitItemController.isAuto = false;
  529. }
  530. for (int i = 0; i < _rewardList.Count; i++)
  531. {
  532. if (!_recordTurnIndex.Contains(i))
  533. {
  534. ShowTurnItem(i);
  535. break;
  536. }
  537. }
  538. }
  539. catch (Exception e)
  540. {
  541. Debug.LogError(e);
  542. }
  543. }
  544. private void ShowTurnItem(int index)
  545. {
  546. try
  547. {
  548. if (!_allEffectsLoaded || !_AnimationWait) return;
  549. UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[index]);
  550. if (!item.m_comIcon.m_imgNew.visible)
  551. {
  552. _recordTurnIndex.Add(index);
  553. _ui.m_touchFlipOpen.touchable = false;
  554. UI_LuckyBoxBonusShowItem.ProxyEnd();
  555. return;
  556. }
  557. _countShow += 1;
  558. //判断是否有套装需要展示
  559. int suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[index]);
  560. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
  561. if (suitId > 0 && itemCfg.ItemType != ConstItemType.CARD)
  562. {
  563. if (_countShow == 1)
  564. {
  565. ViewManager.Hide<SuitItemView>();
  566. ViewManager.Hide<LuckyBoxNewCardView>();
  567. ViewManager.Hide<GetSuitItemVIew>();
  568. _rewardItemList.Clear();
  569. _rewardItemList.Add(_rewardList[index]);
  570. ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
  571. }
  572. else
  573. {
  574. ViewManager.Hide<LuckyBoxNewDressView>();
  575. ViewManager.Hide<LuckyBoxNewCardView>();
  576. int count = 0;
  577. int totalCount = 0;
  578. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  579. if (_countShow == 2) //展示进度条界面
  580. {
  581. int countSuitId = 0;
  582. for (int i = index + 1; i < _rewardList.Count; i++)
  583. {
  584. _itemHasNew.TryGetValue(i, out bool isNew);
  585. var itemRewardCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_rewardList[i].id);
  586. if (isNew && itemRewardCfg.ItemType == ConstItemType.DRESS_UP &&
  587. itemRewardCfg.SuitId == suitId)
  588. {
  589. countSuitId++;
  590. }
  591. }
  592. count = count - countSuitId;
  593. ViewManager.Show<SuitItemView>(new object[] { suitId, countSuitId });
  594. }
  595. else if (_countShow == 3) //展示集齐套装界面
  596. {
  597. ViewManager.Hide<SuitItemView>();
  598. ViewManager.Show<GetSuitItemVIew>(suitId);
  599. _AnimationWait = false;
  600. }
  601. //判断是否需要显示集齐套装界面(需要的时候晚3个定时器时间)
  602. if (count <= 0 || totalCount <= 0 || count < totalCount ||
  603. (count >= totalCount && _countShow > 5))
  604. {
  605. _recordTurnIndex.Add(index);
  606. _countShow = 0;
  607. if (_handClick)
  608. {
  609. _handClick = false;
  610. _ui.m_touchFlipOpen.touchable = false;
  611. }
  612. }
  613. }
  614. }
  615. else
  616. {
  617. //词牌和不是套装进这里
  618. ViewManager.Hide<SuitItemView>();
  619. ViewManager.Hide<LuckyBoxNewCardView>();
  620. ViewManager.Hide<GetSuitItemVIew>();
  621. _rewardItemList.Clear();
  622. _rewardItemList.Add(_rewardList[index]);
  623. ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
  624. _recordTurnIndex.Add(index);
  625. _countShow = 0;
  626. Timers.inst.Add(1.5f, 1, touchFlipOpen); //防止点击太快
  627. }
  628. UI_LuckyBoxBonusShowItem.ProxyEnd();
  629. }
  630. catch (Exception e)
  631. {
  632. Debug.LogError(e);
  633. }
  634. }
  635. private void TurnItem(int index)
  636. {
  637. try
  638. {
  639. if (!_allEffectsLoaded || _recordOpenIndex.Contains(index)) return;
  640. // 删除 "等待翻开" 的特效
  641. if (_effectUIDic.ContainsKey("CK_Loop_Wait_Chen" + index))
  642. {
  643. EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Chen" + index]);
  644. _effectUIDic.Remove("CK_Loop_Wait_Chen" + index);
  645. }
  646. if (_effectUIDic.ContainsKey("CK_Loop_Wait_GS" + index))
  647. {
  648. EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_GS" + index]);
  649. _effectUIDic.Remove("CK_Loop_Wait_GS" + index);
  650. }
  651. if (_effectUIDic.ContainsKey("CK_Loop_Wait_Jin" + index))
  652. {
  653. EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Jin" + index]);
  654. _effectUIDic.Remove("CK_Loop_Wait_Jin" + index);
  655. }
  656. UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[index]);
  657. if (!item.m_comIcon.m_imgNew.visible && !_recordTurnIndex.Contains(index))
  658. {
  659. _recordTurnIndex.Add(index);
  660. }
  661. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
  662. // 点击特效
  663. if (!_effectUIDic.ContainsKey("CK_Cirle_DJ" + index))
  664. {
  665. EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ",
  666. onComplete: (effect) =>
  667. {
  668. if (effect != null)
  669. {
  670. _effectUIDic.Add("CK_Cirle_DJ" + index, effect);
  671. }
  672. });
  673. }
  674. else
  675. {
  676. EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ",
  677. onComplete: (effect) =>
  678. {
  679. if (effect != null)
  680. {
  681. _effectUIDic["CK_Cirle_DJ" + index] = effect;
  682. }
  683. });
  684. }
  685. // 翻开特效
  686. switch (itemCfg.Rarity)
  687. {
  688. case 1:
  689. EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox",
  690. "CK_OpenAfter_HuiLan_UI",
  691. onComplete: (effect) =>
  692. {
  693. if (effect != null)
  694. {
  695. _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index, effect);
  696. }
  697. });
  698. EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
  699. "CK_OpenAfter_LanHui_TX",
  700. onComplete: (effect) =>
  701. {
  702. if (effect != null)
  703. {
  704. _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index, effect);
  705. }
  706. });
  707. break;
  708. case 2:
  709. EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox",
  710. "CK_OpenAfter_LanHui_UI",
  711. onComplete: (effect) =>
  712. {
  713. if (effect != null)
  714. {
  715. _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index, effect
  716. );
  717. }
  718. });
  719. EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
  720. "CK_OpenAfter_LanHui_TX",
  721. onComplete: (effect) =>
  722. {
  723. if (effect != null)
  724. {
  725. _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index, effect
  726. );
  727. }
  728. });
  729. break;
  730. case 3:
  731. EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox",
  732. "CK_OpenAfter_Chen_UI",
  733. onComplete: (effect) =>
  734. {
  735. if (effect != null)
  736. {
  737. _effectUIDic.Add("CK_OpenAfter_Chen_UI" + index, effect);
  738. }
  739. });
  740. EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
  741. "CK_OpenAfter_Chen_TX",
  742. onComplete: (effect) =>
  743. {
  744. if (effect != null)
  745. {
  746. _effectUIDic.Add("CK_OpenAfter_Chen_TX" + index, effect);
  747. }
  748. });
  749. break;
  750. case 4:
  751. EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_GS_UI",
  752. onComplete: (effect) =>
  753. {
  754. if (effect != null)
  755. {
  756. _effectUIDic.Add("CK_OpenAfter_GS_UI" + index, effect);
  757. }
  758. });
  759. EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
  760. "CK_OpenAfter_GS_TX",
  761. onComplete: (effect) =>
  762. {
  763. if (effect != null)
  764. {
  765. _effectUIDic.Add("CK_OpenAfter_GS_TX" + index, effect);
  766. }
  767. });
  768. break;
  769. case 5:
  770. EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_Jin_UI",
  771. onComplete: (effect) =>
  772. {
  773. if (effect != null)
  774. {
  775. _effectUIDic.Add("CK_OpenAfter_Jin_UI" + index, effect);
  776. }
  777. });
  778. EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
  779. "CK_OpenAfter_Jin_TX",
  780. onComplete: (effect) =>
  781. {
  782. if (effect != null)
  783. {
  784. _effectUIDic.Add("CK_OpenAfter_Jin_TX" + index, effect);
  785. }
  786. });
  787. break;
  788. }
  789. _recordOpenIndex.Add(index);
  790. UI_LuckyBoxBonusShowItem.ProxyEnd();
  791. }
  792. catch (Exception e)
  793. {
  794. Debug.LogError(e);
  795. }
  796. }
  797. private void touchFlipOpen(object param)
  798. {
  799. try
  800. {
  801. Timers.inst.Remove(touchFlipOpen);
  802. _ui.m_touchFlipOpen.touchable = false;
  803. }
  804. catch (Exception e)
  805. {
  806. Debug.LogError(e);
  807. }
  808. }
  809. protected void OthershowViewClose()
  810. {
  811. try
  812. {
  813. _ui.m_touchFlipOpen.touchable = false;
  814. }
  815. catch (Exception e)
  816. {
  817. Debug.LogError(e);
  818. }
  819. }
  820. protected void ReferNextShow()
  821. {
  822. try
  823. {
  824. if (!_allEffectsLoaded || GetSuitItemController.isAuto) return;
  825. int suitId = 0;
  826. if (_itemIdList.ContainsKey(_chooseIndex))
  827. suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[_chooseIndex]);
  828. if (_chooseIndex != -1 && suitId > 0)
  829. ClickItem(_chooseIndex);
  830. else
  831. {
  832. if (_handClick)
  833. {
  834. _handClick = false;
  835. _ui.m_touchFlipOpen.touchable = false;
  836. }
  837. }
  838. }
  839. catch (Exception e)
  840. {
  841. Debug.LogError(e);
  842. }
  843. }
  844. protected void SetAnimationWait()
  845. {
  846. try
  847. {
  848. _AnimationWait = true;
  849. }
  850. catch (Exception e)
  851. {
  852. Debug.LogError(e);
  853. }
  854. }
  855. private void HideOtherShowWindow()
  856. {
  857. try
  858. {
  859. ViewManager.Hide<SuitItemView>();
  860. ViewManager.Hide<GetSuitItemVIew>();
  861. ViewManager.Hide<LuckyBoxNewDressView>();
  862. ViewManager.Hide<LuckyBoxNewCardView>();
  863. }
  864. catch (Exception e)
  865. {
  866. Debug.LogError(e);
  867. }
  868. }
  869. }
  870. }