123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class ClothingShopCfgManager : SingletonBase<ClothingShopCfgManager>
- {
- private bool _inited;
- private Dictionary<int, Dictionary<int, List<ClothingShopCfg>>> _dataDic = new Dictionary<int, Dictionary<int, List<ClothingShopCfg>>>();
- public List<ClothingShopCfg> GetList(int storeId, int typeIndex, int scoreType)
- {
- List<ClothingShopCfg> list = new List<ClothingShopCfg>();
- InitData();
- if (_dataDic.ContainsKey(storeId) && _dataDic[storeId].ContainsKey(typeIndex))
- {
- list = _dataDic[storeId][typeIndex];
- SortItemListByScore(list, scoreType);
- }
- return list;
- }
- private List<ClothingShopCfg> SortItemListByScore(List<ClothingShopCfg> arrayList, int scoreType)
- {
- arrayList.Sort((ClothingShopCfg a, ClothingShopCfg b) =>
- {
- int numA = ItemDataManager.GetItemNum(a.itemID);
- int numB = ItemDataManager.GetItemNum(b.itemID);
- bool hasA = numA > 0;
- bool hasB = numB > 0;
- if (hasA && !hasB)
- {
- return 1;
- }
- else if (!hasA && hasB)
- {
- return -1;
- }
- else if (scoreType > 0 && !hasA && !hasB)
- {
- int scoreA = DressUpMenuItemDataManager.GetItemScore(a.itemID, scoreType);
- int scoreB = DressUpMenuItemDataManager.GetItemScore(b.itemID, scoreType);
- if (scoreB > scoreA)
- {
- return 1;
- }
- else if (scoreB < scoreA)
- {
- return -1;
- }
- }
- return 0;
- });
- return arrayList;
- }
- private void InitData()
- {
- if (_inited)
- {
- return;
- }
- _inited = true;
- ClothingShopCfg[] clotiongDataArray = ClothingShopCfgArray.Instance.dataArray;
- foreach (ClothingShopCfg cfg in clotiongDataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.CLOTHING_STORE_ID)==false){
- _dataDic[ConstStoreId.CLOTHING_STORE_ID] = new Dictionary<int, List<ClothingShopCfg>>();
- }
- if (_dataDic[ConstStoreId.CLOTHING_STORE_ID].ContainsKey(cfg.typeIndex)==false)
- {
- _dataDic[ConstStoreId.CLOTHING_STORE_ID][cfg.typeIndex] = new List<ClothingShopCfg>();
- }
- _dataDic[ConstStoreId.CLOTHING_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- ClothingShopCfg[] clothingCJDataArray = ClothingShopCfgCJArray.Instance.dataArray;
- foreach (ClothingShopCfg cfg in clothingCJDataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.LUCKY_BOX_STORE_ID) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID] = new Dictionary<int, List<ClothingShopCfg>>();
- }
- if (_dataDic[ConstStoreId.LUCKY_BOX_STORE_ID].ContainsKey(cfg.typeIndex) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID][cfg.typeIndex] = new List<ClothingShopCfg>();
- }
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- ClothingShopCfg[] clothingCJADataArray = ClothingShopCfgCJArray.Instance.dataArray;
- foreach (ClothingShopCfg cfg in clothingCJADataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID] = new Dictionary<int, List<ClothingShopCfg>>();
- }
- if (_dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID].ContainsKey(cfg.typeIndex) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex] = new List<ClothingShopCfg>();
- }
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- }
- }
- }
|