DressUpObjDataCache.cs 26 KB

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