ClothingShopCfgManager.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Collections.Generic;
  2. namespace GFGGame
  3. {
  4. public class ClothingShopCfgManager : SingletonBase<ClothingShopCfgManager>
  5. {
  6. private Dictionary<int, Dictionary<int, List<ShopCfg>>> _dataDic = new Dictionary<int, Dictionary<int, List<ShopCfg>>>();
  7. public List<ShopCfg> GetList(int storeId, int typeIndex, int scoreType)
  8. {
  9. List<ShopCfg> shopCfgs = null;
  10. switch (storeId)
  11. {
  12. case ConstStoreId.CLOTHING_STORE_ID:
  13. shopCfgs = ShopCfgClothingArray.Instance.GetCfgs(typeIndex);
  14. break;
  15. case ConstStoreId.LUCKY_BOX_STORE_ID:
  16. shopCfgs = ShopCfgCJArray.Instance.GetCfgs(typeIndex);
  17. break;
  18. case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
  19. shopCfgs = ShopCfgCJAArray.Instance.GetCfgs(typeIndex);
  20. break;
  21. }
  22. SortItemListByScore(shopCfgs, scoreType);
  23. return shopCfgs;
  24. }
  25. public ShopCfg GetShopCfg(int buyId, int shopType)
  26. {
  27. switch (shopType)
  28. {
  29. case ConstStoreId.CLOTHING_STORE_ID:
  30. return ShopCfgClothingArray.Instance.GetCfg(buyId);
  31. case ConstStoreId.LUCKY_BOX_STORE_ID:
  32. return ShopCfgCJArray.Instance.GetCfg(buyId);
  33. case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
  34. return ShopCfgCJAArray.Instance.GetCfg(buyId);
  35. }
  36. return null;
  37. }
  38. public void GetMoneyIdAndNum(int buyId, int count, int shopType, out int costId, out int costNum, out int buyNum)
  39. {
  40. ShopCfg shopCfg = GetShopCfg(buyId, shopType);
  41. costId = shopCfg.costID;
  42. costNum = shopCfg.costNum * count;
  43. buyNum = count;
  44. }
  45. private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
  46. {
  47. arrayList.Sort((ShopCfg a, ShopCfg b) =>
  48. {
  49. int numA = ItemDataManager.GetItemNum(a.itemID);
  50. int numB = ItemDataManager.GetItemNum(b.itemID);
  51. bool hasA = numA > 0;
  52. bool hasB = numB > 0;
  53. if (hasA && !hasB)
  54. {
  55. return 1;
  56. }
  57. else if (!hasA && hasB)
  58. {
  59. return -1;
  60. }
  61. else if (scoreType > 0 && !hasA && !hasB)
  62. {
  63. int scoreA = DressUpMenuItemDataManager.GetItemScore(a.itemID, scoreType);
  64. int scoreB = DressUpMenuItemDataManager.GetItemScore(b.itemID, scoreType);
  65. if (scoreB > scoreA)
  66. {
  67. return 1;
  68. }
  69. else if (scoreB < scoreA)
  70. {
  71. return -1;
  72. }
  73. }
  74. return 0;
  75. });
  76. return arrayList;
  77. }
  78. }
  79. }