DressUpObjDataCache.cs 29 KB

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