yyl
5 天以前 973edc44a04dceb8b48a32ca912e6167f86189d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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;
    }
 
 
}