DressUpObj.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using System.Linq;
  5. using ET;
  6. using FairyGUI;
  7. namespace GFGGame
  8. {
  9. public enum DressUpOption
  10. {
  11. Auto,
  12. Add,
  13. Remove
  14. }
  15. public class DressUpObj
  16. {
  17. public int bgId
  18. {
  19. get
  20. {
  21. return _dressUpData.bgId;
  22. }
  23. }
  24. public int suitId
  25. {
  26. get
  27. {
  28. return _dressUpData.suitId;
  29. }
  30. }
  31. public int actionId
  32. {
  33. get
  34. {
  35. return _dressUpData.actionId;
  36. }
  37. }
  38. public bool IsAction
  39. {
  40. get
  41. {
  42. return _dressUpData.actionId > 0;
  43. }
  44. }
  45. public List<int> itemList
  46. {
  47. get
  48. {
  49. return _dressUpData.itemList.ToList();
  50. }
  51. }
  52. private Action onUpdateAction;
  53. /// <summary>
  54. ///
  55. /// </summary>
  56. /// <param name="sceneObj"></param>
  57. /// <param name="needSetMask"></param>
  58. /// <param name="showSceneType"></param>
  59. /// <param name="roleObj"></param>
  60. /// <param name="showBg"></param>
  61. /// <param name="resetData">是否重置装备数据</param>
  62. public void setSceneObj(GameObject sceneObj, bool needSetMask = false, bool showSceneType = true, GameObject roleObj = null, bool showBg = true, Action onUpdateAction = null)
  63. {
  64. if (_sceneObj != null && _sceneObj != sceneObj)
  65. {
  66. PrefabManager.Instance.Restore(_sceneObj);
  67. }
  68. _sceneObj = sceneObj;
  69. _needSetMask = needSetMask;
  70. _showSceneType = showSceneType;
  71. _showBg = showBg;
  72. _roleObj = roleObj;
  73. this.onUpdateAction = onUpdateAction;
  74. if (_dressUpData.IsNew)
  75. {
  76. PutOnDefaultDressUpData();
  77. }
  78. else
  79. {
  80. var tempData = DressUpDataClone();
  81. TakeOffAll(false);
  82. PutOnDressUpData(tempData);
  83. }
  84. Timers.inst.AddUpdate(OnUpdate);
  85. }
  86. public DressUpData DressUpDataClone()
  87. {
  88. return _dressUpData.Clone();
  89. }
  90. public void Dispose()
  91. {
  92. _sceneObj = null;
  93. _dressUpData = null;
  94. Timers.inst.Remove(OnUpdate);
  95. foreach (var t in handlers)
  96. {
  97. t.Release();
  98. }
  99. onUpdateAction = null;
  100. }
  101. private void ClearView()
  102. {
  103. Timers.inst.Remove(OnUpdate);
  104. foreach (var t in handlers)
  105. {
  106. t.Cancel();
  107. t.Release();
  108. }
  109. }
  110. //传入一个服装部件Id,判断是否有与此部件同类型服装已穿着
  111. public bool CheckSameTypeIsOn(int itemId)
  112. {
  113. int subType = ItemUtilCS.GetItemSubType(itemId);
  114. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  115. {
  116. int _subType = ItemUtilCS.GetItemSubType(_dressUpData.itemList[i]);
  117. if (subType == _subType) return true;
  118. }
  119. return false;
  120. }
  121. /// <summary>
  122. /// 仅判断换装部件是否已穿着
  123. /// </summary>
  124. /// <param name="itemId"></param>
  125. /// <returns></returns>
  126. public bool CheckDressUpItemIsOn(int itemId)
  127. {
  128. if (itemId == _dressUpData.bgId)
  129. {
  130. return true;
  131. }
  132. return _dressUpData.itemList.Contains(itemId);
  133. }
  134. /// <summary>
  135. /// 仅判断套装是否穿上
  136. /// </summary>
  137. /// <param name="id"></param>
  138. /// <returns></returns>
  139. public bool CheckSuitIsOn(int id)
  140. {
  141. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  142. if (suitCfg == null)
  143. {
  144. return false;
  145. }
  146. int[] items = suitCfg.partsArr;
  147. foreach (int itemId in items)
  148. {
  149. if (_dressUpData.actionId == id)
  150. {
  151. if (SuitCfgArray.Instance.CheckActionContainsItem(itemId, id))
  152. {
  153. continue;
  154. }
  155. }
  156. bool isOn = CheckDressUpItemIsOn(itemId);
  157. if (!isOn)
  158. {
  159. return false;
  160. }
  161. }
  162. return true;
  163. }
  164. public void AddOrRemove(int itemId, bool checkDefault, DressUpOption dressUpOption = DressUpOption.Auto)
  165. {
  166. int subType = ItemUtilCS.GetItemSubType(itemId);
  167. if (subType == ConstDressUpItemType.BEI_JING)
  168. {
  169. if (!_showBg)
  170. {
  171. return;
  172. }
  173. _dressUpData.bgId = itemId;
  174. List<DressUpLayerOperation> handlers = DressUpUtil.AddItemAsync(_dressUpData.bgId, _sceneObj, _needSetMask, true, _roleObj);
  175. TryAddHandlers(handlers);
  176. }
  177. else
  178. {
  179. if (!CheckDressUpItemIsOn(itemId))
  180. {
  181. if (dressUpOption != DressUpOption.Remove)
  182. {
  183. if (checkDefault)
  184. {
  185. TryCancelActionWhenPutOn(itemId);
  186. }
  187. CheckRemoveSameType(subType);
  188. Add(itemId);
  189. }
  190. }
  191. else
  192. {
  193. if (dressUpOption != DressUpOption.Add)
  194. {
  195. Remove(itemId);
  196. }
  197. }
  198. if (checkDefault)
  199. {
  200. checkDefaultItem();
  201. }
  202. }
  203. }
  204. //脱掉所有换装,换成默认装(不处理背景)
  205. public void TakeOffAll(bool checkDefault = true)
  206. {
  207. if(_sceneObj == null)
  208. {
  209. return;
  210. }
  211. _dressUpData.suitId = 0;
  212. _dressUpData.actionId = 0;
  213. foreach (int itemID in itemList)
  214. {
  215. AddOrRemove(itemID, false, DressUpOption.Remove);
  216. }
  217. if (checkDefault)
  218. {
  219. checkDefaultItem();
  220. }
  221. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  222. // FightDataManager.Instance.score = roleLevelCfg.baseScore;
  223. // foreach (int itemId in _dressUpData.itemList)
  224. // {
  225. // FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  226. // }
  227. }
  228. //穿上或脱掉一个动作
  229. public void PutOnOrTakeOffAction(int actionId)
  230. {
  231. if (_dressUpData.actionId == actionId)
  232. {
  233. CancelAction();
  234. }
  235. else
  236. {
  237. PutOnAction(actionId);
  238. }
  239. }
  240. /// <summary>
  241. /// 尝试穿戴配置套装
  242. /// </summary>
  243. /// <param name="suitId">套装id</param>
  244. /// <param name="tryShowAction">尝试穿上动作</param>
  245. /// <param name="excludeType">排除类型列表</param>
  246. /// <param name="showOptional">是否显示可选部件</param>
  247. /// <param name="CheckOwn">是否只显示主角拥有的部件</param>
  248. public void PutOnSuitCfg(int suitId, bool tryShowAction, int[] excludeType = null, bool showOptional = true, bool CheckOwn = true)
  249. {
  250. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  251. if(suitCfg == null)
  252. {
  253. return;
  254. }
  255. bool oldIsAction = IsAction;
  256. _dressUpData.suitId = suitId;
  257. bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(_dressUpData.suitId);
  258. _dressUpData.actionId = (hasSuitActionRes && tryShowAction) ? suitId : 0;
  259. List<int> items = new List<int>(suitCfg.partsArr);
  260. if (showOptional)
  261. {
  262. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  263. {
  264. items.AddRange(suitCfg.partsOptionalArr);
  265. }
  266. }
  267. int subType = 0;
  268. //找到要穿的散件
  269. List<int> targetItemList = new List<int>();
  270. foreach (int itemId in items)
  271. {
  272. if (!CheckOwn || DressUpMenuItemDataManager.CheckHasItem(itemId))
  273. {
  274. subType = ItemUtilCS.GetItemSubType(itemId);
  275. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  276. if (!IsAction || notInAction)
  277. {
  278. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  279. {
  280. targetItemList.Add(itemId);
  281. }
  282. }
  283. }
  284. }
  285. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  286. checkDefaultItem();
  287. }
  288. //取消动作
  289. public void CancelAction(bool changeToStand = false)
  290. {
  291. if (_dressUpData.actionId <= 0)
  292. {
  293. return;
  294. }
  295. var tempActionId = _dressUpData.actionId;
  296. _dressUpData.actionId = 0;
  297. //更新非场景类型部件形态
  298. foreach (int itemId in itemList)
  299. {
  300. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  301. {
  302. //场景类型不受动作影响并且本来就有动画,对非场景类型处理
  303. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  304. if (notInAction)
  305. {
  306. //更新成图片模式
  307. Update(itemId);
  308. }
  309. }
  310. }
  311. if (changeToStand)
  312. {
  313. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(tempActionId);
  314. List<int> items = new List<int>(suitCfg.partsArr);
  315. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  316. {
  317. items.AddRange(suitCfg.partsOptionalArr);
  318. }
  319. foreach (int itemId in items)
  320. {
  321. if (DressUpMenuItemDataManager.CheckHasItem(itemId))
  322. {
  323. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  324. if (!notInAction)
  325. {
  326. AddOrRemove(itemId, false, DressUpOption.Add);
  327. }
  328. }
  329. }
  330. }
  331. checkDefaultItem();
  332. }
  333. //穿戴一组换装数据
  334. public void PutOnDressUpData(DressUpData targetDressUpData, int[] excludeType = null)
  335. {
  336. bool oldIsAction = IsAction;
  337. _dressUpData.suitId = targetDressUpData.suitId;
  338. _dressUpData.actionId = targetDressUpData.actionId;
  339. var targetItemList = new List<int>();
  340. foreach(var itemId in targetDressUpData.itemList)
  341. {
  342. int subType = ItemUtilCS.GetItemSubType(itemId);
  343. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  344. {
  345. targetItemList.Add(itemId);
  346. }
  347. }
  348. if (targetDressUpData.bgId > 0 && (excludeType == null || Array.IndexOf(excludeType, ConstDressUpItemType.BEI_JING) < 0))
  349. {
  350. targetItemList.Add(targetDressUpData.bgId);
  351. }
  352. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  353. checkDefaultItem();
  354. }
  355. //穿戴默认换装数据
  356. public void PutOnDefaultDressUpData(bool bgType = false)
  357. {
  358. var dressUpData = DressUpData.CreateDefault();
  359. if (bgType) {
  360. dressUpData.bgId = 180002;
  361. }
  362. PutOnDressUpData(dressUpData);
  363. }
  364. //穿戴一组散件数据(会脱掉不包含的部分)
  365. public void PutOnItemList(List<int> targetItemList)
  366. {
  367. bool oldIsAction = IsAction;
  368. _dressUpData.suitId = 0;
  369. _dressUpData.actionId = 0;
  370. CompareAndAddItemList(oldIsAction, IsAction, targetItemList);
  371. checkDefaultItem();
  372. }
  373. #region private
  374. private GameObject _sceneObj;
  375. private GameObject _roleObj;
  376. private bool _needSetMask;
  377. private bool _showSceneType = true;
  378. private bool _showBg = true;
  379. private DressUpData _dressUpData = new DressUpData();
  380. private List<DressUpOperationBase> handlers = new List<DressUpOperationBase>();
  381. //穿上一个动作
  382. private void PutOnAction(int actionId)
  383. {
  384. bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(actionId);
  385. _dressUpData.actionId = actionId;
  386. if (hasSuitActionRes)
  387. {
  388. foreach (int itemId in itemList)
  389. {
  390. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  391. {
  392. //场景类型不受动作影响并且本来就有动画,对非场景类型处理
  393. bool notInAction = SuitCfgArray.Instance.CheckItemNotInAction(itemId);
  394. if (notInAction)
  395. {
  396. //更新成动画模式
  397. Update(itemId);
  398. }
  399. else
  400. {
  401. AddOrRemove(itemId, false, DressUpOption.Remove);
  402. }
  403. }
  404. }
  405. }
  406. else
  407. {
  408. CancelAction(true);
  409. }
  410. checkDefaultItem();
  411. }
  412. //当穿一件部件时检查是否需要取消动作,如果需要则取消该动作
  413. private void TryCancelActionWhenPutOn(int itemId)
  414. {
  415. if (_dressUpData.actionId > 0)
  416. {
  417. bool replaceableByAction = SuitCfgArray.Instance.CheckItemReaplaceableOnAction(itemId, _dressUpData.actionId);
  418. if (!replaceableByAction)
  419. {
  420. CancelAction();
  421. _dressUpData.actionId = 0;
  422. }
  423. }
  424. }
  425. private void Add(int itemId)
  426. {
  427. if (!_showSceneType)
  428. {
  429. if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId))
  430. {
  431. return;
  432. }
  433. }
  434. if (!_dressUpData.itemList.Contains(itemId))
  435. {
  436. _dressUpData.itemList.Add(itemId);
  437. Update(itemId);
  438. }
  439. }
  440. private void Update(int itemId)
  441. {
  442. bool showAni = IsAction || DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId);
  443. var handlers = DressUpUtil.AddItemAsync(itemId, _sceneObj, _needSetMask, showAni, _roleObj);
  444. TryAddHandlers(handlers);
  445. }
  446. private void Remove(int itemId)
  447. {
  448. if (_dressUpData.itemList == null)
  449. {
  450. return;
  451. }
  452. if (_dressUpData.itemList.Contains(itemId))
  453. {
  454. _dressUpData.itemList.Remove(itemId);
  455. var handler = DressUpUtil.RemoveItemAsync(itemId, _sceneObj, _roleObj);
  456. TryAddHandler(handler);
  457. }
  458. }
  459. private void CheckRemoveSameType(int type)
  460. {
  461. int count = 0;
  462. int firstTeshuId = 0;
  463. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  464. {
  465. int itemID = (int)_dressUpData.itemList[i];
  466. int subType = ItemUtilCS.GetItemSubType(itemID);
  467. if (subType == type
  468. || (type == ConstDressUpItemType.LIAN_YI_QUN && (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA))
  469. || (type == ConstDressUpItemType.SHANG_YI && subType == ConstDressUpItemType.LIAN_YI_QUN)
  470. || (type == ConstDressUpItemType.XIA_ZHUANG && subType == ConstDressUpItemType.LIAN_YI_QUN)
  471. || (type == ConstDressUpItemType.NEI_DA && subType == ConstDressUpItemType.LIAN_YI_QUN))
  472. {
  473. Remove(itemID);
  474. i--;
  475. }
  476. if (subType > ConstDressUpItemType.TE_SHU)
  477. {
  478. if (count == 0)
  479. {
  480. firstTeshuId = itemID;
  481. }
  482. count++;
  483. }
  484. }
  485. if (type > ConstDressUpItemType.TE_SHU && count >= 3)
  486. {
  487. //特殊饰品最多穿三件,第四件会自动顶掉第一件
  488. Remove(firstTeshuId);
  489. }
  490. }
  491. //与身上的散件对比差异然后添加
  492. private void CompareAndAddItemList(bool oldIsAction, bool newIsAction, List<int> targetItemList)
  493. {
  494. bool actionStatusChanged = (oldIsAction && !newIsAction) || (!oldIsAction && newIsAction);
  495. foreach (int itemID in itemList)
  496. {
  497. if (!targetItemList.Contains(itemID))
  498. {
  499. //移除不穿的部件
  500. AddOrRemove(itemID, false, DressUpOption.Remove);
  501. }
  502. else if (actionStatusChanged)
  503. {
  504. //当动画形态切换时
  505. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID))
  506. {
  507. //非场景类型重穿
  508. Update(itemID);
  509. targetItemList.Remove(itemID);
  510. }
  511. }
  512. }
  513. foreach (int itemID in targetItemList)
  514. {
  515. AddOrRemove(itemID, false, DressUpOption.Add);
  516. }
  517. }
  518. //检测当前穿戴是否是一件完整套装,且只穿了一件套装,返回套装id
  519. private int CheckCurDressIsSuit()
  520. {
  521. var suitId = 0;
  522. var suitIdList = new List<int>();
  523. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  524. {
  525. int itemSuitId = SuitCfgArray.Instance.GetSuitIdOfItem(_dressUpData.itemList[i]);
  526. if (!suitIdList.Contains(itemSuitId))
  527. {
  528. suitIdList.Add(itemSuitId);
  529. }
  530. }
  531. foreach (var itemSuitId in suitIdList)
  532. {
  533. if (CheckSuitIsOn(itemSuitId))
  534. {
  535. suitId = itemSuitId;
  536. break;
  537. }
  538. }
  539. _dressUpData.suitId = suitId;
  540. return _dressUpData.suitId;
  541. }
  542. private void checkDefaultItem()
  543. {
  544. //是否有头发
  545. bool hasFaXing = false;
  546. //检查默认资源
  547. //是否有连衣裙
  548. bool hasLianYiQun = false;
  549. //是否有内搭
  550. bool hasNeiDa = false;
  551. //是否有上衣
  552. bool hasShangYi = false;
  553. //是否有下装
  554. bool hasXiaZhuang = false;
  555. //是否有默认内搭
  556. bool hasNeiDaDefault = false;
  557. //是否有默认下装
  558. bool hasXiaZhuangDefault = false;
  559. //是否有妆容
  560. bool hasZhuangRong = false;
  561. for (int i = 0; i < _dressUpData.itemList.Count; i++)
  562. {
  563. int itemID = (int)_dressUpData.itemList[i];
  564. int subType = ItemUtilCS.GetItemSubType(itemID);
  565. if (subType == (int)ConstDressUpItemType.FA_XING)
  566. {
  567. hasFaXing = true;
  568. }
  569. else if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  570. {
  571. hasLianYiQun = true;
  572. }
  573. else if (subType == ConstDressUpItemType.NEI_DA)
  574. {
  575. hasNeiDa = true;
  576. }
  577. else if (subType == ConstDressUpItemType.XIA_ZHUANG)
  578. {
  579. hasXiaZhuang = true;
  580. }
  581. else if (subType == ConstDressUpItemType.SHANG_YI)
  582. {
  583. hasShangYi = true;
  584. }
  585. else if (subType == ConstDressUpItemType.ZHUANG_RONG)
  586. {
  587. hasZhuangRong = true;
  588. }
  589. if (itemID == ConstItemID.DEFULT_NEI_DA)
  590. {
  591. hasNeiDaDefault = true;
  592. }
  593. else if (itemID == ConstItemID.DEFULT_XIA_ZHUANG)
  594. {
  595. hasXiaZhuangDefault = true;
  596. }
  597. }
  598. if (!hasFaXing)
  599. {
  600. Add(ConstItemID.DEFULT_FA_XING);
  601. }
  602. if (!IsAction)
  603. {
  604. if (!hasLianYiQun)
  605. {
  606. if (!hasShangYi && (!hasNeiDa || hasNeiDaDefault) && (!hasXiaZhuang || hasXiaZhuangDefault))
  607. {
  608. Remove(ConstItemID.DEFULT_XIA_ZHUANG);
  609. Remove(ConstItemID.DEFULT_NEI_DA);
  610. Add(ConstItemID.DEFULT_LIAN_YI_QUN);
  611. }
  612. else
  613. {
  614. if (!hasXiaZhuang)
  615. {
  616. Add(ConstItemID.DEFULT_XIA_ZHUANG);
  617. }
  618. if (!hasNeiDa)
  619. {
  620. Add(ConstItemID.DEFULT_NEI_DA);
  621. }
  622. }
  623. }
  624. }
  625. CheckCurDressIsSuit();
  626. var handler = DressUpUtil.UpdateHeadAsync(!hasZhuangRong, _sceneObj, _needSetMask, _roleObj);
  627. TryAddHandler(handler);
  628. UpdateBodyView();
  629. }
  630. //更新整个身体
  631. private void UpdateBodyView()
  632. {
  633. string actionRes = null;
  634. if (IsAction)
  635. {
  636. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_dressUpData.actionId);
  637. var hasAniRes = ResPathUtil.CheckDressUpAnimationResExist(suitCfg.aniRes);
  638. actionRes = hasAniRes ? suitCfg.aniRes : null;
  639. }
  640. var handler = DressUpUtil.UpdateBodyAsync(actionRes, _sceneObj, _needSetMask, _roleObj);
  641. TryAddHandler(handler);
  642. }
  643. private void OnUpdate(object param = null)
  644. {
  645. if(_sceneObj == null)
  646. {
  647. ClearView();
  648. return;
  649. }
  650. if(handlers != null && handlers.Count > 0)
  651. {
  652. bool draw = true;
  653. foreach(var handler in handlers)
  654. {
  655. if(!handler.IsDone)
  656. {
  657. draw = false;
  658. }
  659. }
  660. if(draw)
  661. {
  662. var t = handlers.ToArray();
  663. handlers.Clear();
  664. foreach (var handler in t)
  665. {
  666. if(handler.Status == YooAsset.EOperationStatus.Succeed)
  667. {
  668. handler.UpdateView();
  669. }
  670. handler.Release();
  671. }
  672. onUpdateAction?.Invoke();
  673. //Debug.Log($"draw {TimeHelper.ClientNow()}");
  674. }
  675. }
  676. }
  677. private void TryAddHandlers(List<DressUpLayerOperation> t)
  678. {
  679. if (t != null)
  680. {
  681. foreach(var h in t)
  682. {
  683. TryAddHandler(h);
  684. }
  685. //this.handlers.AddRange(t);
  686. }
  687. }
  688. private void TryAddHandler(DressUpOperationBase t)
  689. {
  690. if (t != null)
  691. {
  692. var len = handlers.Count;
  693. for (var i = len - 1; i >= 0; i--)
  694. {
  695. var h = handlers[i];
  696. if (h.CheckRepeated(t))
  697. {
  698. h.Cancel();
  699. h.Release();
  700. handlers.RemoveAt(i);
  701. }
  702. }
  703. this.handlers.Add(t);
  704. }
  705. }
  706. #endregion
  707. }
  708. }