ClothingShopCfgManager.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
  57. {
  58. arrayList.Sort((ShopCfg a, ShopCfg b) =>
  59. {
  60. int numA = ItemDataManager.GetItemNum(a.itemID);
  61. int numB = ItemDataManager.GetItemNum(b.itemID);
  62. bool hasA = numA > 0;
  63. bool hasB = numB > 0;
  64. if (hasA && !hasB)
  65. {
  66. return 1;
  67. }
  68. else if (!hasA && hasB)
  69. {
  70. return -1;
  71. }
  72. else if (scoreType > 0 && !hasA && !hasB)
  73. {
  74. int scoreA = DressUpMenuItemDataManager.GetItemScore(a.itemID, scoreType);
  75. int scoreB = DressUpMenuItemDataManager.GetItemScore(b.itemID, scoreType);
  76. if (scoreB > scoreA)
  77. {
  78. return 1;
  79. }
  80. else if (scoreB < scoreA)
  81. {
  82. return -1;
  83. }
  84. }
  85. return 0;
  86. });
  87. return arrayList;
  88. }
  89. }
  90. }