DressUpObjDataCache.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using System.Linq;
  5. using FairyGUI;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class DressUpObjDataCache
  10. {
  11. private GameObject _sceneObj;
  12. private bool _needSetMask;
  13. public void setSceneObj(GameObject sceneObj, bool needSetMask = false)
  14. {
  15. _sceneObj = sceneObj;
  16. _needSetMask = needSetMask;
  17. }
  18. private int _bgId;
  19. public int bgId
  20. {
  21. get
  22. {
  23. return _bgId;
  24. }
  25. }
  26. private int _suitId;
  27. public int suitId
  28. {
  29. get
  30. {
  31. return _suitId;
  32. }
  33. }
  34. private bool _isPic;
  35. public bool picStatus
  36. {
  37. get
  38. {
  39. return _isPic;
  40. }
  41. }
  42. private List<int> _equipDatas = new List<int>();
  43. public List<int> equipDatas
  44. {
  45. get
  46. {
  47. return _equipDatas.ToList();
  48. }
  49. set
  50. {
  51. _equipDatas = value;
  52. }
  53. }
  54. public void Dispose()
  55. {
  56. _sceneObj = null;
  57. }
  58. private void Add(int value)
  59. {
  60. if (!_equipDatas.Contains(value))
  61. {
  62. _equipDatas.Add(value);
  63. DressUpUtil.AddItem(value, _sceneObj, _needSetMask);
  64. FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(value, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  65. }
  66. int dressSuitId = CheckCurDressIsSuit();
  67. if (dressSuitId > 0) _suitId = dressSuitId;
  68. }
  69. private void Remove(int value)
  70. {
  71. if (_equipDatas == null)
  72. {
  73. return;
  74. }
  75. if (_equipDatas.Contains(value))
  76. {
  77. _equipDatas.Remove(value);
  78. DressUpUtil.RemoveItem(value, _sceneObj);
  79. FightDataManager.Instance.score -= ItemDataManager.GetItemAdditionScore(value, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  80. }
  81. }
  82. //检测当前穿戴是否是一件完整套装,且只穿了一件套装,返回套装id
  83. public int CheckCurDressIsSuit()
  84. {
  85. if (_suitId > 0) return _suitId;
  86. // var equipDatas = _equipDatas;
  87. int dressSuitId = 0;
  88. List<int> equipDatas = new List<int>();
  89. for (int i = 0; i < _equipDatas.Count; i++)
  90. {
  91. if (DressUpMenuItemDataManager.CheckIsSceneType(_equipDatas[i])) continue;
  92. if (_equipDatas[i] != ConstItemID.DEFULT_FA_XING && _equipDatas[i] != ConstItemID.DEFULT_LIAN_YI_QUN && _equipDatas[i] != ConstItemID.DEFULT_NEI_DA && _equipDatas[i] != ConstItemID.DEFULT_XIA_ZHUANG)
  93. {
  94. int suitId = SuitCfgManager.Instance.GetItemSuitId(_equipDatas[i]);
  95. if (suitId <= 0) return 0;//有任何不属于套装的部件且不是原始服装,则当前穿戴不属于套装
  96. if (dressSuitId != 0 && dressSuitId != suitId) return 0;//当前穿戴不同套装的部件,则当前穿戴不属于套装
  97. dressSuitId = suitId;
  98. equipDatas.Add(_equipDatas[i]);
  99. }
  100. }
  101. if (dressSuitId == 0) return dressSuitId;
  102. int[] itemIds = SuitCfgManager.Instance.GetSuitItems(dressSuitId);
  103. for (int i = 0; i < itemIds.Length; i++)
  104. {
  105. if (DressUpMenuItemDataManager.CheckIsSceneType(itemIds[i])) continue;
  106. if (equipDatas.IndexOf(itemIds[i]) < 0) return 0;//套装部件穿戴不完整
  107. }
  108. return dressSuitId;
  109. }
  110. /// <summary>
  111. /// 仅判断换装部件是否已穿着
  112. /// </summary>
  113. /// <param name="id"></param>
  114. /// <returns></returns>
  115. public bool CheckDressUpItemIsOn(int id)
  116. {
  117. if (id == _bgId)
  118. {
  119. return true;
  120. }
  121. // if (suitId > 0)
  122. // {
  123. // int[] suitparts = SuitCfgArray.Instance.GetCfg(suitId).partsArr;
  124. // if (Array.IndexOf(suitparts, id) >= 0)
  125. // {
  126. // return true;
  127. // }
  128. // }
  129. return _equipDatas.Contains(id);
  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. bool isOn = CheckDressUpItemIsOn(itemId);
  147. if (!isOn)
  148. {
  149. return false;
  150. }
  151. }
  152. return true;
  153. }
  154. public void AddOrRemove(int value, bool checkDefault, bool isAdd = false, bool isRemove = false)
  155. {
  156. int subType = ItemUtilCS.GetItemSubType(value);
  157. if (subType == ConstDressUpItemType.BEI_JING)
  158. {
  159. _bgId = value;
  160. DressUpUtil.AddItem(_bgId, _sceneObj, _needSetMask);
  161. }
  162. else
  163. {
  164. if (!CheckDressUpItemIsOn(value))
  165. {
  166. if (!isRemove)
  167. {
  168. checkRemoveSameType(subType);
  169. Add(value);
  170. }
  171. }
  172. else
  173. {
  174. if (!isAdd)
  175. {
  176. Remove(value);
  177. }
  178. }
  179. if (checkDefault)
  180. {
  181. checkDefaultItem();
  182. }
  183. }
  184. }
  185. public void checkRemoveSameType(int type)
  186. {
  187. int count = 0;
  188. int firstTeshuId = 0;
  189. for (int i = 0; i < _equipDatas.Count; i++)
  190. {
  191. int itemID = (int)_equipDatas[i];
  192. int subType = ItemUtilCS.GetItemSubType(itemID);
  193. if (subType == type
  194. || (type == ConstDressUpItemType.LIAN_YI_QUN && (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA))
  195. || (type == ConstDressUpItemType.SHANG_YI && subType == ConstDressUpItemType.LIAN_YI_QUN)
  196. || (type == ConstDressUpItemType.XIA_ZHUANG && subType == ConstDressUpItemType.LIAN_YI_QUN)
  197. || (type == ConstDressUpItemType.NEI_DA && subType == ConstDressUpItemType.LIAN_YI_QUN))
  198. {
  199. Remove(itemID);
  200. i--;
  201. }
  202. if (subType > ConstDressUpItemType.TE_SHU)
  203. {
  204. if (count == 0)
  205. {
  206. firstTeshuId = itemID;
  207. }
  208. count++;
  209. }
  210. }
  211. if (type > ConstDressUpItemType.TE_SHU && count >= 3)
  212. {
  213. //特殊饰品最多穿三件,第四件会自动顶掉第一件
  214. Remove(firstTeshuId);
  215. }
  216. }
  217. private void checkDefaultItem()
  218. {
  219. if (!IsSuitPic)
  220. {
  221. //检查默认资源
  222. //是否有头发
  223. bool hasFaXing = false;
  224. //是否有连衣裙
  225. bool hasLianYiQun = false;
  226. //是否有内搭
  227. bool hasNeiDa = false;
  228. //是否有上衣
  229. bool hasShangYi = false;
  230. //是否有下装
  231. bool hasXiaZhuang = false;
  232. //是否有默认内搭
  233. bool hasNeiDaDefault = false;
  234. //是否有默认下装
  235. bool hasXiaZhuangDefault = false;
  236. for (int i = 0; i < _equipDatas.Count; i++)
  237. {
  238. int itemID = (int)_equipDatas[i];
  239. int subType = ItemUtilCS.GetItemSubType(itemID);
  240. if (subType == (int)ConstDressUpItemType.FA_XING)
  241. {
  242. hasFaXing = true;
  243. }
  244. else if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  245. {
  246. hasLianYiQun = true;
  247. }
  248. else if (subType == ConstDressUpItemType.NEI_DA)
  249. {
  250. hasNeiDa = true;
  251. }
  252. else if (subType == ConstDressUpItemType.XIA_ZHUANG)
  253. {
  254. hasXiaZhuang = true;
  255. }
  256. else if (subType == ConstDressUpItemType.SHANG_YI)
  257. {
  258. hasShangYi = true;
  259. }
  260. if (itemID == ConstItemID.DEFULT_NEI_DA)
  261. {
  262. hasNeiDaDefault = true;
  263. }
  264. else if (itemID == ConstItemID.DEFULT_XIA_ZHUANG)
  265. {
  266. hasXiaZhuangDefault = true;
  267. }
  268. }
  269. if (!hasFaXing)
  270. {
  271. Add(ConstItemID.DEFULT_FA_XING);
  272. }
  273. if (!hasLianYiQun)
  274. {
  275. if (!hasShangYi && (!hasNeiDa || hasNeiDaDefault) && (!hasXiaZhuang || hasXiaZhuangDefault))
  276. {
  277. Remove(ConstItemID.DEFULT_XIA_ZHUANG);
  278. Remove(ConstItemID.DEFULT_NEI_DA);
  279. Add(ConstItemID.DEFULT_LIAN_YI_QUN);
  280. }
  281. else
  282. {
  283. if (!hasXiaZhuang)
  284. {
  285. Add(ConstItemID.DEFULT_XIA_ZHUANG);
  286. }
  287. if (!hasNeiDa)
  288. {
  289. Add(ConstItemID.DEFULT_NEI_DA);
  290. }
  291. }
  292. }
  293. }
  294. }
  295. /// <summary>
  296. /// 检测是否穿戴完整(穿着连衣裙或同时穿着上装下装)
  297. /// </summary>
  298. /// <returns></returns>
  299. public bool CheckPutOnFinish()
  300. {
  301. if (EquipDataCache.cacher.suitId > 0) return true;
  302. List<int> equipDatas = EquipDataCache.cacher.equipDatas;
  303. bool isLianYiQun = false;
  304. bool isShangYi = false;
  305. bool isXiaZhuang = false;
  306. for (int i = 0; i < equipDatas.Count; i++)
  307. {
  308. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDatas[i]);
  309. if (itemCfg.subType == ConstDressUpItemType.LIAN_YI_QUN && itemCfg.id != ConstItemID.DEFULT_LIAN_YI_QUN)
  310. {
  311. isLianYiQun = true; break;
  312. }
  313. if (itemCfg.subType == ConstDressUpItemType.SHANG_YI && itemCfg.id != ConstItemID.DEFULT_NEI_DA)
  314. {
  315. isShangYi = true;
  316. }
  317. if (itemCfg.subType == ConstDressUpItemType.XIA_ZHUANG && itemCfg.id != ConstItemID.DEFULT_XIA_ZHUANG)
  318. {
  319. isXiaZhuang = true;
  320. }
  321. }
  322. return isLianYiQun || isXiaZhuang && isShangYi;
  323. }
  324. private void UpdatePicAction()
  325. {
  326. if (IsSuitPic)
  327. {
  328. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  329. var hasAniRes = !string.IsNullOrEmpty(suitCfg.aniRes);
  330. var res = hasAniRes ? suitCfg.aniRes : suitCfg.picRes;
  331. DressUpUtil.UpdateBody(res, _sceneObj, hasAniRes, suitCfg.effRes);
  332. }
  333. else
  334. {
  335. DressUpUtil.UpdateBody(null, _sceneObj, false, null, _needSetMask);
  336. }
  337. }
  338. public void TakeOffAll(bool checkDefault = true)
  339. {
  340. _suitId = 0;
  341. _isPic = false;
  342. // AddOrRemove(propID, false, true);
  343. var tempList = equipDatas;
  344. foreach (int itemID in tempList)
  345. {
  346. AddOrRemove(itemID, false, false, true);
  347. }
  348. if (checkDefault)
  349. {
  350. checkDefaultItem();
  351. UpdatePicAction();
  352. }
  353. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  354. FightDataManager.Instance.score = roleLevelCfg.baseScore;
  355. foreach (int itemId in _equipDatas)
  356. {
  357. FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  358. }
  359. }
  360. public void ChangeAction()
  361. {
  362. if (!HasSuitPicRes)
  363. {
  364. return;
  365. }
  366. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  367. _isPic = !_isPic;
  368. if (_isPic)
  369. {
  370. var tempList = equipDatas;
  371. foreach (int itemID in tempList)
  372. {
  373. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  374. {
  375. AddOrRemove(itemID, false, false, true);
  376. }
  377. }
  378. }
  379. else
  380. {
  381. int[] items = suitCfg.partsArr;
  382. foreach (int itemId in items)
  383. {
  384. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemId))
  385. {
  386. AddOrRemove(itemId, false, true);
  387. }
  388. }
  389. }
  390. checkDefaultItem();
  391. UpdatePicAction();
  392. }
  393. public void TryCancelSuit(int itemID)
  394. {
  395. if (_suitId > 0)
  396. {
  397. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  398. {
  399. if (_isPic)
  400. {
  401. ChangeAction();
  402. }
  403. _suitId = 0;
  404. }
  405. }
  406. }
  407. public bool IsSuitPic
  408. {
  409. get
  410. {
  411. return _suitId > 0 && _isPic;
  412. }
  413. }
  414. public bool HasSuitPicRes
  415. {
  416. get
  417. {
  418. if (_suitId > 0)
  419. {
  420. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  421. if (suitCfg.picRes != null && suitCfg.picRes.Length > 0)
  422. {
  423. return true;
  424. }
  425. }
  426. return false;
  427. }
  428. }
  429. /// <summary>
  430. /// 尝试穿戴配置套装
  431. /// </summary>
  432. /// <param name="id">套装id</param>
  433. /// <param name="checkPic">检查是否是立绘</param>
  434. /// <param name="noSceneType">是否排除场景类型</param>
  435. /// <param name="excludeType">排除类型列表</param>
  436. /// <param name="showOptional">是否显示可选部件</param>
  437. /// <param name="CheckOwn">是否只显示主角拥有的部件</param>
  438. public void PutOnSuitCfg(int id, bool checkPic, bool noSceneType, int[] excludeType = null, bool showOptional = true, bool CheckOwn = true)
  439. {
  440. if (_suitId == id)
  441. {
  442. return;
  443. }
  444. TakeOffAll(false);
  445. _suitId = id;
  446. _isPic = HasSuitPicRes && checkPic;
  447. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  448. List<int> items = new List<int>(suitCfg.partsArr);
  449. if (showOptional)
  450. {
  451. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  452. {
  453. items.AddRange(suitCfg.partsOptionalArr);
  454. }
  455. }
  456. int subType = 0;
  457. foreach (int itemID in items)
  458. {
  459. if (!CheckOwn || DressUpMenuItemDataManager.CheckHasItem(itemID))
  460. {
  461. bool isSceneType = DressUpMenuItemDataManager.CheckIsSceneType(itemID);
  462. subType = ItemUtilCS.GetItemSubType(itemID);
  463. if (!_isPic || isSceneType)
  464. {
  465. if (!noSceneType || !isSceneType)
  466. {
  467. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  468. {
  469. AddOrRemove(itemID, false, true);
  470. }
  471. }
  472. }
  473. }
  474. }
  475. checkDefaultItem();
  476. UpdatePicAction();
  477. }
  478. public CustomSuitData GetCurSuitData(int index)
  479. {
  480. CustomSuitData suitSavedData = new CustomSuitData(index);
  481. suitSavedData.equipDatas = EquipDataCache.cacher.equipDatas;
  482. suitSavedData.bg = EquipDataCache.cacher.bgId;
  483. suitSavedData.pic = EquipDataCache.cacher.picStatus;
  484. suitSavedData.suitId = EquipDataCache.cacher.suitId;
  485. return suitSavedData;
  486. }
  487. public void PutOnSuitSaved(int index)
  488. {
  489. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  490. PutOnSuitMemory(suitSavedData);
  491. }
  492. public void PutOnSuitMemory(CustomSuitData suitSavedData)
  493. {
  494. TakeOffAll(false);
  495. if (suitSavedData.bg > 0)
  496. {
  497. AddOrRemove(suitSavedData.bg, false);
  498. }
  499. foreach (int itemID in suitSavedData.equipDatas)
  500. {
  501. AddOrRemove(itemID, false, true);
  502. }
  503. _suitId = suitSavedData.suitId;
  504. _isPic = suitSavedData.pic;
  505. checkDefaultItem();
  506. UpdatePicAction();
  507. }
  508. public void PutOnSuitSavedInFight(int index)
  509. {
  510. TakeOffAll(false);
  511. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  512. if (suitSavedData.suitId > 0)
  513. {
  514. PutOnSuitCfg(suitSavedData.suitId, false, true);
  515. }
  516. else
  517. {
  518. foreach (int itemID in suitSavedData.equipDatas)
  519. {
  520. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  521. {
  522. AddOrRemove(itemID, false, true);
  523. }
  524. }
  525. checkDefaultItem();
  526. }
  527. }
  528. // public void PutOnCurrentSuitSaved()
  529. // {
  530. // PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  531. // }
  532. public void PutOnDefaultSuitSaved(bool withBg = true)
  533. {
  534. TakeOffAll(false);
  535. CustomSuitData suitSavedData = CustomSuitDataManager.CreateDefaultSuitData(0);
  536. foreach (int itemID in suitSavedData.equipDatas)
  537. {
  538. AddOrRemove(itemID, false, true);
  539. }
  540. if (withBg)
  541. {
  542. if (suitSavedData.bg > 0)
  543. {
  544. AddOrRemove(suitSavedData.bg, false);
  545. }
  546. }
  547. checkDefaultItem();
  548. UpdatePicAction();
  549. }
  550. public void PutOnRecommendItems()
  551. {
  552. TakeOffAll(false);
  553. List<int> recommendList = DressUpMenuItemDataManager.GetRecommendItemList();
  554. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  555. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  556. int liangyiqunIndex = -1;
  557. int shangyiIndex = -1;
  558. int xiazhuangIndex = -1;
  559. int neidaIndex = -1;
  560. for (int i = 0; i < recommendList.Count; i++)
  561. {
  562. int subType = ItemUtilCS.GetItemSubType(recommendList[i]);
  563. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  564. {
  565. liangyiqunIndex = i;
  566. continue;
  567. }
  568. if (subType == ConstDressUpItemType.SHANG_YI)
  569. {
  570. shangyiIndex = i;
  571. continue;
  572. }
  573. if (subType == ConstDressUpItemType.XIA_ZHUANG)
  574. {
  575. xiazhuangIndex = i;
  576. continue;
  577. }
  578. if (subType == ConstDressUpItemType.NEI_DA)
  579. {
  580. neidaIndex = i;
  581. continue;
  582. }
  583. }
  584. if (liangyiqunIndex >= 0 && (shangyiIndex >= 0 || xiazhuangIndex >= 0))
  585. {
  586. if (shangyiIndex < 0 && xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);//上衣下装只有一件,则保留连衣裙
  587. if (xiazhuangIndex < 0 && shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  588. if (shangyiIndex >= 0 && xiazhuangIndex >= 0)//同时拥有上衣、下装、连衣裙
  589. {
  590. int lianyiqunScore = ItemDataManager.GetItemAdditionScore(recommendList[liangyiqunIndex], InstanceZonesDataManager.currentScoreType);
  591. int shangyiScore = ItemDataManager.GetItemAdditionScore(recommendList[shangyiIndex], InstanceZonesDataManager.currentScoreType);
  592. int xiazhuangScore = ItemDataManager.GetItemAdditionScore(recommendList[xiazhuangIndex], InstanceZonesDataManager.currentScoreType);
  593. int neidaScore = neidaIndex >= 0 ? ItemDataManager.GetItemAdditionScore(recommendList[neidaIndex], InstanceZonesDataManager.currentScoreType) : 0;
  594. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  595. if (fightCfg.needItemId > 0 && recommendList.IndexOf(fightCfg.needItemId) >= 0 && (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA || subType == ConstDressUpItemType.LIAN_YI_QUN))//推荐列表里有必需品且,必需品类型为上衣或下装或连衣裙,有先穿戴必须品,其次穿戴高分服装
  596. {
  597. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  598. {
  599. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  600. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  601. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  602. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  603. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  604. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  605. }
  606. else if (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA)
  607. {
  608. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  609. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  610. }
  611. }
  612. else
  613. {
  614. if (lianyiqunScore > shangyiScore + xiazhuangScore + neidaScore)
  615. {
  616. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  617. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  618. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  619. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  620. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  621. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  622. }
  623. else
  624. {
  625. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  626. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  627. }
  628. }
  629. }
  630. }
  631. //推荐搭配自动穿必穿品
  632. if (fightCfg.needItemId > 0 && DressUpMenuItemDataManager.CheckHasItem(fightCfg.needItemId) && recommendList.IndexOf(fightCfg.needItemId) < 0)
  633. {
  634. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  635. for (int i = 0; i < recommendList.Count; i++)
  636. {
  637. int recommendSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  638. if (recommendSubType == subType)
  639. {
  640. recommendList.RemoveAt(i);
  641. break;
  642. }
  643. }
  644. recommendList.Add(fightCfg.needItemId);
  645. }
  646. else if (fightCfg.needSuitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(fightCfg.needSuitId))
  647. {
  648. recommendList.Clear();
  649. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
  650. recommendList.AddRange(cfg.partsArr);
  651. }
  652. foreach (int itemID in recommendList)
  653. {
  654. AddOrRemove(itemID, false, true);
  655. }
  656. checkDefaultItem();
  657. UpdatePicAction();
  658. }
  659. private int CheckIndex(int _subType, List<int> recommendList)
  660. {
  661. for (int i = 0; i < recommendList.Count; i++)
  662. {
  663. int itemSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  664. if (itemSubType == _subType)
  665. {
  666. return i;
  667. }
  668. }
  669. return -1;
  670. }
  671. public bool CheckEquipedFightNeeded()
  672. {
  673. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  674. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  675. if (fightCfg.needItemId > 0)
  676. {
  677. return CheckDressUpItemIsOn(fightCfg.needItemId);
  678. }
  679. else if (fightCfg.needSuitId > 0)
  680. {
  681. return CheckSuitIsOn(fightCfg.needSuitId);
  682. }
  683. return true;
  684. }
  685. public int GetItemIdBuyType(int subType)
  686. {
  687. for (int i = 0; i < equipDatas.Count; i++)
  688. {
  689. if (equipDatas[i] != ConstItemID.DEFULT_LIAN_YI_QUN && equipDatas[i] != ConstItemID.DEFULT_NEI_DA && equipDatas[i] != ConstItemID.DEFULT_XIA_ZHUANG && equipDatas[i] != ConstItemID.DEFULT_FA_XING)
  690. {
  691. if (subType == ItemUtilCS.GetItemSubType(equipDatas[i]))
  692. {
  693. return equipDatas[i];
  694. }
  695. }
  696. }
  697. if (suitId > 0)
  698. {
  699. return suitId;
  700. }
  701. return 0;
  702. }
  703. }
  704. }