DressUpMenuItemDataManager.cs 35 KB

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