DressUpObjDataCache.cs 29 KB

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