DressUpObjDataCache.cs 29 KB

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