123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class ClothingShopCfgManager : SingletonBase<ClothingShopCfgManager>
- {
- private bool _inited;
- private Dictionary<int, Dictionary<int, List<ShopCfg>>> _dataDic = new Dictionary<int, Dictionary<int, List<ShopCfg>>>();
- public List<ShopCfg> GetList(int storeId, int typeIndex, int scoreType)
- {
- List<ShopCfg> list = new List<ShopCfg>();
- InitData();
- if (_dataDic.ContainsKey(storeId) && _dataDic[storeId].ContainsKey(typeIndex))
- {
- list = _dataDic[storeId][typeIndex];
- SortItemListByScore(list, scoreType);
- }
- return list;
- }
- private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
- {
- arrayList.Sort((ShopCfg a, ShopCfg 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;
- ShopCfg[] clotiongDataArray = ShopCfgClothingArray.Instance.dataArray;
- foreach (ShopCfg cfg in clotiongDataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.CLOTHING_STORE_ID)==false){
- _dataDic[ConstStoreId.CLOTHING_STORE_ID] = new Dictionary<int, List<ShopCfg>>();
- }
- if (_dataDic[ConstStoreId.CLOTHING_STORE_ID].ContainsKey(cfg.typeIndex)==false)
- {
- _dataDic[ConstStoreId.CLOTHING_STORE_ID][cfg.typeIndex] = new List<ShopCfg>();
- }
- _dataDic[ConstStoreId.CLOTHING_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- ShopCfg[] clothingCJDataArray = ShopCfgCJArray.Instance.dataArray;
- foreach (ShopCfg cfg in clothingCJDataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.LUCKY_BOX_STORE_ID) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID] = new Dictionary<int, List<ShopCfg>>();
- }
- if (_dataDic[ConstStoreId.LUCKY_BOX_STORE_ID].ContainsKey(cfg.typeIndex) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID][cfg.typeIndex] = new List<ShopCfg>();
- }
- _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- ShopCfg[] clothingCJADataArray = ShopCfgCJArray.Instance.dataArray;
- foreach (ShopCfg cfg in clothingCJADataArray)
- {
- if (_dataDic.ContainsKey(ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID] = new Dictionary<int, List<ShopCfg>>();
- }
- if (_dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID].ContainsKey(cfg.typeIndex) == false)
- {
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex] = new List<ShopCfg>();
- }
- _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex].Add(cfg);
- }
- }
- }
- }
|