DragonEggTreasurePanelCtrl.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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 string _treasureChestName; // 当前宝藏宝箱名称
  29. private ITimer _openBoxTimer;
  30. private Vector3 _startPos;
  31. private Vector3 _endPos;
  32. private Vector3 _scoreEndPos;
  33. private HashSet<DragonEggFlyIconView> _flyingList;
  34. private List<GButton> _dragonBtnList;
  35. private List<KindItem> _dropItemList;
  36. private const int _costDragonEggNum = 10; // 每次消耗的龙蛋数量
  37. protected override void OnEnable(object intent)
  38. {
  39. AddUIListenres();
  40. AddEventListener();
  41. Init();
  42. }
  43. protected override void OnDisable()
  44. {
  45. RemoveUIListenres();
  46. RemoveEventListener();
  47. ClearOpenTimer();
  48. if (_flyingList != null)
  49. {
  50. foreach (var flying in _flyingList)
  51. {
  52. Context.Asset.Recycle(flying);
  53. }
  54. _flyingList.Clear();
  55. _flyingList = null;
  56. }
  57. if (_dropItemList != null) _dropItemList.Clear();
  58. if (_dragonBtnList != null)
  59. {
  60. _dragonBtnList.Clear();
  61. _dragonBtnList = null;
  62. }
  63. VM.DragonSpine.url = string.Empty;
  64. }
  65. #region UI事件
  66. private void AddUIListenres()
  67. {
  68. VM.NextBtn.onClick.Add(OnClickNextBtn);
  69. VM.PreviousBtn.onClick.Add(OnClickPreviousBtn);
  70. VM.BagBtn.onClick.Add(OnClickBagBtn);
  71. VM.BoxAwardBtn.onClick.Add(OnClickBoxAwardBtn);
  72. VM.DragonSpineBtn.onClick.Add(OnclickDragonSpineBtn);
  73. VM.LevelBtn.onClick.Add(OnClickLevelBtn);
  74. VM.MenusBtnCtrl.onChanged.Add(OnMenusBtnCtrlChange);
  75. }
  76. private void RemoveUIListenres()
  77. {
  78. VM.NextBtn.onClick.Remove(OnClickNextBtn);
  79. VM.PreviousBtn.onClick.Remove(OnClickPreviousBtn);
  80. VM.BagBtn.onClick.Remove(OnClickBagBtn);
  81. VM.BoxAwardBtn.onClick.Remove(OnClickBoxAwardBtn);
  82. VM.DragonSpineBtn.onClick.Remove(OnclickDragonSpineBtn);
  83. VM.LevelBtn.onClick.Remove(OnClickLevelBtn);
  84. VM.MenusBtnCtrl.onChanged.Remove(OnMenusBtnCtrlChange);
  85. }
  86. /// <summary>
  87. /// 打开宝箱等级弹窗界面
  88. /// </summary>
  89. /// <param name="context"></param>
  90. private void OnClickLevelBtn(EventContext context)
  91. {
  92. Context.UI.OpenAsync(UIKeys.TreasureChestUpgradePanel);
  93. }
  94. private void OnClickNextBtn(EventContext context)
  95. {
  96. OnSelectDragon(VM.MenusBtnCtrl.selectedIndex + 1);
  97. }
  98. private void OnClickPreviousBtn(EventContext context)
  99. {
  100. OnSelectDragon(VM.MenusBtnCtrl.selectedIndex - 1);
  101. }
  102. /// <summary>
  103. /// 点击背包按钮
  104. /// </summary>
  105. /// <param name="context"></param>
  106. private void OnClickBagBtn(EventContext context)
  107. {
  108. DragonEggService.Instance.SendToOpenTemporaryEquipBag();
  109. }
  110. /// <summary>
  111. /// 积分进度条满值可领取对应的宝箱奖励
  112. /// </summary>
  113. /// <param name="context"></param>
  114. private void OnClickBoxAwardBtn(EventContext context)
  115. {
  116. DragonEggService.Instance.SendToOpenTreasureBoxAward();
  117. }
  118. private void OnclickDragonSpineBtn(EventContext context)
  119. {
  120. if (_bFlyingAni)
  121. {
  122. //XGame.Log.Info("处于开宝箱状态");
  123. return;
  124. }
  125. if (IsEmptyBox()) return;
  126. _bFlyingAni = true;
  127. OpenDragonEggBoxAni();
  128. OpenDragonTreasure();
  129. }
  130. #endregion
  131. private void AddEventListener()
  132. {
  133. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  134. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  135. EventSingle.Instance.AddListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  136. EventSingle.Instance.AddListener(EventDefine.OpenEquipBag, OpenEquipBag);
  137. EventSingle.Instance.AddListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  138. EventSingle.Instance.AddListener(EventDefine.UpdataItemData, UpdataItemData);
  139. }
  140. private void RemoveEventListener()
  141. {
  142. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  143. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  144. EventSingle.Instance.RemoveListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  145. EventSingle.Instance.RemoveListener(EventDefine.OpenEquipBag, OpenEquipBag);
  146. EventSingle.Instance.RemoveListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  147. EventSingle.Instance.RemoveListener(EventDefine.UpdataItemData, UpdataItemData);
  148. }
  149. private void Init()
  150. {
  151. _bFlyingAni = false;
  152. var startPos = VM.DragonSpineBtn.displayObject.TransformPoint(new Vector2(VM.DragonSpineBtn.width / 3, VM.DragonSpineBtn.height / 2), VM.DragonSpineBtn.displayObject);
  153. _startPos = new Vector3(startPos.x, startPos.y, 0);
  154. var endPos = VM.BagBtn.displayObject.TransformPoint(new Vector3(VM.BagBtn.width/10, VM.BagBtn.height/8), VM.DragonSpine.displayObject);
  155. _endPos = new Vector3(endPos.x, endPos.y, 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. Context.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. var rewardItems = DragonEggData.Instance.DragonTreasureRewardItems;
  473. if (rewardItems?.Count > 0)
  474. {
  475. var obtainData = new ObtainItemsParam()
  476. {
  477. dropItems = rewardItems,
  478. bShowBtn = IsShowOneKeyBtn(rewardItems),
  479. };
  480. var loadAsync = Context.UI.OpenAsync(UIKeys.ItemGetItemPanel, obtainData);
  481. loadAsync.On(_ =>
  482. {
  483. DragonEggData.Instance.DragonTreasureRewardItems.Clear();
  484. });
  485. }
  486. var treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  487. if (treasureInfo != null)
  488. {
  489. ShowDragonTreasureUI(treasureInfo);
  490. }
  491. }
  492. /// <summary>
  493. /// 宝藏积分UI
  494. /// </summary>
  495. /// <param name="treasureInfo"></param>
  496. private void ShowDragonTreasureUI(treasureBonusTable treasureInfo)
  497. {
  498. if (treasureInfo == null)
  499. {
  500. treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  501. }
  502. if (treasureInfo == null) return;
  503. _maxTreasureSocre = treasureInfo.Progress;
  504. var itemInfo = ItemTableRepo.Get(treasureInfo.Reward);
  505. if (itemInfo != null)
  506. {
  507. _treasureChestName = itemInfo.Name;
  508. //_treasureRewardId = itemInfo.Id;
  509. }
  510. ShowDragonEggScoreUI(false);
  511. int index = DragonEggData.Instance.GetTreasureChestIndex(treasureInfo.Reward);
  512. if (index > 0)
  513. {
  514. VM.BoxAwardBtn.GetController("c1").selectedIndex = index - 1;
  515. }
  516. }
  517. /// <summary>
  518. /// 龙蛋开箱动画
  519. /// </summary>
  520. private void OpenDragonEggBoxAni()
  521. {
  522. ShowDragonSpine(true);
  523. if (VM.DragonSpine.Play("box_open", false))
  524. {
  525. ClearOpenTimer();
  526. _openBoxTimer = Context.Time.AddDelayTimer(VM.DragonSpine.spineAnimation.GetDurationMS(), () =>
  527. {
  528. VM.DragonSpine.Play("box_idle", true);
  529. ShowDragonSpine(false);
  530. });
  531. }
  532. }
  533. /// <summary>
  534. /// 请求宝箱消息返回,刷新UI信息
  535. /// </summary>
  536. /// <param name="eventId"></param>
  537. /// <param name="args"></param>
  538. private void RefreshTreasureUI(int eventId, object args)
  539. {
  540. ShowUI();
  541. }
  542. /// <summary>
  543. /// 成功开启龙蛋
  544. /// </summary>
  545. /// <param name="eventId"></param>
  546. /// <param name="args"></param>
  547. private void OpenDragonTreasureSucess(int eventId, object args)
  548. {
  549. if (DragonEggData.Instance.DropItems?.Count > 0)
  550. {
  551. PlayDropAni();
  552. }
  553. ShowDragonBoxNum(ItemData.Instance.GetItemNum(GetTreasureChestId()));
  554. }
  555. /// <summary>
  556. /// 宝箱等级变化
  557. /// </summary>
  558. /// <param name="eventId"></param>
  559. /// <param name="args"></param>
  560. private void RefreshTreasureChestUI(int eventId, object args)
  561. {
  562. ShowDragonLv();
  563. }
  564. /// <summary>
  565. /// 道具变化
  566. /// </summary>
  567. /// <param name="eventId"></param>
  568. /// <param name="args"></param>
  569. private void UpdataItemData(int eventId, object args)
  570. {
  571. var itemDataList = args as List<ActItem>;
  572. if (itemDataList?.Count > 0)
  573. {
  574. int itemId = GetTreasureChestId();
  575. for (int i = 0; i < itemDataList.Count; i++)
  576. {
  577. if (itemDataList[i].count > 0 && itemDataList[i].id == itemId)
  578. {
  579. ShowDragonBoxNum(ItemData.Instance.GetItemNum(itemId));
  580. return;
  581. }
  582. }
  583. }
  584. }
  585. private void ClearOpenTimer()
  586. {
  587. if (_openBoxTimer != null)
  588. {
  589. _openBoxTimer.Cancel();
  590. _openBoxTimer = null;
  591. }
  592. }
  593. /// <summary>
  594. /// 打开装备背包
  595. /// </summary>
  596. /// <param name="eventId"></param>
  597. /// <param name="args"></param>
  598. private void OpenEquipBag(int eventId, object args)
  599. {
  600. Context.UI.OpenAsync(UIKeys.TemporaryEquipBagPanel);
  601. }
  602. }
  603. }