ClothingShopCfgManager.cs 4.0 KB

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