hch
2025-09-11 aa72688fbfcba5cf8d90a7b34700bbe1f9ebee12
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections.Generic;
using System.Linq;
 
//武将天赋:升星获得天赋,可洗练
public partial class HeroInfo
{
 
    public int heroStar
    {
        get
        {
            // 因为觉醒降低了星级,客户端自己降低星级
            if (itemHero == null)
                return 0;
 
            return Math.Min(GetCurMaxStar(), heroStarMaxBefore);
        }
    }
 
    // 因为觉醒降低了星级,保留历史最大星级
    public int heroStarMaxBefore
    {
        get
        {
            if (itemHero == null)
                return 0;
            return itemHero.GetUseDataFirstValue(72);
        }
    }
 
    // 71 # 英雄天赋ID列表
    public List<int> talentIDList
    {
        get
        {
            if (itemHero == null)
                return new List<int>();
            return itemHero.GetUseData(71);
        }
    }
 
    // 73 # 英雄天赋ID等级列表,对应71天赋ID的等级
    public List<int> talentLvList
    {
        get
        {
            if (itemHero == null)
                return new List<int>();
            return itemHero.GetUseData(73);
        }
    }
 
    // 75 # 英雄天赋洗炼锁定索引列表,对应71天赋ID索引
    // 洗炼锁定客户端缓存为准,重登会清除,如果需要重登显示锁定则再处理
    // 存储的是索引不是 是否锁定
    public List<int> talentLockList = new List<int>();
 
    // 77 # 英雄天赋洗炼随机ID列表
    public List<int> talentRandomIDList
    {
        get
        {
            if (itemHero == null)
                return new List<int>();
            return itemHero.GetUseData(77);
        }
    }
 
    // 79 # 英雄觉醒时随机天赋选项ID列表
    public List<int> talentAwakeRandomIDList
    {
        get
        {
            if (itemHero == null)
                return new List<int>();
            return itemHero.GetUseData(79);
        }
    }
 
    Dictionary<int, int> talentAttrDic = new Dictionary<int, int>();   //属性ID : 天赋属性值
 
    protected void RefreshTalentAttr()
    {
        talentAttrDic.Clear();
 
        for (int i = 0; i < talentIDList.Count; i++)
        {
            if (talentIDList[i] == 0)
            {
                continue;
            }
            var config = HeroTalentConfig.Get(talentIDList[i]);
            if (!talentAttrDic.ContainsKey(config.AttrID))
            {
                //天赋属性,值*天赋等级
                talentAttrDic[config.AttrID] = config.AttrValue * talentLvList[i];
            }
            else
            {
                talentAttrDic[config.AttrID] += config.AttrValue * talentLvList[i];
            }
        }
 
    }
 
    public int GetTalentAttrValue(int attrType)
    {
        int value = 0;
        talentAttrDic.TryGetValue(attrType, out value);
        return value;
    }
 
    public int GetTalentAttrPer(int attrType)
    {
        if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType))
        {
            var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType];
            return talentAttrDic.ContainsKey(pertype) ? talentAttrDic[pertype] : 0;
        }
        return 0;
    }
 
 
    //天赋会更快到达满级;觉醒可以提升星上限,如初始时40满星,觉醒X级后50满星
    //判断当前是否满星
    public bool IsFullStar()
    {
        return heroStar >= GetCurMaxStar();
    }
 
    //当前能达到的最大星级
    public int GetCurMaxStar()
    {
        if (HeroAwakeConfig.GetHeroAwakeConfig(heroId, 1) == null)
        {
            return HeroQualityConfig.Get(Quality).InitStarUpper;
        }
        //根据觉醒累计提升星上限
        int addStarCount = 0;
        for (int i = 1; i <= awakeLevel; i++)
        {
            addStarCount += HeroAwakeConfig.GetHeroAwakeConfig(heroId, i).AddStarUpper;
        }
        return HeroQualityConfig.Get(Quality).InitStarUpper + addStarCount;
    }
 
    public bool IsFullGift()
    {
        //检查talentLvList 所有元素都大于等于10
        return talentLvList.All(x => x >= HeroUIManager.Instance.maxGiftLevel);
    }
 
 
 
    public int GetTalentLockCount()
    {
        return talentLockList.Count;
    }
 
    //设置是否锁定,只存储锁定的索引
    public void SetTalentLockState(int lockIndex, int state)
    {
        var index = talentLockList.IndexOf(lockIndex);
 
        if (state == 1)
        {
            if (index < 0)
            {
                talentLockList.Add(lockIndex);
            }
            return;
        }
 
        if (state == 0)
        { 
            if (index >= 0)
            {
                talentLockList.RemoveAt(index);
            }
            return;
        }
 
 
    }
 
}