|
@@ -4,7 +4,8 @@ namespace GFGGame
|
|
|
{
|
|
|
public class DecomposeDataManager : SingletonBase<DecomposeDataManager>
|
|
|
{
|
|
|
- Dictionary<int, List<int>> _decomposeData = new Dictionary<int, List<int>>();//所有数量大于1的换装部件数据
|
|
|
+ Dictionary<int, List<int>> _decomposeData = new Dictionary<int, List<int>>();//所有可分解的换装部件数据
|
|
|
+ Dictionary<int, List<int>> _decomposeMaterialData = new Dictionary<int, List<int>>();//所有可分解的材料数据
|
|
|
Dictionary<int, List<int>> _suitSyntheticMaterials = new Dictionary<int, List<int>>();//materiasId,Lsit<suitId>
|
|
|
List<int> _rewardList = new List<int>();
|
|
|
|
|
@@ -12,6 +13,7 @@ namespace GFGGame
|
|
|
public void Clear()
|
|
|
{
|
|
|
_decomposeData.Clear();
|
|
|
+ _decomposeMaterialData.Clear();
|
|
|
_suitSyntheticMaterials.Clear();
|
|
|
}
|
|
|
public void Add(int itemId)
|
|
@@ -51,6 +53,20 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void AddMaterial(int itemId)
|
|
|
+ {
|
|
|
+ //初始化时禁止使用物品配置,会造成卡顿!!!
|
|
|
+ int rarity = ItemDataManager.GetItemRarity(itemId);
|
|
|
+ if (!_decomposeMaterialData.ContainsKey(rarity))
|
|
|
+ {
|
|
|
+ _decomposeMaterialData.Add(rarity, new List<int>());
|
|
|
+ }
|
|
|
+ if (_decomposeMaterialData[rarity].IndexOf(itemId) < 0)
|
|
|
+ {
|
|
|
+ _decomposeMaterialData[rarity].Add(itemId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void Remove(int itemId)
|
|
|
{
|
|
|
int rarity = ItemCfgArray.Instance.GetCfg(itemId).rarity;
|
|
@@ -62,6 +78,17 @@ namespace GFGGame
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void RemoveMaterial(int itemId)
|
|
|
+ {
|
|
|
+ int rarity = ItemCfgArray.Instance.GetCfg(itemId).rarity;
|
|
|
+ long count = ItemCanDecomposeMaterialCount(itemId);
|
|
|
+
|
|
|
+ if (_decomposeMaterialData.ContainsKey(rarity) && _decomposeMaterialData[rarity].IndexOf(itemId) >= 0 && count <= 0)
|
|
|
+ {
|
|
|
+ _decomposeMaterialData[rarity].Remove(itemId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//分解需要扣去合成需要的数量
|
|
|
public int DeductSynthesisNeedNum(int itemId)
|
|
|
{
|
|
@@ -90,6 +117,7 @@ namespace GFGGame
|
|
|
return _decomposeData[rarity];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public List<int> GetRewardList()
|
|
|
{
|
|
|
if (_rewardList.Count == 0)
|
|
@@ -108,6 +136,19 @@ namespace GFGGame
|
|
|
}
|
|
|
return _rewardList;
|
|
|
}
|
|
|
+
|
|
|
+ //物品可分解的数量
|
|
|
+ public long CanDecomposeCount(int decomposeType, int itemId)
|
|
|
+ {
|
|
|
+ if (decomposeType == 0) {
|
|
|
+ return ItemCanDecomposeCount(itemId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return ItemCanDecomposeMaterialCount(itemId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//物品可分解的数量
|
|
|
public long ItemCanDecomposeCount(int itemId)
|
|
|
{
|
|
@@ -115,6 +156,60 @@ namespace GFGGame
|
|
|
int synthesisNum = DeductSynthesisNeedNum(itemId);
|
|
|
return ItemDataManager.GetItemNum(itemId) - 1 - synthesisNum;
|
|
|
}
|
|
|
+
|
|
|
+ //材料可分解的数量
|
|
|
+ public long ItemCanDecomposeMaterialCount(int itemId)
|
|
|
+ {
|
|
|
+ //合成需要的数量
|
|
|
+ int synthesisNum = DeductSynthesisMaterialNeedNum(itemId);
|
|
|
+ return ItemDataManager.GetItemNum(itemId) - synthesisNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<int> GetDecomposeMaterialByRarity(int rarity)
|
|
|
+ {
|
|
|
+ if (!_decomposeMaterialData.ContainsKey(rarity)) return null;
|
|
|
+ Dictionary<int, int> LeagueSkillLvDatas = SkillDataManager.Instance.LeagueSkillLvDatas;
|
|
|
+ List<int> materialDataKey = new List<int>();
|
|
|
+ foreach (var key in _decomposeMaterialData.Keys)
|
|
|
+ {
|
|
|
+ materialDataKey.Add(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < materialDataKey.Count; i++)
|
|
|
+ {
|
|
|
+ for (int k = 0; k < _decomposeMaterialData[materialDataKey[i]].Count; k++)
|
|
|
+ {
|
|
|
+ int itemId = _decomposeMaterialData[materialDataKey[i]][k];
|
|
|
+ if (ItemCanDecomposeMaterialCount(itemId) <= 0) {
|
|
|
+ _decomposeMaterialData[materialDataKey[i]].RemoveAt(k);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _decomposeMaterialData[rarity];
|
|
|
+ }
|
|
|
+
|
|
|
+ //分解需要扣去合成材料需要的数量
|
|
|
+ public int DeductSynthesisMaterialNeedNum(int itemId)
|
|
|
+ {
|
|
|
+ int sum = 0;
|
|
|
+ int skillId = ItemDataManager.GetItemSkillId(itemId);
|
|
|
+ Dictionary<int, int> leagueSkillLvDatas = SkillDataManager.Instance.GetLeagueSkillLvDatas();
|
|
|
+ if (!leagueSkillLvDatas.ContainsKey(skillId))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ int skillLv = leagueSkillLvDatas[skillId];
|
|
|
+ PassivitySkillLvlCfg skillLvlCfg = PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLv, skillId);
|
|
|
+ int skillLvIndex = skillLv;
|
|
|
+
|
|
|
+ while (skillLvlCfg != null && skillLvlCfg.materiarsArr != null && skillLvlCfg.materiarsArr.Length > 0)
|
|
|
+ {
|
|
|
+ sum += skillLvlCfg.materiarsArr[0][1];
|
|
|
+ skillLvIndex += 1;
|
|
|
+ skillLvlCfg = PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLvIndex, skillId);
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
+
|
|
|
public void InitSuitSyntheticMaterias()
|
|
|
{
|
|
|
List<SuitCfg> suitCfgs = new List<SuitCfg>();
|