DressUpObjDataCache.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  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 += ItemDataManager.GetItemAdditionScore(value, InstanceZonesDataManager.currentScoreType);
  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 -= ItemDataManager.GetItemAdditionScore(value, InstanceZonesDataManager.currentScoreType);
  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 += ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType);
  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, bool showOptional = true, bool CheckOwn = true)
  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(showOptional)
  522. {
  523. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  524. {
  525. items.AddRange(suitCfg.partsOptionalArr);
  526. }
  527. }
  528. int subType = 0;
  529. foreach (int itemID in items)
  530. {
  531. if (!CheckOwn || DressUpMenuItemDataManager.CheckHasItem(itemID))
  532. {
  533. bool isSceneType = DressUpMenuItemDataManager.CheckIsSceneType(itemID);
  534. subType = ItemUtilCS.GetItemSubType(itemID);
  535. if (!_isPic || isSceneType)
  536. {
  537. if (!noSceneType || !isSceneType)
  538. {
  539. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  540. {
  541. AddOrRemove(itemID, false, true);
  542. }
  543. }
  544. }
  545. }
  546. }
  547. checkDefaultItem();
  548. UpdatePicAction();
  549. }
  550. public CustomSuitData GetCurSuitData(int index)
  551. {
  552. CustomSuitData suitSavedData = new CustomSuitData(index);
  553. suitSavedData.equipDatas = EquipDataCache.cacher.equipDatas;
  554. suitSavedData.bg = EquipDataCache.cacher.bgId;
  555. suitSavedData.pic = EquipDataCache.cacher.picStatus;
  556. suitSavedData.suitId = EquipDataCache.cacher.suitId;
  557. return suitSavedData;
  558. }
  559. public void PutOnSuitSaved(int index)
  560. {
  561. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  562. PutOnSuitMemory(suitSavedData);
  563. }
  564. public void PutOnSuitMemory(CustomSuitData suitSavedData)
  565. {
  566. TakeOffAll(false);
  567. if (suitSavedData.bg > 0)
  568. {
  569. AddOrRemove(suitSavedData.bg, false);
  570. }
  571. foreach (int itemID in suitSavedData.equipDatas)
  572. {
  573. AddOrRemove(itemID, false, true);
  574. }
  575. _suitId = suitSavedData.suitId;
  576. _isPic = suitSavedData.pic;
  577. checkDefaultItem();
  578. UpdatePicAction();
  579. }
  580. public void PutOnSuitSavedInFight(int index)
  581. {
  582. TakeOffAll(false);
  583. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  584. if (suitSavedData.suitId > 0)
  585. {
  586. PutOnSuitCfg(suitSavedData.suitId, false, true);
  587. }
  588. else
  589. {
  590. foreach (int itemID in suitSavedData.equipDatas)
  591. {
  592. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  593. {
  594. AddOrRemove(itemID, false, true);
  595. }
  596. }
  597. checkDefaultItem();
  598. }
  599. }
  600. // public void PutOnCurrentSuitSaved()
  601. // {
  602. // PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  603. // }
  604. public void PutOnDefaultSuitSaved(bool withBg = true)
  605. {
  606. TakeOffAll(false);
  607. CustomSuitData suitSavedData = CustomSuitDataManager.CreateDefaultSuitData(0);
  608. foreach (int itemID in suitSavedData.equipDatas)
  609. {
  610. AddOrRemove(itemID, false, true);
  611. }
  612. if (withBg)
  613. {
  614. if (suitSavedData.bg > 0)
  615. {
  616. AddOrRemove(suitSavedData.bg, false);
  617. }
  618. }
  619. checkDefaultItem();
  620. UpdatePicAction();
  621. }
  622. public void PutOnRecommendItems()
  623. {
  624. TakeOffAll(false);
  625. List<int> recommendList = DressUpMenuItemDataManager.GetRecommendItemList();
  626. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  627. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  628. int liangyiqunIndex = -1;
  629. int shangyiIndex = -1;
  630. int xiazhuangIndex = -1;
  631. int neidaIndex = -1;
  632. for (int i = 0; i < recommendList.Count; i++)
  633. {
  634. int subType = ItemUtilCS.GetItemSubType(recommendList[i]);
  635. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  636. {
  637. liangyiqunIndex = i;
  638. continue;
  639. }
  640. if (subType == ConstDressUpItemType.SHANG_YI)
  641. {
  642. shangyiIndex = i;
  643. continue;
  644. }
  645. if (subType == ConstDressUpItemType.XIA_ZHUANG)
  646. {
  647. xiazhuangIndex = i;
  648. continue;
  649. }
  650. if (subType == ConstDressUpItemType.NEI_DA)
  651. {
  652. neidaIndex = i;
  653. continue;
  654. }
  655. }
  656. if (liangyiqunIndex >= 0 && (shangyiIndex >= 0 || xiazhuangIndex >= 0))
  657. {
  658. if (shangyiIndex < 0 && xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);//上衣下装只有一件,则保留连衣裙
  659. if (xiazhuangIndex < 0 && shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  660. if (shangyiIndex >= 0 && xiazhuangIndex >= 0)//同时拥有上衣、下装、连衣裙
  661. {
  662. int lianyiqunScore = ItemDataManager.GetItemAdditionScore(recommendList[liangyiqunIndex], InstanceZonesDataManager.currentScoreType);
  663. int shangyiScore = ItemDataManager.GetItemAdditionScore(recommendList[shangyiIndex], InstanceZonesDataManager.currentScoreType);
  664. int xiazhuangScore = ItemDataManager.GetItemAdditionScore(recommendList[xiazhuangIndex], InstanceZonesDataManager.currentScoreType);
  665. int neidaScore = neidaIndex >= 0 ? ItemDataManager.GetItemAdditionScore(recommendList[neidaIndex], InstanceZonesDataManager.currentScoreType) : 0;
  666. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  667. 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))//推荐列表里有必需品且,必需品类型为上衣或下装或连衣裙,有先穿戴必须品,其次穿戴高分服装
  668. {
  669. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  670. {
  671. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  672. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  673. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  674. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  675. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  676. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  677. }
  678. else if (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA)
  679. {
  680. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  681. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  682. }
  683. }
  684. else
  685. {
  686. if (lianyiqunScore > shangyiScore + xiazhuangScore + neidaScore)
  687. {
  688. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  689. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  690. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  691. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  692. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  693. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  694. }
  695. else
  696. {
  697. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  698. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  699. }
  700. }
  701. }
  702. }
  703. //推荐搭配自动穿必穿品
  704. if (fightCfg.needItemId > 0 && DressUpMenuItemDataManager.CheckHasItem(fightCfg.needItemId) && recommendList.IndexOf(fightCfg.needItemId) < 0)
  705. {
  706. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  707. for (int i = 0; i < recommendList.Count; i++)
  708. {
  709. int recommendSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  710. if (recommendSubType == subType)
  711. {
  712. recommendList.RemoveAt(i);
  713. break;
  714. }
  715. }
  716. recommendList.Add(fightCfg.needItemId);
  717. }
  718. else if (fightCfg.needSuitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(fightCfg.needSuitId))
  719. {
  720. recommendList.Clear();
  721. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
  722. recommendList.AddRange(cfg.partsArr);
  723. }
  724. foreach (int itemID in recommendList)
  725. {
  726. AddOrRemove(itemID, false, true);
  727. }
  728. checkDefaultItem();
  729. UpdatePicAction();
  730. }
  731. private int CheckIndex(int _subType, List<int> recommendList)
  732. {
  733. for (int i = 0; i < recommendList.Count; i++)
  734. {
  735. int itemSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  736. if (itemSubType == _subType)
  737. {
  738. return i;
  739. }
  740. }
  741. return -1;
  742. }
  743. public bool CheckEquipedFightNeeded()
  744. {
  745. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  746. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  747. if (fightCfg.needItemId > 0)
  748. {
  749. return CheckDressUpItemIsOn(fightCfg.needItemId);
  750. }
  751. else if (fightCfg.needSuitId > 0)
  752. {
  753. return CheckSuitIsOn(fightCfg.needSuitId);
  754. }
  755. return true;
  756. }
  757. //根据位置原点和随机范围获取评分位置
  758. public void GetCirclePos(Vector2 pos, int range, out float x, out float y)
  759. {
  760. int numX = UnityEngine.Random.Range(0, 2);
  761. int signX = numX % 2 == 0 ? 1 : -1;
  762. float rangeX = UnityEngine.Random.Range(0, range);
  763. x = pos.x + signX * (rangeX);
  764. int numY = UnityEngine.Random.Range(0, 2);
  765. int signY = numY % 2 == 0 ? 1 : -1;
  766. float rangeY = UnityEngine.Random.Range(0, range);
  767. y = pos.y + signY * (rangeY);
  768. }
  769. public int GetItemIdBuyType(int subType)
  770. {
  771. for (int i = 0; i < equipDatas.Count; i++)
  772. {
  773. 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)
  774. {
  775. if (subType == ItemUtilCS.GetItemSubType(equipDatas[i]))
  776. {
  777. return equipDatas[i];
  778. }
  779. }
  780. }
  781. if (suitId > 0)
  782. {
  783. return suitId;
  784. }
  785. return 0;
  786. }
  787. }
  788. }