ClothingShopCfgManager.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. public ShopCfg GetShopCfg(int buyId, int shopType)
  27. {
  28. switch (shopType)
  29. {
  30. case ConstStoreId.CLOTHING_STORE_ID:
  31. return ShopCfgClothingArray.Instance.GetCfg(buyId);
  32. case ConstStoreId.LUCKY_BOX_STORE_ID:
  33. return ShopCfgCJArray.Instance.GetCfg(buyId);
  34. case ConstStoreId.LUCKY_BOX_ACTIVITY_STORE_ID:
  35. return ShopCfgCJAArray.Instance.GetCfg(buyId);
  36. }
  37. return null;
  38. }
  39. public void GetMoneyIdAndNum(int buyId, int count, int shopType, out int costId, out int costNum, out int buyNum)
  40. {
  41. ShopCfg shopCfg = GetShopCfg(buyId, shopType);
  42. costId = shopCfg.costID;
  43. costNum = shopCfg.costNum * count;
  44. buyNum = count;
  45. }
  46. private List<ShopCfg> SortItemListByScore(List<ShopCfg> arrayList, int scoreType)
  47. {
  48. arrayList.Sort((ShopCfg a, ShopCfg b) =>
  49. {
  50. int numA = ItemDataManager.GetItemNum(a.itemID);
  51. int numB = ItemDataManager.GetItemNum(b.itemID);
  52. bool hasA = numA > 0;
  53. bool hasB = numB > 0;
  54. if (hasA && !hasB)
  55. {
  56. return 1;
  57. }
  58. else if (!hasA && hasB)
  59. {
  60. return -1;
  61. }
  62. else if (scoreType > 0 && !hasA && !hasB)
  63. {
  64. int scoreA = DressUpMenuItemDataManager.GetItemScore(a.itemID, scoreType);
  65. int scoreB = DressUpMenuItemDataManager.GetItemScore(b.itemID, scoreType);
  66. if (scoreB > scoreA)
  67. {
  68. return 1;
  69. }
  70. else if (scoreB < scoreA)
  71. {
  72. return -1;
  73. }
  74. }
  75. return 0;
  76. });
  77. return arrayList;
  78. }
  79. }
  80. }