DressUpMenuItemDataManager.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. using ET;
  6. using FairyGUI;
  7. namespace GFGGame
  8. {
  9. public enum DressFilterType
  10. {
  11. None,
  12. Search,
  13. Filter
  14. }
  15. public class DressUpMenuItemDataManager
  16. {
  17. public static string dressSearchTxt = "";
  18. public static DressFilterType dressFilterType = DressFilterType.None;
  19. public static List<int> selectRarityList = new List<int>();
  20. public static List<int> selectScoreList = new List<int>();
  21. public static List<string> selectTagList = new List<string>();
  22. private static List<int> _itemDatas = new List<int>();
  23. private static Dictionary<int, List<int>> _itemDatasBySubTypeDic = new Dictionary<int, List<int>>();
  24. public static Dictionary<int, List<int>> ItemDatasBySubTypeDic { get { return _itemDatasBySubTypeDic; } }
  25. private static Dictionary<int, List<int>> _newItemdata = new Dictionary<int, List<int>>();
  26. private static Dictionary<int, List<int>> _itemDatasByRarityDic = new Dictionary<int, List<int>>();
  27. //存储初始化时的衣服,用于性能优化,逐帧加载配置
  28. public static List<int> itemIDListInited = new List<int>();
  29. public static void InitData()
  30. {
  31. _itemDatas.Clear();
  32. _newItemdata.Clear();
  33. _itemDatasBySubTypeDic.Clear();
  34. _itemDatasByRarityDic.Clear();
  35. }
  36. public static void Clear()
  37. {
  38. DressUpMenuItemDataManager.dressFilterType = DressFilterType.None;
  39. selectRarityList.Clear();
  40. selectScoreList.Clear();
  41. selectTagList.Clear();
  42. dressSearchTxt = "";
  43. }
  44. public static void Add(ItemInfoProto itemInfoProto)
  45. {
  46. var value = itemInfoProto.ConfigId;
  47. //初始化时禁止使用物品配置,会造成卡顿!!!
  48. if (!_itemDatas.Contains(value))
  49. {
  50. _itemDatas.Add(value);
  51. int subType = itemInfoProto.SubType;
  52. subType = subType >= (int)ConstDressUpItemType.TE_SHU ? (int)ConstDressUpItemType.TE_SHU : subType;
  53. if (!_itemDatasBySubTypeDic.ContainsKey(subType))
  54. {
  55. _itemDatasBySubTypeDic.Add(subType, new List<int>());
  56. }
  57. _itemDatasBySubTypeDic[subType].Add(value);
  58. if (!_itemDatasByRarityDic.ContainsKey(itemInfoProto.Rarity))
  59. {
  60. _itemDatasByRarityDic.Add(itemInfoProto.Rarity, new List<int>());
  61. }
  62. _itemDatasByRarityDic[itemInfoProto.Rarity].Add(value);
  63. if (GameGlobal.DataInited)
  64. {
  65. AddNewDressItem(value);
  66. DressUpMenuSuitDataManager.CheckItemInSuit(value);
  67. }
  68. else
  69. {
  70. itemIDListInited.Add(value);
  71. }
  72. }
  73. }
  74. public static bool CheckHasItem(int itemID)
  75. {
  76. return _itemDatas.Contains(itemID);
  77. }
  78. public static void Remove(int value)
  79. {
  80. if (_itemDatas == null)
  81. {
  82. return;
  83. }
  84. if (_itemDatas.Contains(value))
  85. {
  86. _itemDatas.Remove(value);
  87. }
  88. int subType = ItemUtilCS.GetItemSubType(value);
  89. subType = subType >= (int)ConstDressUpItemType.TE_SHU ? (int)ConstDressUpItemType.TE_SHU : subType;
  90. if (_itemDatasBySubTypeDic.ContainsKey(subType) && _itemDatasBySubTypeDic[subType].IndexOf(value) >= 0)
  91. {
  92. _itemDatasBySubTypeDic[subType].Remove(value);
  93. }
  94. int rarity = ItemCfgArray.Instance.GetCfg(value).rarity;
  95. if (_itemDatasByRarityDic.ContainsKey(rarity) && _itemDatasByRarityDic[rarity].IndexOf(value) >= 0)
  96. {
  97. _itemDatasByRarityDic[rarity].Remove(value);
  98. }
  99. }
  100. public static List<int> getItemDatasByType(int type)
  101. {
  102. List<int> arrayList = new List<int>();
  103. if (_itemDatasBySubTypeDic.ContainsKey(type))
  104. {
  105. arrayList.AddRange(_itemDatasBySubTypeDic[type]);
  106. }
  107. // for (int i = 0; i < _itemDatas.Count; i++)
  108. // {
  109. // int itemID = (int)_itemDatas[i];
  110. // int subType = ItemUtilCS.GetItemSubType(itemID);
  111. // if (type == (int)ConstDressUpItemType.TE_SHU && subType > type)
  112. // {
  113. // arrayList.Add(itemID);
  114. // }
  115. // else if (subType == type)
  116. // {
  117. // arrayList.Add(itemID);
  118. // }
  119. // }
  120. return arrayList;
  121. }
  122. public static List<int> SortItemListByHighScore(List<int> arrayList, bool checkNew = false)
  123. {
  124. arrayList.Sort((int a, int b) =>
  125. {
  126. if (checkNew)
  127. {
  128. bool isNewA = CheckIsDressUpItemNew(a);
  129. bool isNewB = CheckIsDressUpItemNew(b);
  130. if (isNewA != isNewB)
  131. {
  132. if (isNewA) return -1;
  133. if (isNewB) return 1;
  134. }
  135. }
  136. int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  137. int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  138. if (scoreB > scoreA) return 1;
  139. if (scoreB < scoreA) return -1;
  140. return a - b;
  141. });
  142. return arrayList;
  143. }
  144. public static List<int> SortItemListByLowScore(List<int> arrayList, bool checkNew = false)
  145. {
  146. arrayList.Sort((int a, int b) =>
  147. {
  148. if (checkNew)
  149. {
  150. bool isNewA = CheckIsDressUpItemNew(a);
  151. bool isNewB = CheckIsDressUpItemNew(b);
  152. if (isNewA != isNewB)
  153. {
  154. if (isNewA) return -1;
  155. if (isNewB) return 1;
  156. }
  157. }
  158. int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  159. int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  160. if (scoreB < scoreA)
  161. {
  162. return 1;
  163. }
  164. else if (scoreB > scoreA)
  165. {
  166. return -1;
  167. }
  168. return 0;
  169. });
  170. return arrayList;
  171. }
  172. private static List<int> SortItemListByScoreByType(List<int> arrayList)
  173. {
  174. arrayList.Sort((int a, int b) =>
  175. {
  176. int typeA = ItemUtilCS.GetItemSubType(a);
  177. int typeB = ItemUtilCS.GetItemSubType(b);
  178. int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  179. int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
  180. if (typeB < typeA)
  181. {
  182. return -1;
  183. }
  184. else if (typeB > typeA)
  185. {
  186. return 1;
  187. }
  188. else if (scoreB > scoreA)
  189. {
  190. return 1;
  191. }
  192. else if (scoreB < scoreA)
  193. {
  194. return -1;
  195. }
  196. return 0;
  197. });
  198. return arrayList;
  199. }
  200. public static List<int> SortItemListByHighRarity(List<int> arrayList)
  201. {
  202. arrayList.Sort((int a, int b) =>
  203. {
  204. ItemCfg itemCfgA = ItemCfgArray.Instance.GetCfg(a);
  205. ItemCfg itemCfgB = ItemCfgArray.Instance.GetCfg(b);
  206. bool isNewA = CheckIsDressUpItemNew(a);
  207. bool isNewB = CheckIsDressUpItemNew(b);
  208. if (isNewA != isNewB)
  209. {
  210. if (isNewA) return -1;
  211. if (isNewB) return 1;
  212. }
  213. if (itemCfgB.rarity > itemCfgA.rarity)
  214. {
  215. return 1;
  216. }
  217. else if (itemCfgB.rarity < itemCfgA.rarity)
  218. {
  219. return -1;
  220. }
  221. return 0;
  222. });
  223. return arrayList;
  224. }
  225. public static List<int> SortItemListByLowRarity(List<int> arrayList)
  226. {
  227. arrayList.Sort((int a, int b) =>
  228. {
  229. ItemCfg itemCfgA = ItemCfgArray.Instance.GetCfg(a);
  230. ItemCfg itemCfgB = ItemCfgArray.Instance.GetCfg(b);
  231. bool isNewA = CheckIsDressUpItemNew(a);
  232. bool isNewB = CheckIsDressUpItemNew(b);
  233. if (isNewA != isNewB)
  234. {
  235. if (isNewA) return -1;
  236. if (isNewB) return 1;
  237. }
  238. if (itemCfgB.rarity < itemCfgA.rarity)
  239. {
  240. return 1;
  241. }
  242. else if (itemCfgB.rarity > itemCfgA.rarity)
  243. {
  244. return -1;
  245. }
  246. return 0;
  247. });
  248. return arrayList;
  249. }
  250. public static List<int> GetRecommendItemList(bool toSort = true)
  251. {
  252. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  253. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  254. List<int> recommendTypeList = new List<int>();
  255. List<int> recommendList = new List<int>();
  256. List<int> recommendSpecialList = new List<int>();
  257. List<int> tempAllList = _itemDatas.GetRange(0, _itemDatas.Count);
  258. if (toSort)
  259. {
  260. SortItemListByScoreByType(tempAllList);
  261. }
  262. foreach (int itemID in tempAllList)
  263. {
  264. int subType = ItemUtilCS.GetItemSubType(itemID);
  265. if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID) && subType != ConstDressUpItemType.BEI_JING)
  266. {
  267. if (!recommendTypeList.Contains(subType))
  268. {
  269. bool isNeed = fightCfg.needItemId > 0 && (ItemUtilCS.GetItemSubType(fightCfg.needItemId) != subType || ItemUtilCS.GetItemSubType(fightCfg.needItemId) == subType && fightCfg.needItemId == itemID);
  270. if (isNeed || fightCfg.needItemId <= 0)
  271. {
  272. if (subType < ConstDressUpItemType.TE_SHU)
  273. {
  274. recommendList.Add(itemID);
  275. }
  276. recommendTypeList.Add(subType);
  277. }
  278. }
  279. }
  280. }
  281. recommendSpecialList = DressUpMenuItemDataManager.getItemDatasByType(ConstDressUpItemType.TE_SHU);
  282. recommendSpecialList = DressUpMenuItemDataManager.SortItemListByHighScore(recommendSpecialList);
  283. List<int> specialSubList = new List<int>();
  284. List<int> specialIdList = new List<int>();
  285. foreach (int itemID in recommendSpecialList)
  286. {
  287. int subType = ItemUtilCS.GetItemSubType(itemID);
  288. if (subType > ConstDressUpItemType.TE_SHU)
  289. {
  290. if (specialSubList.Count >= 3) continue;
  291. if (specialSubList.IndexOf(subType) < 0)
  292. {
  293. specialSubList.Add(subType);
  294. specialIdList.Add(itemID);
  295. }
  296. }
  297. }
  298. recommendList.AddRange(specialIdList);
  299. return recommendList;
  300. }
  301. // public static int GetRecommendCount()
  302. // {
  303. // List<int> recommendTypeList = GetRecommendItemList(false);
  304. // return recommendTypeList.Count;
  305. // }
  306. // public static int GetItemScore(int itemId)
  307. // {
  308. // return ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType);
  309. // }
  310. public static List<int> DressSearch(bool includeScene = true)
  311. {
  312. List<int> searchList = new List<int>();
  313. for (int i = 0; i < _itemDatas.Count; i++)
  314. {
  315. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemDatas[i]);
  316. if (!includeScene && DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(_itemDatas[i])) continue;
  317. if (itemCfg.name.IndexOf(dressSearchTxt) >= 0 && searchList.IndexOf(itemCfg.id) < 0)
  318. {
  319. searchList.Add(itemCfg.id);
  320. }
  321. }
  322. return searchList;
  323. }
  324. public static List<int> DressFilter(bool includeScene = true)
  325. {
  326. List<int> filterList = new List<int>();
  327. for (int i = 0; i < _itemDatas.Count; i++)
  328. {
  329. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemDatas[i]);
  330. if (!includeScene && DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(_itemDatas[i])) continue;
  331. bool isTag = selectTagList.Count == 0;
  332. if (selectTagList.Count > 0)
  333. {
  334. for (int j = 0; j < itemCfg.tagsArr.Length; j++)
  335. {
  336. if (selectTagList.IndexOf(itemCfg.tagsArr[j][0]) >= 0)
  337. {
  338. isTag = true;
  339. break;
  340. }
  341. }
  342. }
  343. if (!isTag) continue;
  344. if (selectRarityList.Count > 0 && selectRarityList.IndexOf(itemCfg.rarity) < 0) continue;
  345. if (selectScoreList.Count > 0 && selectScoreList.IndexOf(itemCfg.mainScore) < 0) continue;
  346. filterList.Add(itemCfg.id);
  347. }
  348. return filterList;
  349. }
  350. public static List<int> DressSearch(List<int> list)
  351. {
  352. List<int> searchList = new List<int>();
  353. for (int i = 0; i < list.Count; i++)
  354. {
  355. bool isSearch = true;
  356. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(list[i]);
  357. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(list[i]);
  358. string name = itemCfg != null ? itemCfg.name : suitCfg.name;
  359. for (int j = 0; j < dressSearchTxt.Length; j++)
  360. {
  361. if (name.IndexOf(dressSearchTxt[j]) < 0)
  362. {
  363. isSearch = false;
  364. break;
  365. }
  366. }
  367. if (isSearch)
  368. {
  369. searchList.Add(list[i]);
  370. }
  371. }
  372. return searchList;
  373. }
  374. public static List<int> DressFilter(List<int> list)
  375. {
  376. List<int> filterList = new List<int>();
  377. for (int i = 0; i < list.Count; i++)
  378. {
  379. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(list[i]);
  380. SuitCfg tzCfg = SuitCfgArray.Instance.GetCfg(list[i]);
  381. bool isRarity = cfg == null ? FilterRarity(tzCfg) : FilterRarity(cfg);
  382. bool isScore = cfg == null ? true : FilterScore(cfg);
  383. bool isTag = cfg == null ? true : FilterTag(cfg);
  384. if (isRarity && isScore && isTag)
  385. {
  386. filterList.Add(list[i]);
  387. }
  388. }
  389. if (filterList.Count == 0)
  390. {
  391. PromptController.Instance.ShowFloatTextPrompt("无满足条件物品");
  392. }
  393. return filterList;
  394. }
  395. private static bool FilterRarity(ItemCfg cfg)
  396. {
  397. bool isRarity = false;
  398. if (selectRarityList.Count > 0)
  399. {
  400. for (int j = 0; j < selectRarityList.Count; j++)
  401. {
  402. if (cfg != null && cfg.rarity == selectRarityList[j])
  403. {
  404. isRarity = true;
  405. break;
  406. }
  407. }
  408. }
  409. else
  410. {
  411. isRarity = true;
  412. }
  413. return isRarity;
  414. }
  415. private static bool FilterRarity(SuitCfg cfg)
  416. {
  417. bool isRarity = false;
  418. if (selectRarityList.Count > 0)
  419. {
  420. for (int j = 0; j < selectRarityList.Count; j++)
  421. {
  422. if (cfg != null && cfg.rarity == selectRarityList[j])
  423. {
  424. isRarity = true;
  425. break;
  426. }
  427. }
  428. }
  429. else
  430. {
  431. isRarity = true;
  432. }
  433. return isRarity;
  434. }
  435. private static bool FilterScore(ItemCfg cfg)
  436. {
  437. bool isScore = false;
  438. if (selectScoreList.Count > 0)
  439. {
  440. if (cfg != null)
  441. {
  442. for (int j = 0; j < selectScoreList.Count; j++)
  443. {
  444. if (cfg.mainScore == selectScoreList[j])
  445. {
  446. isScore = true;
  447. break;
  448. }
  449. }
  450. }
  451. }
  452. else
  453. {
  454. isScore = true;
  455. }
  456. return isScore;
  457. }
  458. private static bool FilterTag(ItemCfg cfg)
  459. {
  460. bool isTag = false;
  461. if (selectTagList.Count > 0)
  462. {
  463. if (cfg != null)
  464. {
  465. for (int j = 0; j < selectTagList.Count; j++)
  466. {
  467. if (isTag == true)
  468. {
  469. break;
  470. }
  471. for (int k = 0; k < cfg.tagsArr.Length; k++)
  472. {
  473. if (cfg.tagsArr[k][0] == selectTagList[j])
  474. {
  475. isTag = true;
  476. break;
  477. }
  478. }
  479. }
  480. }
  481. }
  482. else
  483. {
  484. isTag = true;
  485. }
  486. return isTag;
  487. }
  488. public static void AddNewDressItem(int value)
  489. {
  490. int subType = ItemDataManager.GetItemSubType(value);
  491. if (!_newItemdata.ContainsKey(subType))
  492. {
  493. _newItemdata.Add(subType, new List<int>());
  494. }
  495. _newItemdata[subType].Add(value);
  496. // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(value);
  497. // if (itemCfg.suitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(itemCfg.suitId))
  498. // {
  499. // SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(itemCfg.suitId);
  500. // }
  501. }
  502. public static void RemoveNewDressItem(int itemId)
  503. {
  504. int subType = ItemCfgArray.Instance.GetCfg(itemId).subType;
  505. if (_newItemdata.ContainsKey(subType) && _newItemdata[subType].IndexOf(itemId) >= 0)
  506. {
  507. _newItemdata[subType].Remove(itemId);
  508. }
  509. }
  510. //检测一级菜单是否有展示新增
  511. public static bool CheckIsFirstMenuNew(int menuId)
  512. {
  513. if (_newItemdata.Count == 0) return false;
  514. DressUpMenuItemCfg1 cfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuId);
  515. if (cfg1.subMenusArr.Length > 0)//有二级菜单
  516. {
  517. foreach (int id2 in cfg1.subMenusArr)
  518. {
  519. if (CheckIsSecondMenuNew(id2)) return true;
  520. }
  521. }
  522. else
  523. {
  524. if (_newItemdata.ContainsKey(cfg1.type) && _newItemdata[cfg1.type].Count > 0) return true;
  525. }
  526. return false;
  527. }
  528. //检测二级菜单是否有展示新增
  529. public static bool CheckIsSecondMenuNew(int subMenuId)
  530. {
  531. if (_newItemdata.Count == 0) return false;
  532. DressUpMenuItemCfg2 cfg2 = DressUpMenuItemCfg2Array.Instance.GetCfg(subMenuId);
  533. if (_newItemdata.ContainsKey(cfg2.type) && _newItemdata[cfg2.type].Count > 0)
  534. {
  535. return true;
  536. }
  537. return false;
  538. }
  539. //检测服装部件是否为新增
  540. public static bool CheckIsDressUpItemNew(int itemId)
  541. {
  542. if (_newItemdata.Count == 0) return false;
  543. int subType = ItemUtilCS.GetItemSubType(itemId);
  544. return _newItemdata.ContainsKey(subType) && _newItemdata[subType].IndexOf(itemId) >= 0;
  545. }
  546. //预加载服装配置
  547. public static void StartPreLoadItemCfg()
  548. {
  549. Timers.inst.AddUpdate(updateOnPreLoad);
  550. }
  551. private static void updateOnPreLoad(object param = null)
  552. {
  553. for(var i = 0; i < 3; i++)
  554. {
  555. PreLoadOneItemCfg();
  556. }
  557. if (itemIDListInited.Count <= 0)
  558. {
  559. Timers.inst.Remove(updateOnPreLoad);
  560. }
  561. }
  562. private static void PreLoadOneItemCfg()
  563. {
  564. var itemIDListInited = DressUpMenuItemDataManager.itemIDListInited;
  565. if (itemIDListInited.Count > 0)
  566. {
  567. int lasetIndex = itemIDListInited.Count - 1;
  568. int itemId = itemIDListInited[lasetIndex];
  569. itemIDListInited.RemoveAt(lasetIndex);
  570. ItemCfgArray.Instance.GetCfg(itemId);
  571. }
  572. }
  573. public static int[] dressUpGuideSubType = {
  574. ConstDressUpItemType.FA_XING, ConstDressUpItemType.LIAN_YI_QUN , ConstDressUpItemType.NEI_DA,
  575. ConstDressUpItemType.WAI_TAO,ConstDressUpItemType.SHANG_YI,ConstDressUpItemType.XIA_ZHUANG,ConstDressUpItemType.WA_ZI,
  576. ConstDressUpItemType.XIE_ZI,ConstDressUpItemType.SHOU_CHI_WU, ConstDressUpItemType.ZHUANG_RONG};
  577. public static int[] dressUpGuideAccessoriesType = {
  578. ConstDressUpItemType.TOU_SHI, ConstDressUpItemType.ER_SHI , ConstDressUpItemType.JING_SHI,
  579. ConstDressUpItemType.MIAN_BU,ConstDressUpItemType.YAO_SHI,ConstDressUpItemType.SHOU_SHI,ConstDressUpItemType.PI_BO};
  580. /// <summary>
  581. /// 根据主属性获取有序服装散件ID列表(排序规则: 已获得按稀有度从高到低 > 未获得按稀有度从高到低 > 名字拼音)
  582. /// 包含已获得和未获得
  583. /// </summary>
  584. /// <param name="subType">0-全部</param>
  585. /// <param name="sorted">true-有序</param>
  586. /// <returns></returns>
  587. public static List<int> GetAllDressUpGuideIdListBySubType(int subType, bool sorted = true)
  588. {
  589. List<int> result = new List<int>();
  590. List<ItemCfg> itemCfgs = new List<ItemCfg>();
  591. // 全部
  592. if (subType == 0)
  593. {
  594. // 除饰品外的散件
  595. for (int i = 0; i < dressUpGuideSubType.Length; i++)
  596. {
  597. itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, dressUpGuideSubType[i]));
  598. }
  599. // 饰品
  600. for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
  601. {
  602. itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, dressUpGuideAccessoriesType[i]));
  603. }
  604. // 特殊
  605. ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
  606. for (int i = 0; i < itemTypeCfg.Length; i++)
  607. {
  608. if (itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
  609. {
  610. itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, itemTypeCfg[i].type));
  611. }
  612. }
  613. }
  614. // 指定子类型
  615. else
  616. {
  617. if(subType == ConstDressUpItemType.TE_SHU)
  618. {
  619. ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
  620. for(int i = 0;i< itemTypeCfg.Length; i++)
  621. {
  622. if(itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
  623. {
  624. itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, itemTypeCfg[i].type));
  625. }
  626. }
  627. }
  628. else
  629. {
  630. itemCfgs = ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, subType);
  631. }
  632. }
  633. if (sorted)
  634. {
  635. itemCfgs.Sort((a, b) =>
  636. {
  637. bool haveA = CheckHasItem(a.id);
  638. bool haveB = CheckHasItem(b.id);
  639. if (haveB && !haveA)
  640. {
  641. return 1;
  642. }
  643. else if (!haveB && haveA)
  644. {
  645. return -1;
  646. }
  647. if (a.rarity != b.rarity)
  648. {
  649. return a.rarity > b.rarity ? -1 : 1;
  650. }
  651. return a.res.CompareTo(b.res);
  652. });
  653. }
  654. for (int i = 0; i < itemCfgs.Count; i++)
  655. {
  656. if(itemCfgs[i].isHide <= 0)
  657. {
  658. result.Add(itemCfgs[i].id);
  659. }
  660. }
  661. return result;
  662. }
  663. public static void GetAllDressUpGuideIdListBySubTypeAsync()
  664. {
  665. // 除饰品外的散件
  666. for (int i = 0; i < dressUpGuideSubType.Length; i++)
  667. {
  668. ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, dressUpGuideSubType[i]);
  669. }
  670. // 饰品
  671. for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
  672. {
  673. ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, dressUpGuideAccessoriesType[i]);
  674. }
  675. // 特殊
  676. ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
  677. for (int i = 0; i < itemTypeCfg.Length; i++)
  678. {
  679. if (itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
  680. {
  681. ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, itemTypeCfg[i].type);
  682. }
  683. }
  684. }
  685. public static void SortDressUpGuideIdList(List<int> list)
  686. {
  687. list.Sort((a, b) =>
  688. {
  689. ItemCfg itemA = ItemCfgArray.Instance.GetCfg(a);
  690. ItemCfg itemB = ItemCfgArray.Instance.GetCfg(b);
  691. bool haveA = CheckHasItem(itemA.id);
  692. bool haveB = CheckHasItem(itemB.id);
  693. if (haveB && !haveA)
  694. {
  695. return 1;
  696. }
  697. else if (!haveB && haveA)
  698. {
  699. return -1;
  700. }
  701. if (itemA.rarity != itemB.rarity)
  702. {
  703. return itemA.rarity > itemB.rarity ? -1 : 1;
  704. }
  705. return itemA.res.CompareTo(itemB.res);
  706. });
  707. }
  708. public static void GetTotalProgress(out int haveCount, out int totalCount)
  709. {
  710. totalCount = GlobalCfgArray.globalCfg.ClothingPartsCount;
  711. haveCount = 0;
  712. // 除饰品外的散件
  713. for (int i = 0; i < dressUpGuideSubType.Length; i++)
  714. {
  715. if (_itemDatasBySubTypeDic.ContainsKey(dressUpGuideSubType[i]))
  716. {
  717. haveCount += _itemDatasBySubTypeDic[dressUpGuideSubType[i]].Count;
  718. }
  719. }
  720. // 饰品
  721. for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
  722. {
  723. if (_itemDatasBySubTypeDic.ContainsKey(dressUpGuideAccessoriesType[i]))
  724. {
  725. haveCount += _itemDatasBySubTypeDic[dressUpGuideAccessoriesType[i]].Count;
  726. }
  727. }
  728. // 特殊
  729. if (_itemDatasBySubTypeDic.ContainsKey(ConstDressUpItemType.TE_SHU))
  730. {
  731. haveCount += _itemDatasBySubTypeDic[ConstDressUpItemType.TE_SHU].Count;
  732. }
  733. }
  734. }
  735. }