123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925 |
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using UnityEngine;
- using ET;
- using FairyGUI;
- using System.Threading.Tasks;
- namespace GFGGame
- {
- public enum DressFilterType
- {
- None,
- Search,
- Filter
- }
- public class DressUpMenuItemDataManager
- {
- public static string dressSearchTxt = "";
- public static DressFilterType dressFilterType = DressFilterType.None;
- public static List<int> selectRarityList = new List<int>();
- public static List<int> selectScoreList = new List<int>();
- public static List<string> selectTagList = new List<string>();
- private static List<int> _itemDatas = new List<int>();
- private static Dictionary<int, List<int>> _itemDatasBySubTypeDic = new Dictionary<int, List<int>>();
- public static Dictionary<int, List<int>> ItemDatasBySubTypeDic { get { return _itemDatasBySubTypeDic; } }
- private static Dictionary<int, List<int>> _newItemdata = new Dictionary<int, List<int>>();
- private static Dictionary<int, List<int>> _itemDatasByRarityDic = new Dictionary<int, List<int>>();
- //存储初始化时的衣服,用于性能优化,逐帧加载配置
- public static List<int> itemIDListInited = new List<int>();
- public static void InitData()
- {
- _itemDatas.Clear();
- _newItemdata.Clear();
- _itemDatasBySubTypeDic.Clear();
- _itemDatasByRarityDic.Clear();
- }
- public static void Clear()
- {
- DressUpMenuItemDataManager.dressFilterType = DressFilterType.None;
- selectRarityList.Clear();
- selectScoreList.Clear();
- selectTagList.Clear();
- dressSearchTxt = "";
- }
- public static void Add(ItemInfoProto itemInfoProto)
- {
- var value = itemInfoProto.ConfigId;
- //初始化时禁止使用物品配置,会造成卡顿!!!
- if (!_itemDatas.Contains(value))
- {
- _itemDatas.Add(value);
- int subType = itemInfoProto.SubType;
- subType = subType >= (int)ConstDressUpItemType.TE_SHU ? (int)ConstDressUpItemType.TE_SHU : subType;
- if (!_itemDatasBySubTypeDic.ContainsKey(subType))
- {
- _itemDatasBySubTypeDic.Add(subType, new List<int>());
- }
- _itemDatasBySubTypeDic[subType].Add(value);
- if (!_itemDatasByRarityDic.ContainsKey(itemInfoProto.Rarity))
- {
- _itemDatasByRarityDic.Add(itemInfoProto.Rarity, new List<int>());
- }
- _itemDatasByRarityDic[itemInfoProto.Rarity].Add(value);
- if (GameGlobal.PreDataInited)
- {
- AddNewDressItem(value);
- DressUpMenuSuitDataManager.CheckItemInSuit(value);
- }
- else
- {
- itemIDListInited.Add(value);
- }
- }
- }
- public static bool CheckHasItem(int itemID)
- {
- return _itemDatas.Contains(itemID);
- }
- public static List<int> GetDressUpItemDatas()
- {
- return _itemDatas;
- }
- public static void Remove(int value)
- {
- if (_itemDatas == null)
- {
- return;
- }
- if (_itemDatas.Contains(value))
- {
- _itemDatas.Remove(value);
- }
- int subType = ItemUtilCS.GetItemSubType(value);
- subType = subType >= (int)ConstDressUpItemType.TE_SHU ? (int)ConstDressUpItemType.TE_SHU : subType;
- if (_itemDatasBySubTypeDic.ContainsKey(subType) && _itemDatasBySubTypeDic[subType].IndexOf(value) >= 0)
- {
- _itemDatasBySubTypeDic[subType].Remove(value);
- }
- int rarity = ItemCfgArray.Instance.GetCfg(value).rarity;
- if (_itemDatasByRarityDic.ContainsKey(rarity) && _itemDatasByRarityDic[rarity].IndexOf(value) >= 0)
- {
- _itemDatasByRarityDic[rarity].Remove(value);
- }
- }
- public static List<int> getItemDatasByType(int type)
- {
- List<int> arrayList = new List<int>();
- if (_itemDatasBySubTypeDic.ContainsKey(type))
- {
- arrayList.AddRange(_itemDatasBySubTypeDic[type]);
- }
- // for (int i = 0; i < _itemDatas.Count; i++)
- // {
- // int itemID = (int)_itemDatas[i];
- // int subType = ItemUtilCS.GetItemSubType(itemID);
- // if (type == (int)ConstDressUpItemType.TE_SHU && subType > type)
- // {
- // arrayList.Add(itemID);
- // }
- // else if (subType == type)
- // {
- // arrayList.Add(itemID);
- // }
- // }
- return arrayList;
- }
- public static List<int> SortItemListByHighScore(List<int> arrayList, bool checkNew = false)
- {
- arrayList.Sort((int a, int b) =>
- {
- if (checkNew)
- {
- bool isNewA = CheckIsDressUpItemNew(a);
- bool isNewB = CheckIsDressUpItemNew(b);
- if (isNewA != isNewB)
- {
- if (isNewA) return -1;
- if (isNewB) return 1;
- }
- }
- int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
- int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags);
- if (scoreB > scoreA) return 1;
- if (scoreB < scoreA) return -1;
- return a - b;
- });
- return arrayList;
- }
- public static List<int> SortItemTeaPartyByHighScore(List<int> arrayList)
- {
- arrayList.Sort((int a, int b) =>
- {
- int scoreA = ItemDataManager.GetItemAddTeaPartyTagsScore(a);
- int scoreB = ItemDataManager.GetItemAddTeaPartyTagsScore(b);
- if (scoreB > scoreA) return 1;
- if (scoreB < scoreA) return -1;
- return a - b;
- });
- return arrayList;
- }
- public static List<int> SortItemListByLowScore(List<int> arrayList, bool checkNew = false)
- {
- arrayList.Sort((int a, int b) =>
- {
- if (checkNew)
- {
- bool isNewA = CheckIsDressUpItemNew(a);
- bool isNewB = CheckIsDressUpItemNew(b);
- if (isNewA != isNewB)
- {
- if (isNewA) return -1;
- if (isNewB) return 1;
- }
- }
- int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
- int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
- if (scoreB < scoreA)
- {
- return 1;
- }
- else if (scoreB > scoreA)
- {
- return -1;
- }
- return 0;
- });
- return arrayList;
- }
- public static List<int> SortItemTeaPartyByLowsore(List<int> arrayList)
- {
- arrayList.Sort((int a, int b) =>
- {
- int scoreA = ItemDataManager.GetItemAddTeaPartyTagsScore(a);
- int scoreB = ItemDataManager.GetItemAddTeaPartyTagsScore(b);
- if (scoreB < scoreA) return 1;
- if (scoreB > scoreA) return -1;
- return a - b;
- });
- return arrayList;
- }
- private static List<int> SortItemListByScoreByType(List<int> arrayList)
- {
- arrayList.Sort((int a, int b) =>
- {
- int typeA = ItemUtilCS.GetItemSubType(a);
- int typeB = ItemUtilCS.GetItemSubType(b);
- int scoreA = ItemDataManager.GetItemAdditionScore(a, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
- int scoreB = ItemDataManager.GetItemAdditionScore(b, InstanceZonesDataManager.currentScoreType, InstanceZonesDataManager.currentFightTags); ;
- if (typeB < typeA)
- {
- return -1;
- }
- else if (typeB > typeA)
- {
- return 1;
- }
- else if (scoreB > scoreA)
- {
- return 1;
- }
- else if (scoreB < scoreA)
- {
- return -1;
- }
- return 0;
- });
- return arrayList;
- }
- public static List<int> SortItemListByHighRarity(List<int> arrayList)
- {
- arrayList.Sort((int a, int b) =>
- {
- ItemCfg itemCfgA = ItemCfgArray.Instance.GetCfg(a);
- ItemCfg itemCfgB = ItemCfgArray.Instance.GetCfg(b);
- bool isNewA = CheckIsDressUpItemNew(a);
- bool isNewB = CheckIsDressUpItemNew(b);
- if (isNewA != isNewB)
- {
- if (isNewA) return -1;
- if (isNewB) return 1;
- }
- if (itemCfgB.rarity > itemCfgA.rarity)
- {
- return 1;
- }
- else if (itemCfgB.rarity < itemCfgA.rarity)
- {
- return -1;
- }
- return 0;
- });
- return arrayList;
- }
- public static List<int> SortItemListByLowRarity(List<int> arrayList)
- {
- arrayList.Sort((int a, int b) =>
- {
- ItemCfg itemCfgA = ItemCfgArray.Instance.GetCfg(a);
- ItemCfg itemCfgB = ItemCfgArray.Instance.GetCfg(b);
- bool isNewA = CheckIsDressUpItemNew(a);
- bool isNewB = CheckIsDressUpItemNew(b);
- if (isNewA != isNewB)
- {
- if (isNewA) return -1;
- if (isNewB) return 1;
- }
- if (itemCfgB.rarity < itemCfgA.rarity)
- {
- return 1;
- }
- else if (itemCfgB.rarity > itemCfgA.rarity)
- {
- return -1;
- }
- return 0;
- });
- return arrayList;
- }
- public static List<int> GetRecommendItemList(bool toSort = true)
- {
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- List<int> recommendTypeList = new List<int>();
- List<int> recommendList = new List<int>();
- List<int> recommendSpecialList = new List<int>();
- List<int> tempAllList = _itemDatas.GetRange(0, _itemDatas.Count);
- if (toSort)
- {
- SortItemListByScoreByType(tempAllList);
- }
- foreach (int itemID in tempAllList)
- {
- int subType = ItemUtilCS.GetItemSubType(itemID);
- if (!DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID) && subType != ConstDressUpItemType.BEI_JING)
- {
- if (!recommendTypeList.Contains(subType))
- {
- bool isNeed = fightCfg.needItemId > 0 && (ItemUtilCS.GetItemSubType(fightCfg.needItemId) != subType || ItemUtilCS.GetItemSubType(fightCfg.needItemId) == subType && fightCfg.needItemId == itemID);
- if (isNeed || fightCfg.needItemId <= 0)
- {
- if (subType < ConstDressUpItemType.TE_SHU)
- {
- recommendList.Add(itemID);
- }
- recommendTypeList.Add(subType);
- }
- }
- }
- }
- recommendSpecialList = DressUpMenuItemDataManager.getItemDatasByType(ConstDressUpItemType.TE_SHU);
- recommendSpecialList = DressUpMenuItemDataManager.SortItemListByHighScore(recommendSpecialList);
- List<int> specialSubList = new List<int>();
- List<int> specialIdList = new List<int>();
- foreach (int itemID in recommendSpecialList)
- {
- int subType = ItemUtilCS.GetItemSubType(itemID);
- if (subType > ConstDressUpItemType.TE_SHU)
- {
- if (specialSubList.Count >= 3) continue;
- if (specialSubList.IndexOf(subType) < 0)
- {
- specialSubList.Add(subType);
- specialIdList.Add(itemID);
- }
- }
- }
- recommendList.AddRange(specialIdList);
- return recommendList;
- }
- // public static int GetRecommendCount()
- // {
- // List<int> recommendTypeList = GetRecommendItemList(false);
- // return recommendTypeList.Count;
- // }
- // public static int GetItemScore(int itemId)
- // {
- // return ItemDataManager.GetItemAdditionScore(itemId, InstanceZonesDataManager.currentScoreType);
- // }
- public static List<int> DressSearch(bool includeScene = true)
- {
- List<int> searchList = new List<int>();
- for (int i = 0; i < _itemDatas.Count; i++)
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemDatas[i]);
- if (!includeScene && DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(_itemDatas[i])) continue;
- if (itemCfg.name.IndexOf(dressSearchTxt) >= 0 && searchList.IndexOf(itemCfg.id) < 0)
- {
- searchList.Add(itemCfg.id);
- }
- }
- return searchList;
- }
- public static List<int> DressFilter(bool includeScene = true)
- {
- List<int> filterList = new List<int>();
- for (int i = 0; i < _itemDatas.Count; i++)
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemDatas[i]);
- if (!includeScene && DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(_itemDatas[i])) continue;
- bool isTag = selectTagList.Count == 0;
- if (selectTagList.Count > 0)
- {
- for (int j = 0; j < itemCfg.tagsArr.Length; j++)
- {
- if (selectTagList.IndexOf(itemCfg.tagsArr[j][0]) >= 0)
- {
- isTag = true;
- break;
- }
- }
- }
- if (!isTag) continue;
- if (selectRarityList.Count > 0 && selectRarityList.IndexOf(itemCfg.rarity) < 0) continue;
- if (selectScoreList.Count > 0 && selectScoreList.IndexOf(itemCfg.mainScore) < 0) continue;
- filterList.Add(itemCfg.id);
- }
- return filterList;
- }
- public static List<int> DressSearch(List<int> list)
- {
- List<int> searchList = new List<int>();
- for (int i = 0; i < list.Count; i++)
- {
- bool isSearch = true;
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(list[i]);
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(list[i]);
- string name = itemCfg != null ? itemCfg.name : suitCfg.name;
- for (int j = 0; j < dressSearchTxt.Length; j++)
- {
- if (name.IndexOf(dressSearchTxt[j]) < 0)
- {
- isSearch = false;
- break;
- }
- }
- if (isSearch)
- {
- searchList.Add(list[i]);
- }
- }
- return searchList;
- }
- public static List<int> DressFilter(List<int> list)
- {
- List<int> filterList = new List<int>();
- for (int i = 0; i < list.Count; i++)
- {
- ItemCfg cfg = ItemCfgArray.Instance.GetCfg(list[i]);
- SuitCfg tzCfg = SuitCfgArray.Instance.GetCfg(list[i]);
- bool isRarity = cfg == null ? FilterRarity(tzCfg) : FilterRarity(cfg);
- bool isScore = cfg == null ? true : FilterScore(cfg);
- bool isTag = cfg == null ? true : FilterTag(cfg);
- if (isRarity && isScore && isTag)
- {
- filterList.Add(list[i]);
- }
- }
- if (filterList.Count == 0)
- {
- PromptController.Instance.ShowFloatTextPrompt("无满足条件物品");
- }
- return filterList;
- }
- private static bool FilterRarity(ItemCfg cfg)
- {
- bool isRarity = false;
- if (selectRarityList.Count > 0)
- {
- for (int j = 0; j < selectRarityList.Count; j++)
- {
- if (cfg != null && cfg.rarity == selectRarityList[j])
- {
- isRarity = true;
- break;
- }
- }
- }
- else
- {
- isRarity = true;
- }
- return isRarity;
- }
- private static bool FilterRarity(SuitCfg cfg)
- {
- bool isRarity = false;
- if (selectRarityList.Count > 0)
- {
- for (int j = 0; j < selectRarityList.Count; j++)
- {
- if (cfg != null && cfg.rarity == selectRarityList[j])
- {
- isRarity = true;
- break;
- }
- }
- }
- else
- {
- isRarity = true;
- }
- return isRarity;
- }
- private static bool FilterScore(ItemCfg cfg)
- {
- bool isScore = false;
- if (selectScoreList.Count > 0)
- {
- if (cfg != null)
- {
- for (int j = 0; j < selectScoreList.Count; j++)
- {
- if (cfg.mainScore == selectScoreList[j])
- {
- isScore = true;
- break;
- }
- }
- }
- }
- else
- {
- isScore = true;
- }
- return isScore;
- }
- private static bool FilterTag(ItemCfg cfg)
- {
- bool isTag = false;
- if (selectTagList.Count > 0)
- {
- if (cfg != null)
- {
- for (int j = 0; j < selectTagList.Count; j++)
- {
- if (isTag == true)
- {
- break;
- }
- for (int k = 0; k < cfg.tagsArr.Length; k++)
- {
- if (cfg.tagsArr[k][0] == selectTagList[j])
- {
- isTag = true;
- break;
- }
- }
- }
- }
- }
- else
- {
- isTag = true;
- }
- return isTag;
- }
- public static void AddNewDressItem(int value)
- {
- int subType = ItemDataManager.GetItemSubType(value);
- if (!_newItemdata.ContainsKey(subType))
- {
- _newItemdata.Add(subType, new List<int>());
- }
- _newItemdata[subType].Add(value);
- // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(value);
- // if (itemCfg.suitId > 0 && DressUpMenuSuitDataManager.CheckHaveSuit(itemCfg.suitId))
- // {
- // SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(itemCfg.suitId);
- // }
- }
- public static void RemoveNewDressItem(int itemId)
- {
- int subType = ItemCfgArray.Instance.GetCfg(itemId).subType;
- if (_newItemdata.ContainsKey(subType) && _newItemdata[subType].IndexOf(itemId) >= 0)
- {
- _newItemdata[subType].Remove(itemId);
- }
- }
- //检测一级菜单是否有展示新增
- public static bool CheckIsFirstMenuNew(int menuId)
- {
- if (_newItemdata.Count == 0) return false;
- DressUpMenuItemCfg1 cfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuId);
- if (cfg1.subMenusArr.Length > 0)//有二级菜单
- {
- foreach (int id2 in cfg1.subMenusArr)
- {
- if (CheckIsSecondMenuNew(id2)) return true;
- }
- }
- else
- {
- if (_newItemdata.ContainsKey(cfg1.type) && _newItemdata[cfg1.type].Count > 0) return true;
- }
- return false;
- }
- //检测二级菜单是否有展示新增
- public static bool CheckIsSecondMenuNew(int subMenuId)
- {
- if (_newItemdata.Count == 0) return false;
- DressUpMenuItemCfg2 cfg2 = DressUpMenuItemCfg2Array.Instance.GetCfg(subMenuId);
- if (_newItemdata.ContainsKey(cfg2.type) && _newItemdata[cfg2.type].Count > 0)
- {
- return true;
- }
- return false;
- }
- //检测服装部件是否为新增
- public static bool CheckIsDressUpItemNew(int itemId)
- {
- if (_newItemdata.Count == 0) return false;
- int subType = ItemUtilCS.GetItemSubType(itemId);
- return _newItemdata.ContainsKey(subType) && _newItemdata[subType].IndexOf(itemId) >= 0;
- }
- //预加载服装配置
- public static void StartPreLoadItemCfg()
- {
- Timers.inst.AddUpdate(updateOnPreLoad);
- }
- private static void updateOnPreLoad(object param = null)
- {
- for(var i = 0; i < 3; i++)
- {
- PreLoadOneItemCfg();
- }
- if (itemIDListInited.Count <= 0)
- {
- Timers.inst.Remove(updateOnPreLoad);
- }
- }
- private static void PreLoadOneItemCfg()
- {
- var itemIDListInited = DressUpMenuItemDataManager.itemIDListInited;
- if (itemIDListInited.Count > 0)
- {
- int lasetIndex = itemIDListInited.Count - 1;
- int itemId = itemIDListInited[lasetIndex];
- itemIDListInited.RemoveAt(lasetIndex);
- ItemCfgArray.Instance.GetCfg(itemId);
- }
- }
- public static int[] dressUpGuideSubType = {
- ConstDressUpItemType.FA_XING, ConstDressUpItemType.LIAN_YI_QUN , ConstDressUpItemType.NEI_DA,
- ConstDressUpItemType.WAI_TAO,ConstDressUpItemType.SHANG_YI,ConstDressUpItemType.XIA_ZHUANG,ConstDressUpItemType.WA_ZI,
- ConstDressUpItemType.XIE_ZI,ConstDressUpItemType.SHOU_CHI_WU, ConstDressUpItemType.ZHUANG_RONG};
- public static int[] dressUpGuideAccessoriesType = {
- ConstDressUpItemType.TOU_SHI, ConstDressUpItemType.ER_SHI , ConstDressUpItemType.JING_SHI,
- ConstDressUpItemType.MIAN_BU,ConstDressUpItemType.YAO_SHI,ConstDressUpItemType.SHOU_SHI,ConstDressUpItemType.PI_BO};
-
- /// <summary>
- /// 根据主属性获取有序服装散件ID列表(排序规则: 已获得按稀有度从高到低 > 未获得按稀有度从高到低 > 名字拼音)
- /// 包含已获得和未获得
- /// </summary>
- /// <param name="subType">0-全部</param>
- /// <param name="sorted">true-有序</param>
- /// <returns></returns>
- public static List<int> GetAllDressUpGuideIdListBySubType(int subType, bool sorted = true)
- {
- List<int> result = new List<int>();
- List<ItemCfg> itemCfgs = new List<ItemCfg>();
-
- // 全部
- if (subType == 0)
- {
- // 除饰品外的散件
- for (int i = 0; i < dressUpGuideSubType.Length; i++)
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, dressUpGuideSubType[i]));
- }
- // 饰品
- for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, dressUpGuideAccessoriesType[i]));
- }
- // 特殊
- ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
- for (int i = 0; i < itemTypeCfg.Length; i++)
- {
- if (itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, itemTypeCfg[i].type));
- }
- }
- }
- // 指定子类型
- else
- {
- if(subType == ConstDressUpItemType.TE_SHU)
- {
- ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
- for(int i = 0;i< itemTypeCfg.Length; i++)
- {
- if(itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, itemTypeCfg[i].type));
- }
- }
- }
- else
- {
- itemCfgs = ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, subType);
- }
- }
- if (sorted)
- {
- itemCfgs.Sort((a, b) =>
- {
- bool haveA = CheckHasItem(a.id);
- bool haveB = CheckHasItem(b.id);
- if (haveB && !haveA)
- {
- return 1;
- }
- else if (!haveB && haveA)
- {
- return -1;
- }
- if (a.rarity != b.rarity)
- {
- return a.rarity > b.rarity ? -1 : 1;
- }
- return a.res.CompareTo(b.res);
- });
- }
-
- for (int i = 0; i < itemCfgs.Count; i++)
- {
- if(CanShow(itemCfgs[i]))
- {
- result.Add(itemCfgs[i].id);
- }
- }
- return result;
- }
- // 默认的不显示
- public static List<int> defaultID = new List<int> { 10000, 20000, 30000, 50000, 60000 };
- private static bool CanShow(ItemCfg item)
- {
- if (defaultID.Contains(item.id))
- {
- return false;
- }
- return item.isHide <= 0;
- }
- public static List<int> GetAllDressUpGuideIdListBySubTypes(List<int> subTypes)
- {
- List<int> result = new List<int>();
- List<ItemCfg> itemCfgs = new List<ItemCfg>();
- for (int j = 0; j < subTypes.Count; j++)
- {
- int subType = subTypes[j];
- if (subType == ConstDressUpItemType.TE_SHU)
- {
- ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
- for (int i = 0; i < itemTypeCfg.Length; i++)
- {
- if (itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, itemTypeCfg[i].type));
- }
- }
- }
- else
- {
- itemCfgs.AddRange(ItemCfgArray.Instance.GetCfgsByitemTypeAndsubType(ConstItemType.DRESS_UP, subType));
- }
- }
- itemCfgs.Sort((a, b) =>
- {
- bool haveA = CheckHasItem(a.id);
- bool haveB = CheckHasItem(b.id);
- if (haveB && !haveA)
- {
- return 1;
- }
- else if (!haveB && haveA)
- {
- return -1;
- }
- if (a.rarity != b.rarity)
- {
- return a.rarity > b.rarity ? -1 : 1;
- }
- return a.res.CompareTo(b.res);
- });
- for (int i = 0; i < itemCfgs.Count; i++)
- {
- if (CanShow(itemCfgs[i]))
- {
- result.Add(itemCfgs[i].id);
- }
- }
- return result;
- }
- public static bool isLoading = false;
- public static async Task GetAllDressUpGuideIdListBySubTypeAsync()
- {
- isLoading = true;
- // 除饰品外的散件
- for (int i = 0; i < dressUpGuideSubType.Length; i++)
- {
- await ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, dressUpGuideSubType[i]);
- }
- // 饰品
- for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
- {
- await ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, dressUpGuideAccessoriesType[i]);
- }
- // 特殊
- ItemTypeCfg[] itemTypeCfg = ItemTypeCfgArray.Instance.dataArray;
- for (int i = 0; i < itemTypeCfg.Length; i++)
- {
- if (itemTypeCfg[i].type > ConstDressUpItemType.TE_SHU)
- {
- await ItemCfgArray.Instance.GetCfgsByitemTypeAndsubTypeAsync(ConstItemType.DRESS_UP, itemTypeCfg[i].type);
- }
- }
- isLoading = false;
- EventAgent.DispatchEvent(ConstMessage.DRESS_PART_LOAD_FINISHED);
- }
- public static void SortDressUpGuideIdList(List<int> list)
- {
- list.Sort((a, b) =>
- {
- ItemCfg itemA = ItemCfgArray.Instance.GetCfg(a);
- ItemCfg itemB = ItemCfgArray.Instance.GetCfg(b);
- bool haveA = CheckHasItem(itemA.id);
- bool haveB = CheckHasItem(itemB.id);
- if (haveB && !haveA)
- {
- return 1;
- }
- else if (!haveB && haveA)
- {
- return -1;
- }
- if (itemA.rarity != itemB.rarity)
- {
- return itemA.rarity > itemB.rarity ? -1 : 1;
- }
- return itemA.res.CompareTo(itemB.res);
- });
- }
- public static void GetTotalProgress(out int haveCount, out int totalCount)
- {
- totalCount = GlobalCfgArray.globalCfg.ClothingPartsCount;
- haveCount = 0;
- // 除饰品外的散件
- for (int i = 0; i < dressUpGuideSubType.Length; i++)
- {
- if (_itemDatasBySubTypeDic.ContainsKey(dressUpGuideSubType[i]))
- {
- haveCount += _itemDatasBySubTypeDic[dressUpGuideSubType[i]].Count;
- }
- }
- // 饰品
- for (int i = 0; i < dressUpGuideAccessoriesType.Length; i++)
- {
- if (_itemDatasBySubTypeDic.ContainsKey(dressUpGuideAccessoriesType[i]))
- {
- haveCount += _itemDatasBySubTypeDic[dressUpGuideAccessoriesType[i]].Count;
- }
- }
- // 特殊
- if (_itemDatasBySubTypeDic.ContainsKey(ConstDressUpItemType.TE_SHU))
- {
- haveCount += _itemDatasBySubTypeDic[ConstDressUpItemType.TE_SHU].Count;
- }
- }
- }
- }
|