yyl
22 小时以前 4b5b31a23a74c1559460643836d70778d7d49931
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using System;
using System.Collections;
using System.Collections.Generic;
using LitJson;
 
using UnityEngine;
using UnityEngine.UI;
 
//天赋
public partial class HeroUIManager : GameSystemManager<HeroUIManager>
{
    public int normalGiftMaxCnt = 4;  //初始天赋格子数
    public const int giftMaxCnt = 8;    //关联界面排版问题,暂时写死,通过觉醒可以增加上限
    public int maxGiftLevel;    //单天赋最高等级,其他功能可能会增加这个上限
    public int starLevelCanAwake;   //x星可以觉醒
 
    public int washItemID;
    public int[] washByLockUseCounts;
    public int canWashStarLevel;   //达到X星可以洗练
 
    public string selectHeroGuidForGiftFunc;//武将主体GUID
 
    public int eatHeroIDForResult; //等待吞噬结果武将ID 为了弹成功界面使用
    public string selectHeroGuidForGiftFuncForSuccessWin;   //等待服务器返回的武将GUID 显示成功界面内容
    public List<int> heroBeforeGiftIDList = new List<int>();    //会有重复的ID,不要用字典
    public List<int> heroBeforeGiftLevelList = new List<int>();
 
 
    public event Action SelectEatHeroEvent;
    string m_SelectEatHeroGuid; //被吞噬武将GUID
    public string selectEatHeroGuid
    {
        get { return m_SelectEatHeroGuid; }
        set
        {
            m_SelectEatHeroGuid = value;
            SelectEatHeroEvent?.Invoke();
        }
    }
 
    #region 洗炼
    public string selectWashHeroGUID; //被洗练武将GUID
    public Action changeLockEvent;
 
    #endregion
 
    public List<string> heroEatList = new List<string>();
 
 
    void ParseGiftConfig()
    {
        var config = FuncConfigConfig.Get("HeroStarTalent");
        normalGiftMaxCnt = int.Parse(config.Numerical1);
        maxGiftLevel = int.Parse(config.Numerical2);
        starLevelCanAwake = int.Parse(config.Numerical4);
 
        config = FuncConfigConfig.Get("HeroWash");
        washItemID = int.Parse(config.Numerical1);
        washByLockUseCounts = JsonMapper.ToObject<int[]>(config.Numerical2);
        canWashStarLevel = int.Parse(config.Numerical3);
    }
 
 
    //根据天赋锁状态获取消耗的材料数量
    public int GetTalentLockUseWashCount(HeroInfo hero)
    {
        int heroTalentLockCount = hero.GetTalentLockCount();
        //不够取最后一个
        if (heroTalentLockCount >= washByLockUseCounts.Length)
        {
            heroTalentLockCount = washByLockUseCounts.Length - 1;
        }
        return washByLockUseCounts[heroTalentLockCount];
    }
 
 
    //天赋格子总数上限 
    public int GetGiftGirdMaxCount(int heroID)
    {
        //没有觉醒配置的 为默认4,否则8
        if (HeroAwakeConfig.GetHeroAwakeConfig(heroID, 1) == null)
        {
            return Instance.normalGiftMaxCnt;
        }
        return giftMaxCnt;
    }
 
 
 
    //星最终上限由品质 和 觉醒决定
    public int GetMaxStarCount(int heroID, int quality)
    {
        if (HeroAwakeConfig.GetHeroAwakeConfig(heroID, 1) == null)
        {
            return HeroQualityConfig.Get(quality).InitStarUpper;
 
        }
 
        //根据觉醒累计提升星上限
        int addStarCount = 0;
        for (int i = 1; i <= HeroAwakeConfig.GetMaxAwakeLV(heroID); i++)
        {
            addStarCount += HeroAwakeConfig.GetHeroAwakeConfig(heroID, i).AddStarUpper;
        }
        return HeroQualityConfig.Get(quality).InitStarUpper + addStarCount;
    }
 
 
 
    //beforeGiftIDList用于对比变化的天赋格子
    public void RefreshGiftCell(GiftBaseCell[] giftBaseCells, HeroInfo hero, List<int> beforeGiftIDList = null, List<int> beforeGiftLevelList = null)
    {
        int showCount = GetGiftGirdMaxCount(hero.heroId);
        for (int i = 0; i < giftBaseCells.Length; i++)
        {
            if (i >= showCount)
            {
                giftBaseCells[i].SetActive(false);
                continue;
            }
 
            giftBaseCells[i].SetActive(true);
            if (i < hero.talentIDList.Count)
            {
                int giftID = hero.talentIDList[i];
                int giftLV = hero.talentLvList[i];
                int state = 0; //0:不显示 1:新增 2:提升
 
                if (!beforeGiftIDList.IsNullOrEmpty())
                {
                    if (i >= beforeGiftIDList.Count)
                    {
                        state = 1;
                    }
                    else
                    {
                        if (giftID != beforeGiftIDList[i])
                        {
                            state = 1;
                        }
                        else
                        {
                            if (giftLV > beforeGiftLevelList[i])
                            {
                                state = 2;
                            }
                        }
                    }
                }
 
                giftBaseCells[i].Init(giftID, giftLV, state, hero.heroId, i, hero.awakeLevel);
            }
            else
            {
                if (!beforeGiftIDList.IsNullOrEmpty())
                {
                    //对比情况下不显示
                    giftBaseCells[i].SetActive(false);
                    continue;
                }
 
                //非对比的显示
                if (i < normalGiftMaxCnt)
                {
                    giftBaseCells[i].Init(0, 0);
                }
                else
                {
                    giftBaseCells[i].Init(-1, 0, 0, hero.heroId, i);
                }
            }
 
        }
    }
 
 
    public void CacheHeroEatList()
    {
        heroEatList = PackManager.Instance.GetSinglePack(PackType.Hero).GetItemGUIDListById(
            HeroManager.Instance.GetHero(selectHeroGuidForGiftFunc).heroId);
        heroEatList.Remove(selectHeroGuidForGiftFunc);  //排除吞噬主体
        heroEatList.Sort(CmpDeleteHero);
    }
 
 
 
 
    public void ShowStarImg(int starCount, Image[] starImages, bool noStarShow = true)
    {
        int imgCount = starImages.Length;
        for (int i = 0; i < imgCount; i++)
        {
            if (starCount == 0 && i == 0)
            {
                if (noStarShow)
                {
                    // 无星级 特殊处理 显示一个空星星
                    starImages[i].SetActive(true);
                    starImages[i].SetSprite("herostar" + starCount);
                }
                else
                {
                    starImages[i].SetActive(false);
                }
            }
            else if ((starCount - 1) % imgCount >= i)
            {
                starImages[i].SetActive(true);
                starImages[i].SetSprite("herostar" + (((starCount - 1) / imgCount) + 1) * imgCount);
            }
            else
            {
                starImages[i].SetActive(false);
            }
        }
    }
 
 
    // public ushort ItemIndex;    //武将物品所在武将背包位置索引
    // public byte LockCnt;
    // public  byte[] LockTalentIndexs;    //锁定天赋索引列表
    // public byte OPType;    // 操作类型:0-执行洗炼;1-替换原天赋;2-保留原天赋
    public void SendWash(HeroInfo hero, byte opType)
    {
        var pack = new CB235_tagCSHeroWash();
        pack.ItemIndex = (ushort)hero.itemHero.gridIndex;
        pack.LockCnt = (byte)hero.talentLockList.Count;
        pack.LockTalentIndexs = new byte[pack.LockCnt];
        for (int i = 0; i < pack.LockCnt; i++)
        {
            pack.LockTalentIndexs[i] = (byte)hero.talentLockList[i];
        }
        pack.OPType = opType;
        GameNetSystem.Instance.SendInfo(pack);
    }
}