123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class ClothingShopCfgManager : SingletonBase<ClothingShopCfgManager>
- {
- 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)
- {
- ShopCfg[] shopCfgs = null;
- switch (storeId)
- {
- 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) =>
- {
- 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;
- }
- }
- }
|