12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class DecomposeDataManager : SingletonBase<DecomposeDataManager>
- {
- Dictionary<int, List<int>> _decomposeData = new Dictionary<int, List<int>>();//所有数量大于1的换装部件数据
- List<int> _rewardList = new List<int>();
- public const int MaxCount = 999;
- public void Clear()
- {
- _decomposeData.Clear();
- }
- public void Add(int itemId)
- {
- int rarity = ItemCfgArray.Instance.GetCfg(itemId).rarity;
- if (!_decomposeData.ContainsKey(rarity))
- {
- _decomposeData.Add(rarity, new List<int>());
- }
- int count = ItemCanDecomposeCount(itemId);
- if (_decomposeData[rarity].IndexOf(itemId) < 0 && count > 0)
- {
- _decomposeData[rarity].Add(itemId);
- }
- }
- public void Remove(int itemId)
- {
- int rarity = ItemCfgArray.Instance.GetCfg(itemId).rarity;
- int count = ItemCanDecomposeCount(itemId);
- if (_decomposeData.ContainsKey(rarity) && _decomposeData[rarity].IndexOf(itemId) >= 0 && count <= 0)
- {
- _decomposeData[rarity].Remove(itemId);
- }
- }
- public List<int> GetDecomposeDataByRarity(int rarity)
- {
- if (!_decomposeData.ContainsKey(rarity)) return null;
- return _decomposeData[rarity];
- }
- public List<int> GetRewardList()
- {
- if (_rewardList.Count == 0)
- {
- DecomposeCfg[] cfgs = DecomposeCfgArray.Instance.dataArray;
- for (int i = 0; i < cfgs.Length; i++)
- {
- for (int j = 0; j < cfgs[i].itemsArr.Length; j++)
- {
- if (_rewardList.IndexOf(cfgs[i].itemsArr[j][0]) < 0)
- {
- _rewardList.Add(cfgs[i].itemsArr[j][0]);
- }
- }
- }
- }
- return _rewardList;
- }
- //物品可分解的数量
- public int ItemCanDecomposeCount(int itemId)
- {
- return ItemDataManager.GetItemNum(itemId) - 1;
- }
- }
- }
|