DressUpObjDataCache.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  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. //角色基础分+部件基础分
  55. private int _score;
  56. public int score
  57. {
  58. get
  59. {
  60. return _score;
  61. }
  62. private set
  63. {
  64. _score = value;
  65. EventAgent.DispatchEvent(ConstMessage.DRESS_UP_SCORE_CHANGED, _score);
  66. }
  67. }
  68. //最终得分
  69. private int _totalScore;
  70. public int totalScore
  71. {
  72. get
  73. {
  74. return _totalScore;
  75. }
  76. set
  77. {
  78. _totalScore = value;
  79. }
  80. }
  81. //战斗对象最终得分
  82. private int _targetTotalScore;
  83. public int npcTotalScore
  84. {
  85. get
  86. {
  87. return _targetTotalScore;
  88. }
  89. set
  90. {
  91. _targetTotalScore = value;
  92. }
  93. }
  94. private bool _autoPlay = false;
  95. public bool autoPlay
  96. {
  97. get
  98. {
  99. return _autoPlay;
  100. }
  101. set
  102. {
  103. _autoPlay = value;
  104. if (!_autoPlay) fightSpeed = 1;
  105. StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_AUTO_PLAY, _autoPlay == true ? 1 : 0).Coroutine();
  106. }
  107. }
  108. public int maxFightSpeed = 2;
  109. private int _fightSpeed = 1;
  110. public int fightSpeed
  111. {
  112. get
  113. {
  114. return _fightSpeed;
  115. }
  116. set
  117. {
  118. _fightSpeed = value;
  119. StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_AUTO_PLAY_SPEED, _fightSpeed).Coroutine();
  120. }
  121. }
  122. private int _fieldFightSpeed = 1;
  123. public int fieldFightSpeed
  124. {
  125. get
  126. {
  127. return _fieldFightSpeed;
  128. }
  129. set
  130. {
  131. _fieldFightSpeed = value;
  132. StorageSProxy.ReqSetClientValue(ConstStorageId.FIELD_AUTO_PLAY_SPEED, _fieldFightSpeed).Coroutine();
  133. }
  134. }
  135. public void Dispose()
  136. {
  137. _sceneObj = null;
  138. }
  139. private void Add(int value)
  140. {
  141. if (!_equipDatas.Contains(value))
  142. {
  143. _equipDatas.Add(value);
  144. DressUpUtil.AddItem(value, _sceneObj, _needSetMask);
  145. score += DressUpMenuItemDataManager.GetItemScore(value);
  146. }
  147. int dressSuitId = DressUpMenuSuitDataManager.CheckCurDressIsSuit();
  148. if (dressSuitId > 0) _suitId = dressSuitId;
  149. }
  150. private void Remove(int value)
  151. {
  152. if (_equipDatas == null)
  153. {
  154. return;
  155. }
  156. if (_equipDatas.Contains(value))
  157. {
  158. _equipDatas.Remove(value);
  159. DressUpUtil.RemoveItem(value, _sceneObj);
  160. score -= DressUpMenuItemDataManager.GetItemScore(value);
  161. }
  162. }
  163. /// <summary>
  164. /// 仅判断换装部件是否已穿着
  165. /// </summary>
  166. /// <param name="id"></param>
  167. /// <returns></returns>
  168. public bool CheckDressUpItemIsOn(int id)
  169. {
  170. if (id == _bgId)
  171. {
  172. return true;
  173. }
  174. // if (suitId > 0)
  175. // {
  176. // int[] suitparts = SuitCfgArray.Instance.GetCfg(suitId).partsArr;
  177. // if (Array.IndexOf(suitparts, id) >= 0)
  178. // {
  179. // return true;
  180. // }
  181. // }
  182. return _equipDatas.Contains(id);
  183. }
  184. /// <summary>
  185. /// 仅判断套装是否穿上
  186. /// </summary>
  187. /// <param name="id"></param>
  188. /// <returns></returns>
  189. public bool CheckSuitIsOn(int id)
  190. {
  191. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
  192. if (suitCfg == null)
  193. {
  194. return false;
  195. }
  196. int[] items = suitCfg.partsArr;
  197. foreach (int itemId in items)
  198. {
  199. bool isOn = CheckDressUpItemIsOn(itemId);
  200. if (!isOn)
  201. {
  202. return false;
  203. }
  204. }
  205. return true;
  206. }
  207. public void AddOrRemove(int value, bool checkDefault, bool isAdd = false, bool isRemove = false)
  208. {
  209. int subType = ItemUtilCS.GetItemSubType(value);
  210. if (subType == ConstDressUpItemType.BEI_JING)
  211. {
  212. _bgId = value;
  213. DressUpUtil.AddItem(_bgId, _sceneObj, _needSetMask);
  214. }
  215. else
  216. {
  217. if (!CheckDressUpItemIsOn(value))
  218. {
  219. if (!isRemove)
  220. {
  221. checkRemoveSameType(subType);
  222. Add(value);
  223. }
  224. }
  225. else
  226. {
  227. if (!isAdd)
  228. {
  229. Remove(value);
  230. }
  231. }
  232. if (checkDefault)
  233. {
  234. checkDefaultItem();
  235. }
  236. }
  237. }
  238. public void checkRemoveSameType(int type)
  239. {
  240. int count = 0;
  241. int firstTeshuId = 0;
  242. for (int i = 0; i < _equipDatas.Count; i++)
  243. {
  244. int itemID = (int)_equipDatas[i];
  245. int subType = ItemUtilCS.GetItemSubType(itemID);
  246. if (subType == type
  247. || (type == ConstDressUpItemType.LIAN_YI_QUN && (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA))
  248. || (type == ConstDressUpItemType.SHANG_YI && subType == ConstDressUpItemType.LIAN_YI_QUN)
  249. || (type == ConstDressUpItemType.XIA_ZHUANG && subType == ConstDressUpItemType.LIAN_YI_QUN)
  250. || (type == ConstDressUpItemType.NEI_DA && subType == ConstDressUpItemType.LIAN_YI_QUN))
  251. {
  252. Remove(itemID);
  253. i--;
  254. }
  255. if (subType > ConstDressUpItemType.TE_SHU)
  256. {
  257. if (count == 0)
  258. {
  259. firstTeshuId = itemID;
  260. }
  261. count++;
  262. }
  263. }
  264. if (type > ConstDressUpItemType.TE_SHU && count >= 3)
  265. {
  266. //特殊饰品最多穿三件,第四件会自动顶掉第一件
  267. Remove(firstTeshuId);
  268. }
  269. }
  270. private void checkDefaultItem()
  271. {
  272. if (!IsSuitPic)
  273. {
  274. //检查默认资源
  275. //是否有头发
  276. bool hasFaXing = false;
  277. //是否有连衣裙
  278. bool hasLianYiQun = false;
  279. //是否有内搭
  280. bool hasNeiDa = false;
  281. //是否有上衣
  282. bool hasShangYi = false;
  283. //是否有下装
  284. bool hasXiaZhuang = false;
  285. //是否有默认内搭
  286. bool hasNeiDaDefault = false;
  287. //是否有默认下装
  288. bool hasXiaZhuangDefault = false;
  289. for (int i = 0; i < _equipDatas.Count; i++)
  290. {
  291. int itemID = (int)_equipDatas[i];
  292. int subType = ItemUtilCS.GetItemSubType(itemID);
  293. if (subType == (int)ConstDressUpItemType.FA_XING)
  294. {
  295. hasFaXing = true;
  296. }
  297. else if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  298. {
  299. hasLianYiQun = true;
  300. }
  301. else if (subType == ConstDressUpItemType.NEI_DA)
  302. {
  303. hasNeiDa = true;
  304. }
  305. else if (subType == ConstDressUpItemType.XIA_ZHUANG)
  306. {
  307. hasXiaZhuang = true;
  308. }
  309. else if (subType == ConstDressUpItemType.SHANG_YI)
  310. {
  311. hasShangYi = true;
  312. }
  313. if (itemID == ConstItemID.DEFULT_NEI_DA)
  314. {
  315. hasNeiDaDefault = true;
  316. }
  317. else if (itemID == ConstItemID.DEFULT_XIA_ZHUANG)
  318. {
  319. hasXiaZhuangDefault = true;
  320. }
  321. }
  322. if (!hasFaXing)
  323. {
  324. Add(10000);
  325. }
  326. if (!hasLianYiQun)
  327. {
  328. if(!hasShangYi && (!hasNeiDa || hasNeiDaDefault) && (!hasXiaZhuang || hasXiaZhuangDefault))
  329. {
  330. Remove(ConstItemID.DEFULT_XIA_ZHUANG);
  331. Remove(ConstItemID.DEFULT_NEI_DA);
  332. Add(ConstItemID.DEFULT_LIAN_YI_QUN);
  333. }
  334. else
  335. {
  336. if (!hasXiaZhuang)
  337. {
  338. Add(ConstItemID.DEFULT_XIA_ZHUANG);
  339. }
  340. if (!hasNeiDa)
  341. {
  342. Add(ConstItemID.DEFULT_NEI_DA);
  343. }
  344. }
  345. }
  346. }
  347. }
  348. /// <summary>
  349. /// 检测是否穿戴完整(穿着连衣裙或同时穿着上装下装)
  350. /// </summary>
  351. /// <returns></returns>
  352. public bool CheckPutOnFinish()
  353. {
  354. List<int> equipDatas = EquipDataCache.cacher.equipDatas;
  355. bool isLianYiQun = false;
  356. bool isShangYi = false;
  357. bool isXiaZhuang = false;
  358. for (int i = 0; i < equipDatas.Count; i++)
  359. {
  360. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDatas[i]);
  361. if (itemCfg.subType == ConstDressUpItemType.LIAN_YI_QUN && itemCfg.id != ConstItemID.DEFULT_LIAN_YI_QUN)
  362. {
  363. isLianYiQun = true; break;
  364. }
  365. if (itemCfg.subType == ConstDressUpItemType.SHANG_YI && itemCfg.id != ConstItemID.DEFULT_NEI_DA)
  366. {
  367. isShangYi = true;
  368. }
  369. if (itemCfg.subType == ConstDressUpItemType.XIA_ZHUANG && itemCfg.id != ConstItemID.DEFULT_XIA_ZHUANG)
  370. {
  371. isXiaZhuang = true;
  372. }
  373. }
  374. return isLianYiQun || isXiaZhuang && isShangYi;
  375. }
  376. private void UpdatePicAction()
  377. {
  378. if (IsSuitPic)
  379. {
  380. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  381. DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObj, !string.IsNullOrEmpty(suitCfg.aniRes), suitCfg.effRes);
  382. }
  383. else
  384. {
  385. DressUpUtil.UpdateBody(null, _sceneObj, false, null, _needSetMask);
  386. }
  387. }
  388. public void TakeOffAll(bool checkDefault = true)
  389. {
  390. _suitId = 0;
  391. _isPic = false;
  392. // AddOrRemove(propID, false, true);
  393. var tempList = equipDatas;
  394. foreach (int itemID in tempList)
  395. {
  396. AddOrRemove(itemID, false, false, true);
  397. }
  398. if (checkDefault)
  399. {
  400. checkDefaultItem();
  401. UpdatePicAction();
  402. }
  403. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  404. score = roleLevelCfg.baseScore;
  405. foreach (int itemId in _equipDatas)
  406. {
  407. score += DressUpMenuItemDataManager.GetItemScore(itemId);
  408. }
  409. }
  410. public void ChangeAction()
  411. {
  412. if (!HasSuitPicRes)
  413. {
  414. return;
  415. }
  416. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  417. _isPic = !_isPic;
  418. if (_isPic)
  419. {
  420. var tempList = equipDatas;
  421. foreach (int itemID in tempList)
  422. {
  423. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  424. {
  425. AddOrRemove(itemID, false, false, true);
  426. }
  427. }
  428. }
  429. else
  430. {
  431. int[] items = suitCfg.partsArr;
  432. foreach (int itemId in items)
  433. {
  434. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemId))
  435. {
  436. AddOrRemove(itemId, false, true);
  437. }
  438. }
  439. }
  440. checkDefaultItem();
  441. UpdatePicAction();
  442. }
  443. public void TryCancelSuit(int itemID)
  444. {
  445. if (_suitId > 0)
  446. {
  447. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  448. {
  449. if (_isPic)
  450. {
  451. ChangeAction();
  452. }
  453. _suitId = 0;
  454. }
  455. }
  456. }
  457. public bool IsSuitPic
  458. {
  459. get
  460. {
  461. return _suitId > 0 && _isPic;
  462. }
  463. }
  464. public bool HasSuitPicRes
  465. {
  466. get
  467. {
  468. if (_suitId > 0)
  469. {
  470. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  471. if (suitCfg.picRes != null && suitCfg.picRes.Length > 0)
  472. {
  473. return true;
  474. }
  475. }
  476. return false;
  477. }
  478. }
  479. public void PutOnSuitCfg(int id, bool checkPic, bool noSceneType, int[] excludeType = null)
  480. {
  481. if (_suitId == id)
  482. {
  483. return;
  484. }
  485. TakeOffAll(false);
  486. _suitId = id;
  487. _isPic = HasSuitPicRes && checkPic;
  488. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  489. List<int> items = new List<int>(suitCfg.partsArr);
  490. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  491. {
  492. items.AddRange(suitCfg.partsOptionalArr);
  493. }
  494. int subType = 0;
  495. foreach (int itemID in items)
  496. {
  497. if (DressUpMenuItemDataManager.CheckHasItem(itemID))
  498. {
  499. bool isSceneType = DressUpMenuItemDataManager.CheckIsSceneType(itemID);
  500. subType = ItemUtilCS.GetItemSubType(itemID);
  501. if (!_isPic || isSceneType)
  502. {
  503. if (!noSceneType || !isSceneType)
  504. {
  505. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  506. {
  507. AddOrRemove(itemID, false, true);
  508. }
  509. }
  510. }
  511. }
  512. }
  513. checkDefaultItem();
  514. UpdatePicAction();
  515. }
  516. public CustomSuitData GetCurSuitData(int index)
  517. {
  518. CustomSuitData suitSavedData = new CustomSuitData(index);
  519. suitSavedData.equipDatas = EquipDataCache.cacher.equipDatas;
  520. suitSavedData.bg = EquipDataCache.cacher.bgId;
  521. suitSavedData.pic = EquipDataCache.cacher.picStatus;
  522. suitSavedData.suitId = EquipDataCache.cacher.suitId;
  523. return suitSavedData;
  524. }
  525. public void PutOnSuitSaved(int index)
  526. {
  527. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  528. PutOnSuitMemory(suitSavedData);
  529. }
  530. public void PutOnSuitMemory(CustomSuitData suitSavedData)
  531. {
  532. TakeOffAll(false);
  533. if (suitSavedData.bg > 0)
  534. {
  535. AddOrRemove(suitSavedData.bg, false);
  536. }
  537. foreach (int itemID in suitSavedData.equipDatas)
  538. {
  539. AddOrRemove(itemID, false, true);
  540. }
  541. _suitId = suitSavedData.suitId;
  542. _isPic = suitSavedData.pic;
  543. checkDefaultItem();
  544. UpdatePicAction();
  545. }
  546. public void PutOnSuitSavedInFight(int index)
  547. {
  548. TakeOffAll(false);
  549. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  550. if (suitSavedData.suitId > 0)
  551. {
  552. PutOnSuitCfg(suitSavedData.suitId, false, true);
  553. }
  554. else
  555. {
  556. foreach (int itemID in suitSavedData.equipDatas)
  557. {
  558. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  559. {
  560. AddOrRemove(itemID, false, true);
  561. }
  562. }
  563. checkDefaultItem();
  564. }
  565. }
  566. // public void PutOnCurrentSuitSaved()
  567. // {
  568. // PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  569. // }
  570. public void PutOnDefaultSuitSaved(bool withBg = true)
  571. {
  572. TakeOffAll(false);
  573. CustomSuitData suitSavedData = CustomSuitDataManager.CreateDefaultSuitData(0);
  574. foreach (int itemID in suitSavedData.equipDatas)
  575. {
  576. AddOrRemove(itemID, false, true);
  577. }
  578. if (withBg)
  579. {
  580. if (suitSavedData.bg > 0)
  581. {
  582. AddOrRemove(suitSavedData.bg, false);
  583. }
  584. }
  585. checkDefaultItem();
  586. UpdatePicAction();
  587. }
  588. public void PutOnRecommendItems()
  589. {
  590. TakeOffAll(false);
  591. List<int> recommendList = DressUpMenuItemDataManager.GetRecommendItemList();
  592. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  593. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  594. int liangyiqunIndex = -1;
  595. int shangyiIndex = -1;
  596. int xiazhuangIndex = -1;
  597. int neidaIndex = -1;
  598. for (int i = 0; i < recommendList.Count; i++)
  599. {
  600. int subType = ItemUtilCS.GetItemSubType(recommendList[i]);
  601. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  602. {
  603. liangyiqunIndex = i;
  604. continue;
  605. }
  606. if (subType == ConstDressUpItemType.SHANG_YI)
  607. {
  608. shangyiIndex = i;
  609. continue;
  610. }
  611. if (subType == ConstDressUpItemType.XIA_ZHUANG)
  612. {
  613. xiazhuangIndex = i;
  614. continue;
  615. }
  616. if (subType == ConstDressUpItemType.NEI_DA)
  617. {
  618. neidaIndex = i;
  619. continue;
  620. }
  621. }
  622. if (liangyiqunIndex >= 0 && (shangyiIndex >= 0 || xiazhuangIndex >= 0))
  623. {
  624. if (shangyiIndex < 0 && xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);//上衣下装只有一件,则保留连衣裙
  625. if (xiazhuangIndex < 0 && shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  626. if (shangyiIndex >= 0 && xiazhuangIndex >= 0)//同时拥有上衣、下装、连衣裙
  627. {
  628. int lianyiqunScore = DressUpMenuItemDataManager.GetItemScore(recommendList[liangyiqunIndex]);
  629. int shangyiScore = DressUpMenuItemDataManager.GetItemScore(recommendList[shangyiIndex]);
  630. int xiazhuangScore = DressUpMenuItemDataManager.GetItemScore(recommendList[xiazhuangIndex]);
  631. int neidaScore = neidaIndex >= 0 ? DressUpMenuItemDataManager.GetItemScore(recommendList[neidaIndex]) : 0;
  632. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  633. 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))//推荐列表里有必需品且,必需品类型为上衣或下装或连衣裙,有先穿戴必须品,其次穿戴高分服装
  634. {
  635. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  636. {
  637. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  638. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  639. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  640. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  641. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  642. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  643. }
  644. else if (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA)
  645. {
  646. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  647. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  648. }
  649. }
  650. else
  651. {
  652. if (lianyiqunScore > shangyiScore + xiazhuangScore + neidaScore)
  653. {
  654. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  655. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  656. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  657. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  658. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  659. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  660. }
  661. else
  662. {
  663. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  664. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  665. }
  666. }
  667. }
  668. }
  669. //推荐搭配自动穿必穿品
  670. if (fightCfg.needItemId > 0 && DressUpMenuItemDataManager.CheckHasItem(fightCfg.needItemId) && recommendList.IndexOf(fightCfg.needItemId) < 0)
  671. {
  672. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  673. for (int i = 0; i < recommendList.Count; i++)
  674. {
  675. int recommendSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  676. if (recommendSubType == subType)
  677. {
  678. recommendList.RemoveAt(i);
  679. break;
  680. }
  681. }
  682. recommendList.Add(fightCfg.needItemId);
  683. }
  684. else if (fightCfg.needSuitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(fightCfg.needSuitId))
  685. {
  686. recommendList.Clear();
  687. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
  688. recommendList.AddRange(cfg.partsArr);
  689. }
  690. foreach (int itemID in recommendList)
  691. {
  692. AddOrRemove(itemID, false, true);
  693. }
  694. checkDefaultItem();
  695. UpdatePicAction();
  696. }
  697. private int CheckIndex(int _subType, List<int> recommendList)
  698. {
  699. for (int i = 0; i < recommendList.Count; i++)
  700. {
  701. int itemSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  702. if (itemSubType == _subType)
  703. {
  704. return i;
  705. }
  706. }
  707. return -1;
  708. }
  709. public bool CheckEquipedFightNeeded()
  710. {
  711. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  712. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  713. if (fightCfg.needItemId > 0)
  714. {
  715. return CheckDressUpItemIsOn(fightCfg.needItemId);
  716. }
  717. else if (fightCfg.needSuitId > 0)
  718. {
  719. return CheckSuitIsOn(fightCfg.needSuitId);
  720. }
  721. return true;
  722. }
  723. //根据位置原点和随机范围获取评分位置
  724. public void GetCirclePos(Vector2 pos, int range, out float x, out float y)
  725. {
  726. int numX = UnityEngine.Random.Range(0, 2);
  727. int signX = numX % 2 == 0 ? 1 : -1;
  728. float rangeX = UnityEngine.Random.Range(0, range);
  729. x = pos.x + signX * (rangeX);
  730. int numY = UnityEngine.Random.Range(0, 2);
  731. int signY = numY % 2 == 0 ? 1 : -1;
  732. float rangeY = UnityEngine.Random.Range(0, range);
  733. y = pos.y + signY * (rangeY);
  734. }
  735. public int GetItemIdBuyType(int subType)
  736. {
  737. for (int i = 0; i < equipDatas.Count; i++)
  738. {
  739. 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)
  740. {
  741. if (subType == ItemUtilCS.GetItemSubType(equipDatas[i]))
  742. {
  743. return equipDatas[i];
  744. }
  745. }
  746. }
  747. if (suitId > 0)
  748. {
  749. return suitId;
  750. }
  751. return 0;
  752. }
  753. }
  754. }