using System.Collections.Generic;
|
using System.Linq;
|
|
//羁绊:上阵后的武将组合可激活羁绊
|
public partial class HeroInfo
|
{
|
Dictionary<int, int> fetterAttrs = new Dictionary<int, int>(); //羁绊属性ID:属性值
|
|
|
//不同阵容羁绊属性不同,实时计算,与其他缓存的不同
|
public void RefreshFetterAttrsWhenCalcPower(TeamType teamType)
|
{
|
fetterAttrs.Clear();
|
var list = GetActiveFetter(heroConfig, TeamManager.Instance.GetTeam(teamType));
|
|
foreach (var id in list)
|
{
|
var config = HeroFetterConfig.Get(id);
|
var attrIDs = config.AttrIDList;
|
var attrValues = config.AttrValueList;
|
for (int i = 0; i < attrIDs.Length; i++)
|
{
|
if (!fetterAttrs.ContainsKey(attrIDs[i]))
|
{
|
fetterAttrs.Add(attrIDs[i], attrValues[i]);
|
}
|
else
|
{
|
fetterAttrs[attrIDs[i]] += attrValues[i];
|
}
|
}
|
}
|
}
|
|
|
public int GetFetterAttrValue(int attrType)
|
{
|
int value = 0;
|
fetterAttrs.TryGetValue(attrType, out value);
|
return value;
|
}
|
|
public int GetFetterAttrPer(int attrType)
|
{
|
if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType))
|
{
|
var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType];
|
return fetterAttrs.ContainsKey(pertype) ? fetterAttrs[pertype] : 0;
|
}
|
return 0;
|
}
|
|
|
public List<int> GetActiveFetter(HeroConfig config, TeamBase teamBase)
|
{
|
List<int> list = new List<int>();
|
if (config.FetterIDList.Length == 0)
|
return list;
|
|
foreach (var fetterID in config.FetterIDList)
|
{
|
HeroFetterConfig fetterConfig = HeroFetterConfig.Get(fetterID);
|
int count = 0;
|
for (int i = 0; i < teamBase.tempHeroes.Length; i++)
|
{
|
TeamHero teamHero = teamBase.tempHeroes[i];
|
|
if (null == teamHero)
|
continue;
|
|
if (fetterConfig.HeroIDList.Contains(teamHero.heroId))
|
{
|
count++;
|
}
|
if (count >= fetterConfig.HeroIDList.Length)
|
{
|
list.Add(fetterID);
|
break;
|
}
|
}
|
}
|
|
return list;
|
}
|
|
|
}
|