using System.Collections.Generic; namespace GFGGame { public class ClothingShopCfgManager : SingletonBase { private bool _inited; private Dictionary>> _dataDic = new Dictionary>>(); public List GetList(int storeId, int typeIndex, int scoreType) { List list = new List(); InitData(); if (_dataDic.ContainsKey(storeId) && _dataDic[storeId].ContainsKey(typeIndex)) { list = _dataDic[storeId][typeIndex]; SortItemListByScore(list, scoreType); } return list; } private List SortItemListByScore(List 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>(); } if (_dataDic[ConstStoreId.CLOTHING_STORE_ID].ContainsKey(cfg.typeIndex)==false) { _dataDic[ConstStoreId.CLOTHING_STORE_ID][cfg.typeIndex] = new List(); } _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>(); } if (_dataDic[ConstStoreId.LUCKY_BOX_STORE_ID].ContainsKey(cfg.typeIndex) == false) { _dataDic[ConstStoreId.LUCKY_BOX_STORE_ID][cfg.typeIndex] = new List(); } _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>(); } if (_dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID].ContainsKey(cfg.typeIndex) == false) { _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex] = new List(); } _dataDic[ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID][cfg.typeIndex].Add(cfg); } } } }