DressUpObjDataCache.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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 has1 = false;
  277. //是否有连衣裙
  278. bool has2 = false;
  279. //是否有内搭
  280. bool has3 = false;
  281. //是否有上衣
  282. // bool has4 = false;
  283. //是否有下装
  284. bool has5 = false;
  285. //是否有默认内搭
  286. // bool has30000 = false;
  287. //是否有默认下装
  288. // bool has50000 = 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. has1 = true;
  296. }
  297. else if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  298. {
  299. has2 = true;
  300. }
  301. else if (subType == ConstDressUpItemType.NEI_DA)
  302. {
  303. has3 = true;
  304. }
  305. else if (subType == ConstDressUpItemType.XIA_ZHUANG)
  306. {
  307. has5 = true;
  308. }
  309. }
  310. if (!has1)
  311. {
  312. Add(10000);
  313. }
  314. if (!has2)
  315. {
  316. if (!has5)
  317. {
  318. Add(50000);
  319. }
  320. if (!has3)
  321. {
  322. Add(30000);
  323. }
  324. }
  325. }
  326. }
  327. /// <summary>
  328. /// 检测是否穿戴完整(穿着连衣裙或同时穿着上装下装)
  329. /// </summary>
  330. /// <returns></returns>
  331. public bool CheckPutOnFinish()
  332. {
  333. List<int> equipDatas = EquipDataCache.cacher.equipDatas;
  334. bool isLianYiQun = false;
  335. bool isShangYi = false;
  336. bool isXiaZhuang = false;
  337. for (int i = 0; i < equipDatas.Count; i++)
  338. {
  339. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDatas[i]);
  340. if (itemCfg.subType == ConstDressUpItemType.LIAN_YI_QUN && itemCfg.id != ConstItemID.DEFULT_LIAN_YI_QUN)
  341. {
  342. isLianYiQun = true; break;
  343. }
  344. if (itemCfg.subType == ConstDressUpItemType.SHANG_YI && itemCfg.id != ConstItemID.DEFULT_NEI_DA)
  345. {
  346. isShangYi = true;
  347. }
  348. if (itemCfg.subType == ConstDressUpItemType.XIA_ZHUANG && itemCfg.id != ConstItemID.DEFULT_XIA_ZHUANG)
  349. {
  350. isXiaZhuang = true;
  351. }
  352. }
  353. return isLianYiQun || isXiaZhuang && isShangYi;
  354. }
  355. private void UpdatePicAction()
  356. {
  357. if (IsSuitPic)
  358. {
  359. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  360. DressUpUtil.UpdateBody(suitCfg.picRes, _sceneObj, !string.IsNullOrEmpty(suitCfg.aniRes), suitCfg.effRes);
  361. }
  362. else
  363. {
  364. DressUpUtil.UpdateBody(null, _sceneObj, false, null, _needSetMask);
  365. }
  366. }
  367. public void TakeOffAll(bool checkDefault = true)
  368. {
  369. _suitId = 0;
  370. _isPic = false;
  371. // AddOrRemove(propID, false, true);
  372. var tempList = equipDatas;
  373. foreach (int itemID in tempList)
  374. {
  375. AddOrRemove(itemID, false, false, true);
  376. }
  377. if (checkDefault)
  378. {
  379. checkDefaultItem();
  380. UpdatePicAction();
  381. }
  382. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  383. score = roleLevelCfg.baseScore;
  384. foreach (int itemId in _equipDatas)
  385. {
  386. score += DressUpMenuItemDataManager.GetItemScore(itemId);
  387. }
  388. }
  389. public void ChangeAction()
  390. {
  391. if (!HasSuitPicRes)
  392. {
  393. return;
  394. }
  395. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  396. _isPic = !_isPic;
  397. if (_isPic)
  398. {
  399. var tempList = equipDatas;
  400. foreach (int itemID in tempList)
  401. {
  402. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  403. {
  404. AddOrRemove(itemID, false, false, true);
  405. }
  406. }
  407. }
  408. else
  409. {
  410. int[] items = suitCfg.partsArr;
  411. foreach (int itemId in items)
  412. {
  413. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemId))
  414. {
  415. AddOrRemove(itemId, false, true);
  416. }
  417. }
  418. }
  419. checkDefaultItem();
  420. UpdatePicAction();
  421. }
  422. public void TryCancelSuit(int itemID)
  423. {
  424. if (_suitId > 0)
  425. {
  426. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  427. {
  428. if (_isPic)
  429. {
  430. ChangeAction();
  431. }
  432. _suitId = 0;
  433. }
  434. }
  435. }
  436. public bool IsSuitPic
  437. {
  438. get
  439. {
  440. return _suitId > 0 && _isPic;
  441. }
  442. }
  443. public bool HasSuitPicRes
  444. {
  445. get
  446. {
  447. if (_suitId > 0)
  448. {
  449. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  450. if (suitCfg.picRes != null && suitCfg.picRes.Length > 0)
  451. {
  452. return true;
  453. }
  454. }
  455. return false;
  456. }
  457. }
  458. public void PutOnSuitCfg(int id, bool checkPic, bool noSceneType, int[] excludeType = null)
  459. {
  460. if (_suitId == id)
  461. {
  462. return;
  463. }
  464. TakeOffAll(false);
  465. _suitId = id;
  466. _isPic = HasSuitPicRes && checkPic;
  467. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
  468. List<int> items = new List<int>(suitCfg.partsArr);
  469. if (suitCfg.partsOptionalArr != null && suitCfg.partsOptionalArr.Length > 0)
  470. {
  471. items.AddRange(suitCfg.partsOptionalArr);
  472. }
  473. int subType = 0;
  474. foreach (int itemID in items)
  475. {
  476. if (DressUpMenuItemDataManager.CheckHasItem(itemID))
  477. {
  478. bool isSceneType = DressUpMenuItemDataManager.CheckIsSceneType(itemID);
  479. subType = ItemUtilCS.GetItemSubType(itemID);
  480. if (!_isPic || isSceneType)
  481. {
  482. if (!noSceneType || !isSceneType)
  483. {
  484. if (excludeType == null || Array.IndexOf(excludeType, subType) < 0)
  485. {
  486. AddOrRemove(itemID, false, true);
  487. }
  488. }
  489. }
  490. }
  491. }
  492. checkDefaultItem();
  493. UpdatePicAction();
  494. }
  495. public CustomSuitData GetCurSuitData(int index)
  496. {
  497. CustomSuitData suitSavedData = new CustomSuitData(index);
  498. suitSavedData.equipDatas = EquipDataCache.cacher.equipDatas;
  499. suitSavedData.bg = EquipDataCache.cacher.bgId;
  500. suitSavedData.pic = EquipDataCache.cacher.picStatus;
  501. suitSavedData.suitId = EquipDataCache.cacher.suitId;
  502. return suitSavedData;
  503. }
  504. public void PutOnSuitSaved(int index)
  505. {
  506. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  507. PutOnSuitMemory(suitSavedData);
  508. }
  509. public void PutOnSuitMemory(CustomSuitData suitSavedData)
  510. {
  511. TakeOffAll(false);
  512. if (suitSavedData.bg > 0)
  513. {
  514. AddOrRemove(suitSavedData.bg, false);
  515. }
  516. foreach (int itemID in suitSavedData.equipDatas)
  517. {
  518. AddOrRemove(itemID, false, true);
  519. }
  520. _suitId = suitSavedData.suitId;
  521. _isPic = suitSavedData.pic;
  522. checkDefaultItem();
  523. UpdatePicAction();
  524. }
  525. public void PutOnSuitSavedInFight(int index)
  526. {
  527. TakeOffAll(false);
  528. CustomSuitData suitSavedData = CustomSuitDataManager.GetSuitList(index);
  529. if (suitSavedData.suitId > 0)
  530. {
  531. PutOnSuitCfg(suitSavedData.suitId, false, true);
  532. }
  533. else
  534. {
  535. foreach (int itemID in suitSavedData.equipDatas)
  536. {
  537. if (!DressUpMenuItemDataManager.CheckIsSceneType(itemID))
  538. {
  539. AddOrRemove(itemID, false, true);
  540. }
  541. }
  542. checkDefaultItem();
  543. }
  544. }
  545. // public void PutOnCurrentSuitSaved()
  546. // {
  547. // PutOnSuitSaved(CustomSuitDataManager.currentIndex);
  548. // }
  549. public void PutOnDefaultSuitSaved(bool withBg = true)
  550. {
  551. TakeOffAll(false);
  552. CustomSuitData suitSavedData = CustomSuitDataManager.CreateDefaultSuitData(0);
  553. foreach (int itemID in suitSavedData.equipDatas)
  554. {
  555. AddOrRemove(itemID, false, true);
  556. }
  557. if (withBg)
  558. {
  559. if (suitSavedData.bg > 0)
  560. {
  561. AddOrRemove(suitSavedData.bg, false);
  562. }
  563. }
  564. checkDefaultItem();
  565. UpdatePicAction();
  566. }
  567. public void PutOnRecommendItems()
  568. {
  569. TakeOffAll(false);
  570. List<int> recommendList = DressUpMenuItemDataManager.GetRecommendItemList();
  571. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  572. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  573. int liangyiqunIndex = -1;
  574. int shangyiIndex = -1;
  575. int xiazhuangIndex = -1;
  576. int neidaIndex = -1;
  577. for (int i = 0; i < recommendList.Count; i++)
  578. {
  579. int subType = ItemUtilCS.GetItemSubType(recommendList[i]);
  580. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  581. {
  582. liangyiqunIndex = i;
  583. continue;
  584. }
  585. if (subType == ConstDressUpItemType.SHANG_YI)
  586. {
  587. shangyiIndex = i;
  588. continue;
  589. }
  590. if (subType == ConstDressUpItemType.XIA_ZHUANG)
  591. {
  592. xiazhuangIndex = i;
  593. continue;
  594. }
  595. if (subType == ConstDressUpItemType.NEI_DA)
  596. {
  597. neidaIndex = i;
  598. continue;
  599. }
  600. }
  601. if (liangyiqunIndex >= 0 && (shangyiIndex >= 0 || xiazhuangIndex >= 0))
  602. {
  603. if (shangyiIndex < 0 && xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);//上衣下装只有一件,则保留连衣裙
  604. if (xiazhuangIndex < 0 && shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  605. if (shangyiIndex >= 0 && xiazhuangIndex >= 0)//同时拥有上衣、下装、连衣裙
  606. {
  607. int lianyiqunScore = DressUpMenuItemDataManager.GetItemScore(recommendList[liangyiqunIndex]);
  608. int shangyiScore = DressUpMenuItemDataManager.GetItemScore(recommendList[shangyiIndex]);
  609. int xiazhuangScore = DressUpMenuItemDataManager.GetItemScore(recommendList[xiazhuangIndex]);
  610. int neidaScore = neidaIndex >= 0 ? DressUpMenuItemDataManager.GetItemScore(recommendList[neidaIndex]) : 0;
  611. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  612. 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))//推荐列表里有必需品且,必需品类型为上衣或下装或连衣裙,有先穿戴必须品,其次穿戴高分服装
  613. {
  614. if (subType == ConstDressUpItemType.LIAN_YI_QUN)
  615. {
  616. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  617. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  618. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  619. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  620. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  621. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  622. }
  623. else if (subType == ConstDressUpItemType.SHANG_YI || subType == ConstDressUpItemType.XIA_ZHUANG || subType == ConstDressUpItemType.NEI_DA)
  624. {
  625. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  626. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  627. }
  628. }
  629. else
  630. {
  631. if (lianyiqunScore > shangyiScore + xiazhuangScore + neidaScore)
  632. {
  633. shangyiIndex = CheckIndex(ConstDressUpItemType.SHANG_YI, recommendList);
  634. if (shangyiIndex >= 0) recommendList.RemoveAt(shangyiIndex);
  635. xiazhuangIndex = CheckIndex(ConstDressUpItemType.XIA_ZHUANG, recommendList);
  636. if (xiazhuangIndex >= 0) recommendList.RemoveAt(xiazhuangIndex);
  637. neidaIndex = CheckIndex(ConstDressUpItemType.NEI_DA, recommendList);
  638. if (neidaIndex >= 0) recommendList.RemoveAt(neidaIndex);
  639. }
  640. else
  641. {
  642. liangyiqunIndex = CheckIndex(ConstDressUpItemType.LIAN_YI_QUN, recommendList);
  643. if (liangyiqunIndex >= 0) recommendList.RemoveAt(liangyiqunIndex);
  644. }
  645. }
  646. }
  647. }
  648. //推荐搭配自动穿必穿品
  649. if (fightCfg.needItemId > 0 && DressUpMenuItemDataManager.CheckHasItem(fightCfg.needItemId) && recommendList.IndexOf(fightCfg.needItemId) < 0)
  650. {
  651. int subType = ItemUtilCS.GetItemSubType(fightCfg.needItemId);
  652. for (int i = 0; i < recommendList.Count; i++)
  653. {
  654. int recommendSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  655. if (recommendSubType == subType)
  656. {
  657. recommendList.RemoveAt(i);
  658. break;
  659. }
  660. }
  661. recommendList.Add(fightCfg.needItemId);
  662. }
  663. else if (fightCfg.needSuitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(fightCfg.needSuitId))
  664. {
  665. recommendList.Clear();
  666. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
  667. recommendList.AddRange(cfg.partsArr);
  668. }
  669. foreach (int itemID in recommendList)
  670. {
  671. AddOrRemove(itemID, false, true);
  672. }
  673. checkDefaultItem();
  674. UpdatePicAction();
  675. }
  676. private int CheckIndex(int _subType, List<int> recommendList)
  677. {
  678. for (int i = 0; i < recommendList.Count; i++)
  679. {
  680. int itemSubType = ItemUtilCS.GetItemSubType(recommendList[i]);
  681. if (itemSubType == _subType)
  682. {
  683. return i;
  684. }
  685. }
  686. return -1;
  687. }
  688. public bool CheckEquipedFightNeeded()
  689. {
  690. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  691. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  692. if (fightCfg.needItemId > 0)
  693. {
  694. return CheckDressUpItemIsOn(fightCfg.needItemId);
  695. }
  696. else if (fightCfg.needSuitId > 0)
  697. {
  698. return CheckSuitIsOn(fightCfg.needSuitId);
  699. }
  700. return true;
  701. }
  702. //根据位置原点和随机范围获取评分位置
  703. public void GetCirclePos(Vector2 pos, int range, out float x, out float y)
  704. {
  705. int numX = UnityEngine.Random.Range(0, 2);
  706. int signX = numX % 2 == 0 ? 1 : -1;
  707. float rangeX = UnityEngine.Random.Range(0, range);
  708. x = pos.x + signX * (rangeX);
  709. int numY = UnityEngine.Random.Range(0, 2);
  710. int signY = numY % 2 == 0 ? 1 : -1;
  711. float rangeY = UnityEngine.Random.Range(0, range);
  712. y = pos.y + signY * (rangeY);
  713. }
  714. public int GetItemIdBuyType(int subType)
  715. {
  716. for (int i = 0; i < equipDatas.Count; i++)
  717. {
  718. 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)
  719. {
  720. if (subType == ItemUtilCS.GetItemSubType(equipDatas[i]))
  721. {
  722. return equipDatas[i];
  723. }
  724. }
  725. }
  726. if (suitId > 0)
  727. {
  728. return suitId;
  729. }
  730. return 0;
  731. }
  732. }
  733. }