DressUpObj.cs 25 KB

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