LuckyBoxBonusDataCache.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. namespace GFGGame
  5. {
  6. public class LuckyBoxBonusDataCache
  7. {
  8. private static int _currentBoxId;
  9. private static int _currentSelectId;
  10. public static int currentBoxId
  11. {
  12. get
  13. {
  14. return _currentBoxId;
  15. }
  16. set
  17. {
  18. if (_currentBoxId != value)
  19. {
  20. _currentBoxId = value;
  21. InitData(_currentBoxId);
  22. }
  23. }
  24. }
  25. public static string probShow;
  26. private static List<LuckyBoxBonusData> _showList;
  27. // private static int _dropOutId;
  28. // private static int _dropId;
  29. public static int GetOwnedCount()
  30. {
  31. int count = 0;
  32. foreach (LuckyBoxBonusData luckyBoxBonusData in _showList)
  33. {
  34. foreach (ItemData itemData in luckyBoxBonusData.itemList)
  35. {
  36. if (ItemDataManager.GetItemNum(itemData.id) > 0)
  37. {
  38. count++;
  39. }
  40. }
  41. }
  42. return count;
  43. }
  44. public static List<LuckyBoxBonusData> GetCurrentShowList()
  45. {
  46. return _showList.GetRange(0, _showList.Count);
  47. }
  48. // public static List<ItemData> GetBonusList(int count, bool isGuide = false)
  49. // {
  50. // List<ItemData> bonusList = null;
  51. // if (isGuide)
  52. // {
  53. // int[][] temp = new int[5][];
  54. // temp[0] = new int[] { 10332, 1 };
  55. // temp[1] = new int[] { 10334, 1 };
  56. // temp[2] = new int[] { 10335, 1 };
  57. // temp[3] = new int[] { 10336, 1 };
  58. // temp[4] = new int[] { 10338, 1 };
  59. // List<ItemData> guideBonusList = ItemUtil.CreateItemDataList(temp);
  60. // count = count - guideBonusList.Count;
  61. // bonusList = DropOutDataCache.GetDropItemDatas(_dropOutId, count);
  62. // while (guideBonusList.Count > 1)
  63. // {
  64. // ItemData itemData = guideBonusList[0];
  65. // guideBonusList.RemoveAt(0);
  66. // int index = UnityEngine.Random.Range(0, bonusList.Count);
  67. // bonusList.Insert(index, itemData);
  68. // }
  69. // bonusList.Add(guideBonusList[0]);
  70. // }
  71. // else
  72. // {
  73. // bonusList = DropOutDataCache.GetDropItemDatas(_dropOutId, count);
  74. // }
  75. // int dicIndex = 0;
  76. // LuckyBoxDataManager.Instance.FirstRewardList.Clear();
  77. // foreach (ItemData itemData in bonusList)
  78. // {
  79. // if (ItemDataManager.GetItemNum(itemData.id) == 0)
  80. // {
  81. // LuckyBoxDataManager.Instance.FirstRewardList.Add(dicIndex, itemData);
  82. // }
  83. // ItemDataManager.Add(itemData.id, itemData.num);
  84. // dicIndex++;
  85. // }
  86. // ItemDataManager.Add(_dropId, count);
  87. // //100¸öÐÇм»»1¸öÂäÐÇʯ
  88. // LuckyBoxCfg boxCfg0 = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxIds[0]);
  89. // LuckyBoxCfg boxCfg1 = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxIds[1]);
  90. // int itemCount = ItemDataManager.GetItemNum(boxCfg0.drop);
  91. // if (_dropId == boxCfg0.drop && itemCount >= 100)
  92. // {
  93. // ItemDataManager.Add(boxCfg1.drop, itemCount / 100);
  94. // ItemDataManager.Remove(_dropId, itemCount / 100 * 100);
  95. // }
  96. // GetSuitItemController.TryShow(0);
  97. // return bonusList;
  98. // }
  99. private static void InitData(int boxId)
  100. {
  101. LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
  102. probShow = luckyBoxCfg.probShow;
  103. _showList = GetBonusDataList(luckyBoxCfg.bonusShowArr);
  104. // _dropOutId = luckyBoxCfg.bonus;
  105. // _dropId = luckyBoxCfg.drop;
  106. }
  107. private static List<LuckyBoxBonusData> GetBonusDataList(int[] idsList)
  108. {
  109. List<LuckyBoxBonusData> list = new List<LuckyBoxBonusData>();
  110. foreach (int id in idsList)
  111. {
  112. BonusListCfg bonusListCfg = BonusListCfgArray.Instance.GetCfg(id);
  113. LuckyBoxBonusData luckyBoxBonusData = new LuckyBoxBonusData();
  114. luckyBoxBonusData.id = id;
  115. luckyBoxBonusData.name = bonusListCfg.name;
  116. luckyBoxBonusData.itemList = ItemUtil.CreateItemDataList(bonusListCfg.bonusListArr);
  117. list.Add(luckyBoxBonusData);
  118. }
  119. return list;
  120. }
  121. }
  122. }