DressUpObjDataCache.cs 27 KB

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