ClothingShopCfgManager.cs 3.9 KB

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