DressUpObjDataCache.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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(10000);
  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. DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObj, !string.IsNullOrEmpty(suitCfg.aniRes), suitCfg.effRes);
  330. }
  331. else
  332. {
  333. DressUpUtil.UpdateBody(null, _sceneObj, false, null, _needSetMask);
  334. }
  335. }
  336. public void TakeOffAll(bool checkDefault = true)
  337. {
  338. _suitId = 0;
  339. _isPic = false;
  340. // AddOrRemove(propID, false, true);
  341. var tempList = equipDatas;
  342. foreach (int itemID in tempList)
  343. {
  344. AddOrRemove(itemID, false, false, true);
  345. }
  346. if (checkDefault)
  347. {
  348. checkDefaultItem();
  349. UpdatePicAction();
  350. }
  351. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  352. FightDataManager.Instance.score = roleLevelCfg.baseScore;
  353. foreach (int itemId in _equipDatas)
  354. {
  355. FightDataManager.Instance.score += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
  356. }
  357. }
  358. public void ChangeAction()
  359. {
  360. if (!HasSuitPicRes)
  361. {
  362. return;
  363. }
  364. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  365. _isPic = !_isPic;
  366. if (_isPic)
  367. {
  368. var tempList = equipDatas;
  369. foreach (int itemID in tempList)
  370. {
  371. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  372. {
  373. AddOrRemove(itemID, false, false, true);
  374. }
  375. }
  376. }
  377. else
  378. {
  379. int[] items = suitCfg.partsArr;
  380. foreach (int itemId in items)
  381. {
  382. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemId))
  383. {
  384. AddOrRemove(itemId, false, true);
  385. }
  386. }
  387. }
  388. checkDefaultItem();
  389. UpdatePicAction();
  390. }
  391. public void TryCancelSuit(int itemID)
  392. {
  393. if (_suitId > 0)
  394. {
  395. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  396. {
  397. if (_isPic)
  398. {
  399. ChangeAction();
  400. }
  401. _suitId = 0;
  402. }
  403. }
  404. }
  405. public bool IsSuitPic
  406. {
  407. get
  408. {
  409. return _suitId > 0 && _isPic;
  410. }
  411. }
  412. public bool HasSuitPicRes
  413. {
  414. get
  415. {
  416. if (_suitId > 0)
  417. {
  418. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  419. if (suitCfg.picRes != null && suitCfg.picRes.Length > 0)
  420. {
  421. return true;
  422. }
  423. }
  424. return false;
  425. }
  426. }
  427. /// <summary>
  428. /// 尝试穿戴配置套装
  429. /// </summary>
  430. /// <param name="id">套装id</param>
  431. /// <param name="checkPic">检查是否是立绘</param>
  432. /// <param name="noSceneType">是否排除场景类型</param>
  433. /// <param name="excludeType">排除类型列表</param>
  434. /// <param name="showOptional">是否显示可选部件</param>
  435. /// <param name="CheckOwn">是否只显示主角拥有的部件</param>
  436. public void PutOnSuitCfg(int id, bool checkPic, bool noSceneType, int[] excludeType = null, bool showOptional = true, bool CheckOwn = true)
  437. {
  438. if (_suitId == id)
  439. {
  440. return;
  441. }
  442. TakeOffAll(false);
  443. _suitId = id;
  444. _isPic = HasSuitPicRes && checkPic;
  445. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  446. List<int> items = new List<int>(suitCfg.partsArr);
  447. if (showOptional)
  448. {
  449. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  450. {
  451. items.AddRange(suitCfg.partsOptionalArr);
  452. }
  453. }
  454. int subType = 0;
  455. foreach (int itemID in items)
  456. {
  457. if (!CheckOwn || DressUpMenuItemDataManager.CheckHasItem(itemID))
  458. {
  459. bool isSceneType = DressUpMenuItemDataManager.CheckIsSceneType(itemID);
  460. subType = ItemUtilCS.GetItemSubType(itemID);
  461. if (!_isPic || isSceneType)
  462. {
  463. if (!noSceneType || !isSceneType)
  464. {
  465. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  466. {
  467. AddOrRemove(itemID, false, true);
  468. }
  469. }
  470. }
  471. }
  472. }
  473. checkDefaultItem();
  474. UpdatePicAction();
  475. }
  476. public CustomSuitData GetCurSuitData(int index)
  477. {
  478. CustomSuitData suitSavedData = new CustomSuitData(index);
  479. suitSavedData.equipDatas = EquipDataCache.cacher.equipDatas;
  480. suitSavedData.bg = EquipDataCache.cacher.bgId;
  481. suitSavedData.pic = EquipDataCache.cacher.picStatus;
  482. suitSavedData.suitId = EquipDataCache.cacher.suitId;
  483. return suitSavedData;
  484. }
  485. public void PutOnSuitSaved(int index)
  486. {
  487. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  488. PutOnSuitMemory(suitSavedData);
  489. }
  490. public void PutOnSuitMemory(CustomSuitData suitSavedData)
  491. {
  492. TakeOffAll(false);
  493. if (suitSavedData.bg > 0)
  494. {
  495. AddOrRemove(suitSavedData.bg, false);
  496. }
  497. foreach (int itemID in suitSavedData.equipDatas)
  498. {
  499. AddOrRemove(itemID, false, true);
  500. }
  501. _suitId = suitSavedData.suitId;
  502. _isPic = suitSavedData.pic;
  503. checkDefaultItem();
  504. UpdatePicAction();
  505. }
  506. public void PutOnSuitSavedInFight(int index)
  507. {
  508. TakeOffAll(false);
  509. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  510. if (suitSavedData.suitId > 0)
  511. {
  512. PutOnSuitCfg(suitSavedData.suitId, false, true);
  513. }
  514. else
  515. {
  516. foreach (int itemID in suitSavedData.equipDatas)
  517. {
  518. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  519. {
  520. AddOrRemove(itemID, false, true);
  521. }
  522. }
  523. checkDefaultItem();
  524. }
  525. }
  526. // public void PutOnCurrentSuitSaved()
  527. // {
  528. // PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  529. // }
  530. public void PutOnDefaultSuitSaved(bool withBg = true)
  531. {
  532. TakeOffAll(false);
  533. CustomSuitData suitSavedData = CustomSuitDataManager.CreateDefaultSuitData(0);
  534. foreach (int itemID in suitSavedData.equipDatas)
  535. {
  536. AddOrRemove(itemID, false, true);
  537. }
  538. if (withBg)
  539. {
  540. if (suitSavedData.bg > 0)
  541. {
  542. AddOrRemove(suitSavedData.bg, false);
  543. }
  544. }
  545. checkDefaultItem();
  546. UpdatePicAction();
  547. }
  548. public void PutOnRecommendItems()
  549. {
  550. TakeOffAll(false);
  551. List<int> recommendList = DressUpMenuItemDataManager.GetRecommendItemList();
  552. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  553. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  554. int liangyiqunIndex = -1;
  555. int shangyiIndex = -1;
  556. int xiazhuangIndex = -1;
  557. int neidaIndex = -1;
  558. for (int i = 0; i < recommendList.Count; i++)
  559. {
  560. int subType = ItemUtilCS.GetItemSubType(recommendList[i]);
  561. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  562. {
  563. liangyiqunIndex = i;
  564. continue;
  565. }
  566. if (subType == ConstDressUpItemType.SHANG_YI)
  567. {
  568. shangyiIndex = i;
  569. continue;
  570. }
  571. if (subType == ConstDressUpItemType.XIA_ZHUANG)
  572. {
  573. xiazhuangIndex = i;
  574. continue;
  575. }
  576. if (subType == ConstDressUpItemType.NEI_DA)
  577. {
  578. neidaIndex = i;
  579. continue;
  580. }
  581. }
  582. if (liangyiqunIndex >= 0 && (shangyiIndex >= 0 || xiazhuangIndex >= 0))
  583. {
  584. if (shangyiIndex < 0 && xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);//上衣下装只有一件,则保留连衣裙
  585. if (xiazhuangIndex < 0 && shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  586. if (shangyiIndex >= 0 && xiazhuangIndex >= 0)//同时拥有上衣、下装、连衣裙
  587. {
  588. int lianyiqunScore = ItemDataManager.GetItemAdditionScore(recommendList[liangyiqunIndex], InstanceZonesDataManager.currentScoreType);
  589. int shangyiScore = ItemDataManager.GetItemAdditionScore(recommendList[shangyiIndex], InstanceZonesDataManager.currentScoreType);
  590. int xiazhuangScore = ItemDataManager.GetItemAdditionScore(recommendList[xiazhuangIndex], InstanceZonesDataManager.currentScoreType);
  591. int neidaScore = neidaIndex >= 0 ? ItemDataManager.GetItemAdditionScore(recommendList[neidaIndex], InstanceZonesDataManager.currentScoreType) : 0;
  592. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  593. 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))//推荐列表里有必需品且,必需品类型为上衣或下装或连衣裙,有先穿戴必须品,其次穿戴高分服装
  594. {
  595. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  596. {
  597. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  598. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  599. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  600. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  601. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  602. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  603. }
  604. else if (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA)
  605. {
  606. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  607. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  608. }
  609. }
  610. else
  611. {
  612. if (lianyiqunScore > shangyiScore + xiazhuangScore + neidaScore)
  613. {
  614. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  615. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  616. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  617. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  618. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  619. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  620. }
  621. else
  622. {
  623. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  624. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  625. }
  626. }
  627. }
  628. }
  629. //推荐搭配自动穿必穿品
  630. if (fightCfg.needItemId > 0 && DressUpMenuItemDataManager.CheckHasItem(fightCfg.needItemId) && recommendList.IndexOf(fightCfg.needItemId) < 0)
  631. {
  632. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  633. for (int i = 0; i < recommendList.Count; i++)
  634. {
  635. int recommendSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  636. if (recommendSubType == subType)
  637. {
  638. recommendList.RemoveAt(i);
  639. break;
  640. }
  641. }
  642. recommendList.Add(fightCfg.needItemId);
  643. }
  644. else if (fightCfg.needSuitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(fightCfg.needSuitId))
  645. {
  646. recommendList.Clear();
  647. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
  648. recommendList.AddRange(cfg.partsArr);
  649. }
  650. foreach (int itemID in recommendList)
  651. {
  652. AddOrRemove(itemID, false, true);
  653. }
  654. checkDefaultItem();
  655. UpdatePicAction();
  656. }
  657. private int CheckIndex(int _subType, List<int> recommendList)
  658. {
  659. for (int i = 0; i < recommendList.Count; i++)
  660. {
  661. int itemSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  662. if (itemSubType == _subType)
  663. {
  664. return i;
  665. }
  666. }
  667. return -1;
  668. }
  669. public bool CheckEquipedFightNeeded()
  670. {
  671. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  672. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  673. if (fightCfg.needItemId > 0)
  674. {
  675. return CheckDressUpItemIsOn(fightCfg.needItemId);
  676. }
  677. else if (fightCfg.needSuitId > 0)
  678. {
  679. return CheckSuitIsOn(fightCfg.needSuitId);
  680. }
  681. return true;
  682. }
  683. public int GetItemIdBuyType(int subType)
  684. {
  685. for (int i = 0; i < equipDatas.Count; i++)
  686. {
  687. 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)
  688. {
  689. if (subType == ItemUtilCS.GetItemSubType(equipDatas[i]))
  690. {
  691. return equipDatas[i];
  692. }
  693. }
  694. }
  695. if (suitId > 0)
  696. {
  697. return suitId;
  698. }
  699. return 0;
  700. }
  701. }
  702. }