|
@@ -4,21 +4,64 @@ 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))
|
|
|
+ ShopCfg[] shopCfgs = null;
|
|
|
+ switch (storeId)
|
|
|
{
|
|
|
- list = _dataDic[storeId][typeIndex];
|
|
|
- SortItemListByScore(list, scoreType);
|
|
|
+ case ConstStoreId.CLOTHING_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgClothingArray.Instance.GetCfgs(typeIndex);
|
|
|
+ break;
|
|
|
+ case ConstStoreId.LUCKY_BOX_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgCJArray.Instance.GetCfgs(typeIndex);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgCJAArray.Instance.GetCfgs(typeIndex);
|
|
|
+ break;
|
|
|
}
|
|
|
+ List<ShopCfg> list = new List<ShopCfg>(shopCfgs);
|
|
|
+ SortItemListByScore(list, scoreType);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private List<ShopCfg> ShopCfgs(int storeId)
|
|
|
+ {
|
|
|
+ ShopCfg[] shopCfgs = null;
|
|
|
+ switch (storeId)
|
|
|
+ {
|
|
|
+ case ConstStoreId.CLOTHING_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgClothingArray.Instance.dataArray;
|
|
|
+ break;
|
|
|
+ case ConstStoreId.LUCKY_BOX_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgCJArray.Instance.dataArray;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
|
|
|
+ shopCfgs = ShopCfgCJAArray.Instance.dataArray;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return new List<ShopCfg>(shopCfgs);
|
|
|
+ }
|
|
|
+ public ShopCfg GetShopCfg(int buyId, int shopType)
|
|
|
+ {
|
|
|
+ switch (shopType)
|
|
|
+ {
|
|
|
+ case ConstStoreId.CLOTHING_STORE_ID:
|
|
|
+ return ShopCfgClothingArray.Instance.GetCfg(buyId);
|
|
|
+
|
|
|
+ case ConstStoreId.LUCKY_BOX_STORE_ID:
|
|
|
+
|
|
|
+ return ShopCfgCJArray.Instance.GetCfg(buyId);
|
|
|
+ case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
|
|
|
+ return ShopCfgCJAArray.Instance.GetCfg(buyId);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
|
|
|
{
|
|
|
arrayList.Sort((ShopCfg a, ShopCfg b) =>
|
|
@@ -52,54 +95,5 @@ namespace GFGGame
|
|
|
});
|
|
|
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);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|