ClothingShopCfgManager.cs 3.7 KB

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