DressUpMenuItemDataManager.cs 32 KB

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