lcy
6 天以前 f4d2e99c6041c0d0c933472dcbbeab3cbf4028ef
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
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
//阵型
public class HeroFormationCell : CellView
{
    [SerializeField] Image activeImg;
    [SerializeField] Image countryOnImg;    //上阵阵型激活国家
    [SerializeField] Image[] OnCountImgs;    //上阵数量激活
    [SerializeField] RichText attrText;
 
    public void Display(int index)
    {
        // 第5个格子为混搭阵型
        if (index == 4)
        {
            DisplayMixedFormation();
            return;
        }
 
        Int2 result;
        if (HeroUIManager.Instance.isCustonHeroFormation)
        {
            result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.custonTeamHeroes);;
        }
        else
        {
            result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.selectTeamType, true);
        }
 
        var config = HeroLineupHaloConfig.GetConfig(result.x, result.y);
        bool sameCountry = result.x == (index + 1);
 
        activeImg.SetActive(config != null && sameCountry);
 
 
        countryOnImg.SetSprite("heroTeamCountry" + (index + 1));
        if (config == null || !sameCountry)
        {
            for (int i = 0; i < OnCountImgs.Length; i++)
            {
                OnCountImgs[i].SetActive(false);
            }
        }
        else
        {
            for (int i = 0; i < OnCountImgs.Length; i++)
            {
                if (i < result.y)
                {
                    OnCountImgs[i].SetActive(true);
                    OnCountImgs[i].SetSprite("heroTeamCountryPoint" + result.x);
                }
                else
                {
                    OnCountImgs[i].SetActive(false);
                }
            }
        }
 
 
        var attrDict = HeroLineupHaloConfig.GetAttrsByCountry(index + 1);
        var countList = attrDict.Keys.ToList();
        countList.Sort();
        string text = string.Empty;
        for (int k = 0; k < countList.Count; k++)
        {
            int count = countList[k];
            string lineText = string.Empty;
            bool isActive = sameCountry && count <= result.y;
            string countStr = isActive ? UIHelper.AppendColor(TextColType.Green, count.ToString()) : count.ToString();
            lineText = (k == 0 ? "" : "</r>") + Language.Get("herocard37", countStr, HeroUIManager.Instance.GetCountryName(index + 1));
            var attrConfig = attrDict[count];
            for (int i = 0; i < attrConfig.AttrIDList.Length; i++)
            {
                string format = !isActive ? "{0}+{1}" : "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}");
                lineText += " " + PlayerPropertyConfig.GetFullDescription(attrConfig.AttrIDList[i], attrConfig.AttrValueList[i], format);
            }
 
            text += UIHelper.AppendColor(isActive ? TextColType.NavyBrown : TextColType.Gray, lineText);
        }
        attrText.text = text;
    }
 
    void DisplayMixedFormation()
    {
        // 获取当前激活的混搭配置
        HeroLineupHaloConfig activeMixedConfig;
        List<TeamHero> teamHeroes = null;
        if (HeroUIManager.Instance.isCustonHeroFormation)
            teamHeroes = HeroUIManager.Instance.custonTeamHeroes;
 
        if (teamHeroes != null)
            activeMixedConfig = HeroUIManager.Instance.GetMixedFormationConfig(teamHeroes);
        else
            activeMixedConfig = HeroUIManager.Instance.GetMixedFormationConfig(HeroUIManager.Instance.selectTeamType, true);
 
        bool hasActive = activeMixedConfig != null;
        activeImg.SetActive(hasActive);
        countryOnImg.SetSprite("heroTeamCountryHe");
 
        // 激活点显示:使用当前激活配置的阵营颜色
        List<int> participatingCountries = null;
        if (teamHeroes != null)
            participatingCountries = HeroUIManager.Instance.GetParticipatingCountriesByPriority(teamHeroes);
        else
            participatingCountries = HeroUIManager.Instance.GetParticipatingCountriesByPriority(HeroUIManager.Instance.selectTeamType, true);
 
        if (activeMixedConfig != null && participatingCountries != null && participatingCountries.Count > 0)
        {
            int totalPoints = activeMixedConfig.Countrys * activeMixedConfig.NeedHeroCount;
            for (int i = 0; i < OnCountImgs.Length; i++)
            {
                if (i < totalPoints)
                {
                    int countryIndex = i / activeMixedConfig.NeedHeroCount;
                    OnCountImgs[i].SetActive(true);
                    OnCountImgs[i].SetSprite("heroTeamCountryPoint" + participatingCountries[countryIndex]);
                }
                else
                {
                    OnCountImgs[i].SetActive(false);
                }
            }
        }
        else
        {
            for (int i = 0; i < OnCountImgs.Length; i++)
                OnCountImgs[i].SetActive(false);
        }
 
        // 获取所有混搭配置并展平,按 Countrys 排序
        var allMixedConfigs = HeroLineupHaloConfig.GetAllMixedConfigs();
        List<HeroLineupHaloConfig> sortedConfigs = new List<HeroLineupHaloConfig>();
        if (allMixedConfigs != null)
        {
            foreach (var kvp in allMixedConfigs)
            {
                foreach (var innerKvp in kvp.Value)
                {
                    sortedConfigs.Add(innerKvp.Value);
                }
            }
            sortedConfigs.Sort((a, b) => a.Id.CompareTo(b.Id));
        }
 
        // 属性文本:遍历所有混搭配置,激活的高亮,未激活的灰色
        string text = string.Empty;
        for (int k = 0; k < sortedConfigs.Count; k++)
        {
            var config = sortedConfigs[k];
            bool isActive = activeMixedConfig != null && activeMixedConfig.Id == config.Id;
            string lineText = (k == 0 ? "" : "</r>") + Language.Get("herocard74", config.Countrys, config.NeedHeroCount);
 
            for (int i = 0; i < config.AttrIDList.Length; i++)
            {
                string format = !isActive ? "{0}+{1}" : "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}");
                lineText += " " + PlayerPropertyConfig.GetFullDescription(config.AttrIDList[i], config.AttrValueList[i], format);
            }
 
            text += UIHelper.AppendColor(isActive ? TextColType.NavyBrown : TextColType.Gray, lineText);
        }
        attrText.text = text;
    }
}