DragonEggTreasurePanelCtrl.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using FL.Data.Items;
  9. using FL.Network;
  10. using Spine.Unity;
  11. using System.Collections.Generic;
  12. using UnityEngine;
  13. using XGame.Database;
  14. using XGame.Framework.FGUI;
  15. using XGame.Framework.Time;
  16. using XGame.Framework.UI;
  17. namespace FL.FGUI
  18. {
  19. /// <summary>
  20. /// UI逻辑处理类
  21. /// </summary>
  22. /// <typeparam name=""></typeparam>
  23. public partial class DragonEggTreasurePanelCtrl : UIController<DragonEggTreasurePanelVM>
  24. {
  25. private bool _bFlyingAni; // 是否处于开龙宝藏飞行动画状态
  26. private int _useCount; // 使用的品质宝箱数量
  27. private int _maxTreasureSocre; // 当前宝藏进度的最大积分值
  28. private int _treasureRewardId; // 奖励宝箱道具id
  29. private string _treasureChestName; // 当前宝藏宝箱名称
  30. private ITimer _openBoxTimer;
  31. private Vector3 _startPos;
  32. private Vector3 _endPos;
  33. private Vector3 _scoreEndPos;
  34. private HashSet<DragonEggFlyIconView> _flyingList;
  35. private List<GButton> _dragonBtnList;
  36. private List<KindItem> _dropItemList;
  37. private const int _costDragonEggNum = 10; // 每次消耗的龙蛋数量
  38. protected override void OnEnable(object intent)
  39. {
  40. AddUIListenres();
  41. AddEventListener();
  42. Init();
  43. }
  44. protected override void OnDisable()
  45. {
  46. RemoveUIListenres();
  47. RemoveEventListener();
  48. ClearOpenTimer();
  49. if (_flyingList != null)
  50. {
  51. foreach (var flying in _flyingList)
  52. {
  53. Context.Asset.Recycle(flying);
  54. }
  55. _flyingList.Clear();
  56. _flyingList = null;
  57. }
  58. if (_dropItemList != null) _dropItemList.Clear();
  59. if (_dragonBtnList != null)
  60. {
  61. _dragonBtnList.Clear();
  62. _dragonBtnList = null;
  63. }
  64. VM.DragonSpine.url = string.Empty;
  65. }
  66. #region UI事件
  67. private void AddUIListenres()
  68. {
  69. VM.NextBtn.onClick.Add(OnClickNextBtn);
  70. VM.PreviousBtn.onClick.Add(OnClickPreviousBtn);
  71. VM.BagBtn.onClick.Add(OnClickBagBtn);
  72. VM.BoxAwardBtn.onClick.Add(OnClickBoxAwardBtn);
  73. VM.DragonSpineBtn.onClick.Add(OnclickDragonSpineBtn);
  74. VM.LevelBtn.onClick.Add(OnClickLevelBtn);
  75. VM.MenusBtnCtrl.onChanged.Add(OnMenusBtnCtrlChange);
  76. }
  77. private void RemoveUIListenres()
  78. {
  79. VM.NextBtn.onClick.Remove(OnClickNextBtn);
  80. VM.PreviousBtn.onClick.Remove(OnClickPreviousBtn);
  81. VM.BagBtn.onClick.Remove(OnClickBagBtn);
  82. VM.BoxAwardBtn.onClick.Remove(OnClickBoxAwardBtn);
  83. VM.DragonSpineBtn.onClick.Remove(OnclickDragonSpineBtn);
  84. VM.LevelBtn.onClick.Remove(OnClickLevelBtn);
  85. VM.MenusBtnCtrl.onChanged.Remove(OnMenusBtnCtrlChange);
  86. }
  87. /// <summary>
  88. /// 打开宝箱等级弹窗界面
  89. /// </summary>
  90. /// <param name="context"></param>
  91. private void OnClickLevelBtn(EventContext context)
  92. {
  93. Context.UI.OpenAsync(UIKeys.TreasureChestUpgradePanel);
  94. }
  95. private void OnClickNextBtn(EventContext context)
  96. {
  97. OnSelectDragon(VM.MenusBtnCtrl.selectedIndex + 1);
  98. }
  99. private void OnClickPreviousBtn(EventContext context)
  100. {
  101. OnSelectDragon(VM.MenusBtnCtrl.selectedIndex - 1);
  102. }
  103. /// <summary>
  104. /// 点击背包按钮
  105. /// </summary>
  106. /// <param name="context"></param>
  107. private void OnClickBagBtn(EventContext context)
  108. {
  109. DragonEggService.Instance.SendToOpenTemporaryEquipBag();
  110. }
  111. /// <summary>
  112. /// 积分进度条满值可领取对应的宝箱奖励
  113. /// </summary>
  114. /// <param name="context"></param>
  115. private void OnClickBoxAwardBtn(EventContext context)
  116. {
  117. DragonEggService.Instance.SendToOpenTreasureBoxAward();
  118. }
  119. private void OnclickDragonSpineBtn(EventContext context)
  120. {
  121. if (_bFlyingAni)
  122. {
  123. //XGame.Log.Info("处于开宝箱状态");
  124. return;
  125. }
  126. if (IsEmptyBox()) return;
  127. _bFlyingAni = true;
  128. OpenDragonEggBoxAni();
  129. OpenDragonTreasure();
  130. }
  131. #endregion
  132. private void AddEventListener()
  133. {
  134. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  135. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  136. EventSingle.Instance.AddListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  137. EventSingle.Instance.AddListener(EventDefine.OpenEquipBag, OpenEquipBag);
  138. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  139. EventSingle.Instance.AddListener(EventDefine.UpdataItemData, UpdataItemData);
  140. }
  141. private void RemoveEventListener()
  142. {
  143. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  144. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  145. EventSingle.Instance.RemoveListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  146. EventSingle.Instance.RemoveListener(EventDefine.OpenEquipBag, OpenEquipBag);
  147. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  148. EventSingle.Instance.RemoveListener(EventDefine.UpdataItemData, UpdataItemData);
  149. }
  150. private void Init()
  151. {
  152. _bFlyingAni = false;
  153. _startPos = VM.DragonSpineBtn.displayObject.LocalToWorld(new Vector3(VM.DragonSpineBtn.width / 3, VM.DragonSpineBtn.height / 2, 0));
  154. _endPos = VM.BagBtn.displayObject.LocalToWorld(new Vector3(VM.BagBtn.width / 10, VM.BagBtn.height / 8, 0));
  155. _scoreEndPos = VM.EggPointBar.displayObject.LocalToWorld(new Vector3(VM.EggPointBar.width / 2, VM.EggPointBar.height / 2, 0));
  156. ShowUI();
  157. DragonEggService.Instance.SendToTreasureInfo();
  158. }
  159. private void ShowUI()
  160. {
  161. InitDrangonBoxUI();
  162. ShowDragonTreasureUI(null);
  163. ShowDragonLv();
  164. }
  165. private void ShowDragonLv()
  166. {
  167. VM.LevelBtn.title = $"LV.{DragonEggData.Instance.Level}";
  168. }
  169. /// <summary>
  170. /// 加载龙的spine
  171. /// </summary>
  172. /// <param name="spineName"></param>
  173. private void LoadDragonSpine(string spineName)
  174. {
  175. VM.DragonSpine.LoadSpine(spineName, "box_idle", true);
  176. }
  177. /// <summary>
  178. /// 是否显示龙的spine模型
  179. /// </summary>
  180. /// <param name="bShow"></param>
  181. private void ShowDragonSpine(bool bShow)
  182. {
  183. VM.DragonSpine.visible = bShow;
  184. VM.DragonIcon.visible = !bShow;
  185. }
  186. /// <summary>
  187. /// 龙蛋积分变化
  188. /// </summary>
  189. /// <param name="addScore"></param>
  190. /// <param name="bTweenValue"></param>
  191. private void ShowDragonEggScoreUI(bool bTweenValue)
  192. {
  193. VM.EggPointBar.max = _maxTreasureSocre;
  194. if (bTweenValue)
  195. VM.EggPointBar.TweenValue(DragonEggData.Instance.DragonTreasureSocre, 0.5f);
  196. else
  197. VM.EggPointBar.value = DragonEggData.Instance.DragonTreasureSocre;
  198. OnchangeAwardState(DragonEggData.Instance.DragonTreasureSocre >= _maxTreasureSocre);
  199. int subSocre = _maxTreasureSocre > DragonEggData.Instance.DragonTreasureSocre ? _maxTreasureSocre - DragonEggData.Instance.DragonTreasureSocre : 0;
  200. VM.ScoreAwardLabel.text = string.Format(StringDefine.dragonTreasureScore, subSocre, _treasureChestName);
  201. }
  202. private void InitDrangonBoxUI()
  203. {
  204. if (_dragonBtnList == null) _dragonBtnList = new List<GButton>() { VM.DragonBtn1, VM.DragonBtn2, VM.DragonBtn3, VM.DragonBtn4, VM.DragonBtn5 };
  205. int index = -1;
  206. for (int i = 0; i < 5; i++)
  207. {
  208. long num = ItemData.Instance.GetItemNum(DragonEggData.Instance.GetTreasureChestId(i));
  209. if (num > 0 && index == -1)
  210. {
  211. index = i;
  212. ShowDragonBoxNum(num);
  213. }
  214. }
  215. OnSelectDragon(index == -1 ? 0 : index);
  216. }
  217. /// <summary>
  218. /// 判断龙裔宝卵数量是否
  219. /// </summary>
  220. /// <returns></returns>
  221. private bool IsEmptyBox(bool bShowTip = true)
  222. {
  223. var boxNum = ItemData.Instance.GetItemNum(GetTreasureChestId());
  224. if (boxNum == 0)
  225. {
  226. if (bShowTip)
  227. {
  228. EventSingle.Instance.Notify(EventDefine.ShowTips, StringDefine.dragonEggsEmpty);
  229. }
  230. return true;
  231. }
  232. return false;
  233. }
  234. /// <summary>
  235. /// 龙蛋品质宝箱数量
  236. /// </summary>
  237. /// <param name="index"></param>
  238. /// <param name="num"></param>
  239. private void ShowDragonBoxNum(long num)
  240. {
  241. VM.NumLabel.text = num.ToString();
  242. }
  243. private void ShowFlyIconView(int itemId, bool bScore)
  244. {
  245. var flyParam = new FlyingIconParam()
  246. {
  247. iconName = ItemTableRepo.Get(itemId).Icon,
  248. startPos = _startPos,
  249. bScore = bScore,
  250. endPos = _endPos,
  251. };
  252. if (_flyingList == null) _flyingList = new HashSet<DragonEggFlyIconView>();
  253. var loadAsync = Context.Asset.LoadFguiNested(UINestedKeys.DragonEggFlyIcon, VM.DragonSpineBtn);
  254. loadAsync.On(_ =>
  255. {
  256. var flyView = loadAsync.Result as DragonEggFlyIconView;
  257. if (flyView != null)
  258. {
  259. flyParam.callback = (bScore) =>
  260. {
  261. FlyingCallback(flyView, bScore);
  262. };
  263. flyView.Ctrl.ShowUI(flyParam);
  264. _flyingList.Add(flyView);
  265. }
  266. });
  267. }
  268. /// <summary>
  269. /// 物品全部飞入背包后的回调函数
  270. /// </summary>
  271. /// <param name="flyView"></param>
  272. /// <param name="bScore"></param>
  273. private void FlyingCallback(DragonEggFlyIconView flyView, bool bScore)
  274. {
  275. _flyingList.Remove(flyView);
  276. Context.Asset.Recycle(flyView);
  277. if (_flyingList.Count == 0) OnchangBagState(false);
  278. if (bScore)
  279. {
  280. ShowDragonEggScoreUI(true);
  281. _bFlyingAni = false;
  282. if (_dropItemList == null) _dropItemList = new List<KindItem>();
  283. else _dropItemList.Clear();
  284. _dropItemList.AddRange(DragonEggData.Instance.DropItems);
  285. if (_dropItemList.Count > 1)
  286. {
  287. OnSortByEquipPower();
  288. }
  289. var obtainData = new ObtainItemsParam()
  290. {
  291. dropItems = _dropItemList,
  292. bShowBtn = IsShowOneKeyBtn(DragonEggData.Instance.DropItems),
  293. };
  294. var loadAsync = Context.UI.OpenAsync(UIKeys.ItemGetItemPanel, obtainData);
  295. loadAsync.On(_=>
  296. {
  297. DragonEggData.Instance.DropItems.Clear();
  298. });
  299. };
  300. }
  301. private void OnSortByEquipPower()
  302. {
  303. _dropItemList.Sort((aItem, bItem)=>
  304. {
  305. int aEquipFlag = aItem.count == 0 ? 1 : 0;
  306. int bEquipFlag = bItem.count == 0 ? 1 : 0;
  307. if (aEquipFlag == bEquipFlag)
  308. {
  309. if (aEquipFlag == 1)
  310. {
  311. var aEquipData = EquipData.Instance.GetTemporaryEquipItem(aItem.id);
  312. var bEquipData = EquipData.Instance.GetTemporaryEquipItem(bItem.id);
  313. var aHighPower = GetCompareValue(aEquipData);
  314. var bHighPower = GetCompareValue(bEquipData);
  315. if (aHighPower == bHighPower)
  316. {
  317. if (aEquipData.FightingPower == bEquipData.FightingPower)
  318. {
  319. return aEquipData.Id.CompareTo(bEquipData.Id); // 升序
  320. }
  321. return bEquipData.FightingPower.CompareTo(aEquipData.FightingPower); //降序
  322. }
  323. else
  324. return bHighPower.CompareTo(aHighPower);
  325. }
  326. return aItem.count.CompareTo(bItem.count);
  327. }
  328. return bEquipFlag.CompareTo(aEquipFlag);//降序
  329. });
  330. }
  331. private int GetCompareValue(EquipItem equipData)
  332. {
  333. int compareFlag = 0;
  334. if (equipData?.Table?.Part > 0)
  335. {
  336. long compareFightingPower = equipData?.FightingPower ?? 0;
  337. var equipItem = EquipData.Instance.GetWearEquipData(equipData.Table.Part);
  338. long wearFightingPower = equipItem?.FightingPower ?? 0;
  339. if (compareFightingPower > wearFightingPower)
  340. compareFlag = 1;
  341. }
  342. return compareFlag;
  343. }
  344. /// <summary>
  345. /// 打开恭喜获得界面是否需要显示一键处理按钮
  346. /// </summary>
  347. /// <returns></returns>
  348. private bool IsShowOneKeyBtn(List<KindItem> dropItems)
  349. {
  350. bool bShowBtn = false;
  351. if (dropItems.Count > 0)
  352. {
  353. for (int i = 0; i < dropItems.Count; i++)
  354. {
  355. if (dropItems[i].count == 0)
  356. {
  357. return true;
  358. }
  359. }
  360. }
  361. return bShowBtn;
  362. }
  363. private void OnchangBagState(bool bOpen)
  364. {
  365. VM.BagBtn.GetController("State").selectedIndex = bOpen ? 1 : 0;
  366. }
  367. /// <summary>
  368. /// 打开龙蛋宝藏
  369. /// </summary>
  370. private void OpenDragonTreasure()
  371. {
  372. int itemId = GetTreasureChestId();
  373. var boxNum = ItemData.Instance.GetItemNum(itemId);
  374. _useCount = boxNum < _costDragonEggNum ? (int)boxNum : _costDragonEggNum;
  375. DragonEggService.Instance.SendToOpenDragonTreasure(itemId, _useCount);
  376. }
  377. /// <summary>
  378. /// 开龙蛋宝箱的掉落动画
  379. /// </summary>
  380. private void PlayDropAni()
  381. {
  382. OnchangBagState(true);
  383. int count = DragonEggData.Instance.DropItems.Count - 1;
  384. for (int i = 0; i < DragonEggData.Instance.DropItems.Count; i++)
  385. {
  386. var itemData = DragonEggData.Instance.DropItems[i];
  387. if (itemData != null)
  388. {
  389. ShowFlyIconView(GetItemId(itemData), i == count);
  390. }
  391. }
  392. }
  393. /// <summary>
  394. /// 获取道具tableId
  395. /// </summary>
  396. /// <param name="itemData"></param>
  397. /// <returns></returns>
  398. private int GetItemId(KindItem itemData)
  399. {
  400. if (itemData?.count == 0)
  401. {
  402. var equipData = EquipData.Instance.GetTemporaryEquipItem(itemData.id);
  403. return equipData == null ? 0 : equipData.TableId;
  404. }
  405. else
  406. {
  407. // 非装备的物品道具
  408. return itemData.id;
  409. }
  410. }
  411. /// <summary>
  412. /// 宝箱按钮领取状态
  413. /// </summary>
  414. /// <param name="bGray"></param>
  415. private void OnchangeAwardState(bool bAward)
  416. {
  417. VM.AwardState.selectedIndex = bAward ? 1 : 0;
  418. }
  419. private void OnSelectDragon(int index)
  420. {
  421. VM.MenusBtnCtrl.selectedIndex = index;
  422. ShowSelectDragonUI();
  423. }
  424. /// <summary>
  425. /// 获取当前选择的龙蛋道具id
  426. /// </summary>
  427. /// <returns></returns>
  428. private int GetTreasureChestId()
  429. {
  430. return DragonEggData.Instance.GetTreasureChestId(VM.MenusBtnCtrl.selectedIndex);
  431. }
  432. /// <summary>
  433. /// 当前选中的龙蛋
  434. /// </summary>
  435. private void ShowSelectDragonUI()
  436. {
  437. int selectedIndex = VM.MenusBtnCtrl.selectedIndex;
  438. ShowDragonName(selectedIndex);
  439. int itemId = GetTreasureChestId();
  440. var itemInfo = ItemTableRepo.Get(itemId);
  441. if (itemInfo != null)
  442. {
  443. bool bShowDesc = itemInfo?.Desc.Length > 0;
  444. VM.ProbalityLabel.visible = bShowDesc;
  445. VM.DescBg.visible = bShowDesc;
  446. if (bShowDesc)
  447. VM.ProbalityLabel.text = itemInfo.Desc;
  448. }
  449. ShowDragonBoxNum(ItemData.Instance.GetItemNum(itemId));
  450. // 获取龙的spine
  451. LoadDragonSpine("box_skeletondata");
  452. ShowDragonSpine(false);
  453. }
  454. /// <summary>
  455. /// 龙蛋按钮菜单栏变化
  456. /// </summary>
  457. /// <param name="context"></param>
  458. private void OnMenusBtnCtrlChange(EventContext context)
  459. {
  460. ShowSelectDragonUI();
  461. }
  462. private void ShowDragonName(int selectedIndex)
  463. {
  464. VM.PreviousBtn.visible = selectedIndex != 0;
  465. VM.NextBtn.visible = selectedIndex != 4;
  466. }
  467. /// <summary>
  468. /// 领取龙蛋积分宝箱后龙蛋进度条积分变化
  469. /// </summary>
  470. private void RefreshTreasureProgressUI(int eventId, object args)
  471. {
  472. if (_treasureRewardId > 0)
  473. {
  474. var obtainData = new ObtainItemsParam()
  475. {
  476. dropItems = new List<KindItem>() { new KindItem() { id = _treasureRewardId, count = 1 } },
  477. bShowBtn = false
  478. };
  479. Context.UI.OpenAsync(UIKeys.ItemGetItemPanel, obtainData);
  480. }
  481. var treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  482. if (treasureInfo != null)
  483. {
  484. ShowDragonTreasureUI(treasureInfo);
  485. }
  486. }
  487. /// <summary>
  488. /// 宝藏积分UI
  489. /// </summary>
  490. /// <param name="treasureInfo"></param>
  491. private void ShowDragonTreasureUI(treasureBonusTable treasureInfo)
  492. {
  493. if (treasureInfo == null)
  494. {
  495. treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  496. }
  497. if (treasureInfo == null) return;
  498. _maxTreasureSocre = treasureInfo.Progress;
  499. var itemInfo = ItemTableRepo.Get(treasureInfo.Reward);
  500. if (itemInfo != null)
  501. {
  502. _treasureChestName = itemInfo.Name;
  503. _treasureRewardId = itemInfo.Id;
  504. }
  505. ShowDragonEggScoreUI(false);
  506. int index = DragonEggData.Instance.GetTreasureChestIndex(treasureInfo.Reward);
  507. if (index > 0)
  508. {
  509. VM.BoxAwardBtn.GetController("c1").selectedIndex = index - 1;
  510. }
  511. }
  512. /// <summary>
  513. /// 龙蛋开箱动画
  514. /// </summary>
  515. private void OpenDragonEggBoxAni()
  516. {
  517. ShowDragonSpine(true);
  518. if (VM.DragonSpine.Play("box_open", false))
  519. {
  520. ClearOpenTimer();
  521. _openBoxTimer = Context.Time.AddDelayTimer(VM.DragonSpine.spineAnimation.GetDurationMS(), () =>
  522. {
  523. VM.DragonSpine.Play("box_idle", true);
  524. ShowDragonSpine(false);
  525. });
  526. }
  527. }
  528. /// <summary>
  529. /// 请求宝箱消息返回,刷新UI信息
  530. /// </summary>
  531. /// <param name="eventId"></param>
  532. /// <param name="args"></param>
  533. private void RefreshTreasureUI(int eventId, object args)
  534. {
  535. ShowUI();
  536. }
  537. /// <summary>
  538. /// 成功开启龙蛋
  539. /// </summary>
  540. /// <param name="eventId"></param>
  541. /// <param name="args"></param>
  542. private void OpenDragonTreasureSucess(int eventId, object args)
  543. {
  544. if (DragonEggData.Instance.DropItems?.Count > 0)
  545. {
  546. PlayDropAni();
  547. }
  548. ShowDragonBoxNum(ItemData.Instance.GetItemNum(GetTreasureChestId()));
  549. }
  550. /// <summary>
  551. /// 宝箱等级变化
  552. /// </summary>
  553. /// <param name="eventId"></param>
  554. /// <param name="args"></param>
  555. private void RefreshTreasureChestUI(int eventId, object args)
  556. {
  557. ShowDragonLv();
  558. }
  559. /// <summary>
  560. /// 道具变化
  561. /// </summary>
  562. /// <param name="eventId"></param>
  563. /// <param name="args"></param>
  564. private void UpdataItemData(int eventId, object args)
  565. {
  566. var itemDataList = args as List<ActItem>;
  567. if (itemDataList?.Count > 0)
  568. {
  569. int itemId = GetTreasureChestId();
  570. for (int i = 0; i < itemDataList.Count; i++)
  571. {
  572. if (itemDataList[i].count > 0 && itemDataList[i].id == itemId)
  573. {
  574. ShowDragonBoxNum(ItemData.Instance.GetItemNum(itemId));
  575. return;
  576. }
  577. }
  578. }
  579. }
  580. private void ClearOpenTimer()
  581. {
  582. if (_openBoxTimer != null)
  583. {
  584. _openBoxTimer.Cancel();
  585. _openBoxTimer = null;
  586. }
  587. }
  588. /// <summary>
  589. /// 打开装备背包
  590. /// </summary>
  591. /// <param name="eventId"></param>
  592. /// <param name="args"></param>
  593. private void OpenEquipBag(int eventId, object args)
  594. {
  595. Context.UI.OpenAsync(UIKeys.TemporaryEquipBagPanel);
  596. }
  597. }
  598. }