DragonEggTreasurePanelCtrl.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 _selectIndex; // 当前选择的龙索引
  27. private int _useCount; // 使用的品质宝箱数量
  28. private int _maxTreasureSocre; // 当前宝藏进度的最大积分值
  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(intent as int[]);
  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. Context.AddListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  135. Context.AddListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  136. Context.AddListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  137. Context.AddListener(EventDefine.OpenEquipBag, OpenEquipBag);
  138. Context.AddListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  139. Context.AddListener(EventDefine.UpdataItemData, UpdataItemData);
  140. }
  141. private void RemoveEventListener()
  142. {
  143. Context.RemoveListener(EventDefine.RefreshTreasureProgressUI, RefreshTreasureProgressUI);
  144. Context.RemoveListener(EventDefine.RefreshTreasureUI, RefreshTreasureUI);
  145. Context.RemoveListener(EventDefine.OpenDragonTreasureSucess, OpenDragonTreasureSucess);
  146. Context.RemoveListener(EventDefine.OpenEquipBag, OpenEquipBag);
  147. Context.RemoveListener(EventDefine.RefreshTreasureChestUI, RefreshTreasureChestUI);
  148. Context.RemoveListener(EventDefine.UpdataItemData, UpdataItemData);
  149. }
  150. private void Init(int[] paramArray)
  151. {
  152. _selectIndex = paramArray?.Length > 0 ? paramArray[0] : -1;
  153. _bFlyingAni = false;
  154. var startPos = VM.DragonSpineBtn.displayObject.TransformPoint(new Vector2(VM.DragonSpineBtn.width / 3, VM.DragonSpineBtn.height / 2), VM.DragonSpineBtn.displayObject);
  155. _startPos = new Vector3(startPos.x, startPos.y, 0);
  156. var endPos = VM.BagBtn.displayObject.TransformPoint(new Vector3(VM.BagBtn.width/10, VM.BagBtn.height/8), VM.DragonSpine.displayObject);
  157. _endPos = new Vector3(endPos.x, endPos.y, 0);
  158. ShowUI();
  159. DragonEggService.Instance.SendToTreasureInfo();
  160. }
  161. private void ShowUI()
  162. {
  163. InitDrangonBoxUI();
  164. ShowDragonTreasureUI(null);
  165. ShowDragonLv();
  166. }
  167. private void ShowDragonLv()
  168. {
  169. VM.LevelBtn.title = $"LV.{DragonEggData.Instance.Level}";
  170. }
  171. /// <summary>
  172. /// 加载龙的spine
  173. /// </summary>
  174. /// <param name="spineName"></param>
  175. private void LoadDragonSpine(string spineName)
  176. {
  177. VM.DragonSpine.LoadSpine(spineName, "box_idle", true);
  178. }
  179. /// <summary>
  180. /// 是否显示龙的spine模型
  181. /// </summary>
  182. /// <param name="bShow"></param>
  183. private void ShowDragonSpine(bool bShow)
  184. {
  185. VM.DragonSpine.visible = bShow;
  186. VM.DragonIcon.visible = !bShow;
  187. }
  188. /// <summary>
  189. /// 龙蛋积分变化
  190. /// </summary>
  191. /// <param name="addScore"></param>
  192. /// <param name="bTweenValue"></param>
  193. private void ShowDragonEggScoreUI(bool bTweenValue)
  194. {
  195. VM.EggPointBar.max = _maxTreasureSocre;
  196. if (bTweenValue)
  197. VM.EggPointBar.TweenValue(DragonEggData.Instance.DragonTreasureSocre, 0.5f);
  198. else
  199. VM.EggPointBar.value = DragonEggData.Instance.DragonTreasureSocre;
  200. OnchangeAwardState(DragonEggData.Instance.DragonTreasureSocre >= _maxTreasureSocre);
  201. int subSocre = _maxTreasureSocre > DragonEggData.Instance.DragonTreasureSocre ? _maxTreasureSocre - DragonEggData.Instance.DragonTreasureSocre : 0;
  202. VM.ScoreAwardLabel.text = string.Format(StringDefine.dragonTreasureScore, subSocre, _treasureChestName);
  203. }
  204. private void InitDrangonBoxUI()
  205. {
  206. if (_dragonBtnList == null) _dragonBtnList = new List<GButton>() { VM.DragonBtn1, VM.DragonBtn2, VM.DragonBtn3, VM.DragonBtn4, VM.DragonBtn5 };
  207. for (int i = 0; i < 5; i++)
  208. {
  209. long num = ItemData.Instance.GetItemNum(DragonEggData.Instance.GetTreasureChestId(i));
  210. if (num > 0 && _selectIndex == -1)
  211. {
  212. _selectIndex = i;
  213. ShowDragonBoxNum(num);
  214. }
  215. }
  216. OnSelectDragon(_selectIndex == -1 ? 0 : _selectIndex);
  217. }
  218. /// <summary>
  219. /// 判断龙裔宝卵数量是否
  220. /// </summary>
  221. /// <returns></returns>
  222. private bool IsEmptyBox(bool bShowTip = true)
  223. {
  224. var boxNum = ItemData.Instance.GetItemNum(GetTreasureChestId());
  225. if (boxNum == 0)
  226. {
  227. if (bShowTip)
  228. {
  229. Context.ShowTips(StringDefine.dragonEggsEmpty);
  230. }
  231. return true;
  232. }
  233. return false;
  234. }
  235. /// <summary>
  236. /// 龙蛋品质宝箱数量
  237. /// </summary>
  238. /// <param name="index"></param>
  239. /// <param name="num"></param>
  240. private void ShowDragonBoxNum(long num)
  241. {
  242. VM.NumLabel.text = num.ToString();
  243. }
  244. private void ShowFlyIconView(int itemId, bool bScore)
  245. {
  246. var flyParam = new FlyingIconParam()
  247. {
  248. iconName = ItemTableRepo.Get(itemId).Icon,
  249. startPos = _startPos,
  250. bScore = bScore,
  251. endPos = _endPos,
  252. };
  253. if (_flyingList == null) _flyingList = new HashSet<DragonEggFlyIconView>();
  254. var loadAsync = Context.Asset.LoadFguiNested(UINestedKeys.DragonEggFlyIcon, VM.DragonSpineBtn);
  255. loadAsync.On(_ =>
  256. {
  257. var flyView = loadAsync.Result as DragonEggFlyIconView;
  258. if (flyView != null)
  259. {
  260. flyParam.callback = (bScore) =>
  261. {
  262. FlyingCallback(flyView, bScore);
  263. };
  264. flyView.Ctrl.ShowUI(flyParam);
  265. _flyingList.Add(flyView);
  266. }
  267. });
  268. }
  269. /// <summary>
  270. /// 物品全部飞入背包后的回调函数
  271. /// </summary>
  272. /// <param name="flyView"></param>
  273. /// <param name="bScore"></param>
  274. private void FlyingCallback(DragonEggFlyIconView flyView, bool bScore)
  275. {
  276. _flyingList.Remove(flyView);
  277. Context.Asset.Recycle(flyView);
  278. if (_flyingList.Count == 0) OnchangBagState(false);
  279. if (bScore)
  280. {
  281. ShowDragonEggScoreUI(true);
  282. _bFlyingAni = false;
  283. if (_dropItemList == null) _dropItemList = new List<KindItem>();
  284. else _dropItemList.Clear();
  285. _dropItemList.AddRange(DragonEggData.Instance.DropItems);
  286. //if (_dropItemList.Count > 1)
  287. //{
  288. // OnSortByEquipPower();
  289. //}
  290. //var obtainData = new ObtainItemsParam()
  291. //{
  292. // dropItems = _dropItemList,
  293. // bShowBtn = IsShowOneKeyBtn(DragonEggData.Instance.DropItems),
  294. //};
  295. var loadAsync = Context.UI.OpenAsync(UIKeys.ItemGetItemPanel, _dropItemList);
  296. loadAsync.On(_=>
  297. {
  298. DragonEggData.Instance.DropItems.Clear();
  299. });
  300. };
  301. }
  302. //private void OnSortByEquipPower()
  303. //{
  304. // _dropItemList.Sort((aItem, bItem)=>
  305. // {
  306. // int aEquipFlag = aItem.count == 0 ? 1 : 0;
  307. // int bEquipFlag = bItem.count == 0 ? 1 : 0;
  308. // if (aEquipFlag == bEquipFlag)
  309. // {
  310. // if (aEquipFlag == 1)
  311. // {
  312. // var aEquipData = EquipData.Instance.GetTemporaryEquipItem(aItem.id);
  313. // var bEquipData = EquipData.Instance.GetTemporaryEquipItem(bItem.id);
  314. // var aHighPower = GetCompareValue(aEquipData);
  315. // var bHighPower = GetCompareValue(bEquipData);
  316. // if (aHighPower == bHighPower)
  317. // {
  318. // if (aEquipData.FightingPower == bEquipData.FightingPower)
  319. // {
  320. // return aEquipData.Id.CompareTo(bEquipData.Id); // 升序
  321. // }
  322. // return bEquipData.FightingPower.CompareTo(aEquipData.FightingPower); //降序
  323. // }
  324. // else
  325. // return bHighPower.CompareTo(aHighPower);
  326. // }
  327. // return aItem.count.CompareTo(bItem.count);
  328. // }
  329. // return bEquipFlag.CompareTo(aEquipFlag);//降序
  330. // });
  331. //}
  332. //private int GetCompareValue(EquipItem equipData)
  333. //{
  334. // int compareFlag = 0;
  335. // if (equipData?.Table?.Part > 0)
  336. // {
  337. // long compareFightingPower = equipData?.FightingPower ?? 0;
  338. // var equipItem = EquipData.Instance.GetWearEquipData(equipData.Table.Part);
  339. // long wearFightingPower = equipItem?.FightingPower ?? 0;
  340. // if (compareFightingPower > wearFightingPower)
  341. // compareFlag = 1;
  342. // }
  343. // return compareFlag;
  344. //}
  345. ///// <summary>
  346. ///// 打开恭喜获得界面是否需要显示一键处理按钮
  347. ///// </summary>
  348. ///// <returns></returns>
  349. //private bool IsShowOneKeyBtn(List<KindItem> dropItems)
  350. //{
  351. // bool bShowBtn = false;
  352. // if (dropItems.Count > 0)
  353. // {
  354. // for (int i = 0; i < dropItems.Count; i++)
  355. // {
  356. // if (dropItems[i].count == 0)
  357. // {
  358. // return true;
  359. // }
  360. // }
  361. // }
  362. // return bShowBtn;
  363. //}
  364. private void OnchangBagState(bool bOpen)
  365. {
  366. VM.BagBtn.GetController("State").selectedIndex = bOpen ? 1 : 0;
  367. }
  368. /// <summary>
  369. /// 打开龙蛋宝藏
  370. /// </summary>
  371. private void OpenDragonTreasure()
  372. {
  373. int itemId = GetTreasureChestId();
  374. var boxNum = ItemData.Instance.GetItemNum(itemId);
  375. _useCount = boxNum < _costDragonEggNum ? (int)boxNum : _costDragonEggNum;
  376. DragonEggService.Instance.SendToOpenDragonTreasure(itemId, _useCount);
  377. }
  378. /// <summary>
  379. /// 开龙蛋宝箱的掉落动画
  380. /// </summary>
  381. private void PlayDropAni()
  382. {
  383. OnchangBagState(true);
  384. int count = DragonEggData.Instance.DropItems.Count - 1;
  385. for (int i = 0; i < DragonEggData.Instance.DropItems.Count; i++)
  386. {
  387. var itemData = DragonEggData.Instance.DropItems[i];
  388. if (itemData != null)
  389. {
  390. ShowFlyIconView(GetItemId(itemData), i == count);
  391. }
  392. }
  393. }
  394. /// <summary>
  395. /// 获取道具tableId
  396. /// </summary>
  397. /// <param name="itemData"></param>
  398. /// <returns></returns>
  399. private int GetItemId(KindItem itemData)
  400. {
  401. if (itemData.kind == 1) // 装备
  402. {
  403. var equipData = EquipData.Instance.GetTemporaryEquipItem(itemData.id);
  404. return equipData == null ? 0 : equipData.TableId;
  405. }
  406. else
  407. {
  408. // 非装备的物品道具
  409. return itemData.id;
  410. }
  411. }
  412. /// <summary>
  413. /// 宝箱按钮领取状态
  414. /// </summary>
  415. /// <param name="bGray"></param>
  416. private void OnchangeAwardState(bool bAward)
  417. {
  418. VM.AwardState.selectedIndex = bAward ? 1 : 0;
  419. }
  420. private void OnSelectDragon(int index)
  421. {
  422. VM.MenusBtnCtrl.selectedIndex = index;
  423. ShowSelectDragonUI();
  424. }
  425. /// <summary>
  426. /// 获取当前选择的龙蛋道具id
  427. /// </summary>
  428. /// <returns></returns>
  429. private int GetTreasureChestId()
  430. {
  431. return DragonEggData.Instance.GetTreasureChestId(VM.MenusBtnCtrl.selectedIndex);
  432. }
  433. /// <summary>
  434. /// 当前选中的龙蛋
  435. /// </summary>
  436. private void ShowSelectDragonUI()
  437. {
  438. int selectedIndex = VM.MenusBtnCtrl.selectedIndex;
  439. ShowDragonName(selectedIndex);
  440. int itemId = GetTreasureChestId();
  441. var itemInfo = ItemTableRepo.Get(itemId);
  442. if (itemInfo != null)
  443. {
  444. bool bShowDesc = itemInfo?.Desc.Length > 0;
  445. VM.ProbalityLabel.visible = bShowDesc;
  446. VM.DescBg.visible = bShowDesc;
  447. if (bShowDesc)
  448. VM.ProbalityLabel.text = itemInfo.Desc;
  449. }
  450. ShowDragonBoxNum(ItemData.Instance.GetItemNum(itemId));
  451. // 获取龙的spine
  452. LoadDragonSpine("box_skeletondata");
  453. ShowDragonSpine(false);
  454. }
  455. /// <summary>
  456. /// 龙蛋按钮菜单栏变化
  457. /// </summary>
  458. /// <param name="context"></param>
  459. private void OnMenusBtnCtrlChange(EventContext context)
  460. {
  461. ShowSelectDragonUI();
  462. }
  463. private void ShowDragonName(int selectedIndex)
  464. {
  465. VM.PreviousBtn.visible = selectedIndex != 0;
  466. VM.NextBtn.visible = selectedIndex != 4;
  467. }
  468. /// <summary>
  469. /// 领取龙蛋积分宝箱后龙蛋进度条积分变化
  470. /// </summary>
  471. private void RefreshTreasureProgressUI(int eventId, object args)
  472. {
  473. var rewardItems = DragonEggData.Instance.DragonTreasureRewardItems;
  474. if (rewardItems?.Count > 0)
  475. {
  476. //var obtainData = new ObtainItemsParam()
  477. //{
  478. // dropItems = rewardItems,
  479. // bShowBtn = IsShowOneKeyBtn(rewardItems),
  480. //};
  481. var loadAsync = Context.UI.OpenAsync(UIKeys.ItemGetItemPanel, rewardItems);
  482. loadAsync.On(_ =>
  483. {
  484. DragonEggData.Instance.DragonTreasureRewardItems.Clear();
  485. });
  486. }
  487. var treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  488. if (treasureInfo != null)
  489. {
  490. ShowDragonTreasureUI(treasureInfo);
  491. }
  492. }
  493. /// <summary>
  494. /// 宝藏积分UI
  495. /// </summary>
  496. /// <param name="treasureInfo"></param>
  497. private void ShowDragonTreasureUI(treasureBonusTable treasureInfo)
  498. {
  499. if (treasureInfo == null)
  500. {
  501. treasureInfo = treasureBonusTableRepo.Get(DragonEggData.Instance.DragonTreasureId);
  502. }
  503. if (treasureInfo == null) return;
  504. _maxTreasureSocre = treasureInfo.Progress;
  505. var itemInfo = ItemTableRepo.Get(treasureInfo.Reward);
  506. if (itemInfo != null)
  507. {
  508. _treasureChestName = itemInfo.Name;
  509. //_treasureRewardId = itemInfo.Id;
  510. }
  511. ShowDragonEggScoreUI(false);
  512. int index = DragonEggData.Instance.GetTreasureChestIndex(treasureInfo.Reward);
  513. if (index > 0)
  514. {
  515. VM.BoxAwardBtn.GetController("c1").selectedIndex = index - 1;
  516. }
  517. }
  518. /// <summary>
  519. /// 龙蛋开箱动画
  520. /// </summary>
  521. private void OpenDragonEggBoxAni()
  522. {
  523. ShowDragonSpine(true);
  524. if (VM.DragonSpine.Play("box_open", false))
  525. {
  526. ClearOpenTimer();
  527. _openBoxTimer = Context.Time.AddDelayTimer(VM.DragonSpine.spineAnimation.GetDurationMS(), () =>
  528. {
  529. VM.DragonSpine.Play("box_idle", true);
  530. ShowDragonSpine(false);
  531. });
  532. }
  533. }
  534. /// <summary>
  535. /// 请求宝箱消息返回,刷新UI信息
  536. /// </summary>
  537. /// <param name="eventId"></param>
  538. /// <param name="args"></param>
  539. private void RefreshTreasureUI(int eventId, object args)
  540. {
  541. ShowUI();
  542. }
  543. /// <summary>
  544. /// 成功开启龙蛋
  545. /// </summary>
  546. /// <param name="eventId"></param>
  547. /// <param name="args"></param>
  548. private void OpenDragonTreasureSucess(int eventId, object args)
  549. {
  550. if (DragonEggData.Instance.DropItems?.Count > 0)
  551. {
  552. PlayDropAni();
  553. }
  554. ShowDragonBoxNum(ItemData.Instance.GetItemNum(GetTreasureChestId()));
  555. }
  556. /// <summary>
  557. /// 宝箱等级变化
  558. /// </summary>
  559. /// <param name="eventId"></param>
  560. /// <param name="args"></param>
  561. private void RefreshTreasureChestUI(int eventId, object args)
  562. {
  563. ShowDragonLv();
  564. }
  565. /// <summary>
  566. /// 道具变化
  567. /// </summary>
  568. /// <param name="eventId"></param>
  569. /// <param name="args"></param>
  570. private void UpdataItemData(int eventId, object args)
  571. {
  572. var itemDataList = args as List<ActItem>;
  573. if (itemDataList?.Count > 0)
  574. {
  575. int itemId = GetTreasureChestId();
  576. for (int i = 0; i < itemDataList.Count; i++)
  577. {
  578. if (itemDataList[i].count > 0 && itemDataList[i].id == itemId)
  579. {
  580. ShowDragonBoxNum(ItemData.Instance.GetItemNum(itemId));
  581. return;
  582. }
  583. }
  584. }
  585. }
  586. private void ClearOpenTimer()
  587. {
  588. if (_openBoxTimer != null)
  589. {
  590. _openBoxTimer.Cancel();
  591. _openBoxTimer = null;
  592. }
  593. }
  594. /// <summary>
  595. /// 打开装备背包
  596. /// </summary>
  597. /// <param name="eventId"></param>
  598. /// <param name="args"></param>
  599. private void OpenEquipBag(int eventId, object args)
  600. {
  601. Context.UI.OpenAsync(UIKeys.TemporaryEquipBagPanel);
  602. }
  603. }
  604. }