ClothingShopCfgManager.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ShopCfg[] GetShopCfgs(int shopType)
  39. {
  40. switch (shopType)
  41. {
  42. case ConstStoreId.CLOTHING_STORE_ID:
  43. return ShopCfgClothingArray.Instance.dataArray;
  44. case ConstStoreId.LUCKY_BOX_STORE_ID:
  45. return ShopCfgCJArray.Instance.dataArray;
  46. case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
  47. return ShopCfgCJAArray.Instance.dataArray;
  48. }
  49. return null;
  50. }
  51. public void GetMoneyIdAndNum(int buyId, int count, int shopType, out int costId, out int costNum, out int buyNum)
  52. {
  53. ShopCfg shopCfg = GetShopCfg(buyId, shopType);
  54. costId = shopCfg.costID;
  55. costNum = shopCfg.costNum * count;
  56. buyNum = count;
  57. }
  58. private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
  59. {
  60. arrayList.Sort((ShopCfg a, ShopCfg b) =>
  61. {
  62. int numA = ItemDataManager.GetItemNum(a.itemID);
  63. int numB = ItemDataManager.GetItemNum(b.itemID);
  64. bool hasA = numA > 0;
  65. bool hasB = numB > 0;
  66. if (hasA && !hasB)
  67. {
  68. return 1;
  69. }
  70. else if (!hasA && hasB)
  71. {
  72. return -1;
  73. }
  74. else if (scoreType > 0 && !hasA && !hasB)
  75. {
  76. int scoreA = DressUpMenuItemDataManager.GetItemScore(a.itemID, scoreType);
  77. int scoreB = DressUpMenuItemDataManager.GetItemScore(b.itemID, scoreType);
  78. if (scoreB > scoreA)
  79. {
  80. return 1;
  81. }
  82. else if (scoreB < scoreA)
  83. {
  84. return -1;
  85. }
  86. }
  87. return a.itemID.CompareTo(b.itemID);
  88. });
  89. return arrayList;
  90. }
  91. }
  92. }