hch
2026-01-26 aa84cb62bebb9c8a4e586bcc1ec28eb7a16a8860
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
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class HeroFatesCell : MonoBehaviour
{
    [SerializeField] ImageEx imgBG;
    [SerializeField] TextEx txtFateName;
    [SerializeField] OutlineEx outlineFateName;
    [SerializeField] TextEx txtFateLV;
    [SerializeField] TextEx txtFateNeedHeroHasCnt;
    [SerializeField] TextEx txtHasHeroTotalStar;
 
    [SerializeField] ItemCell itemCell;
 
    [SerializeField] ButtonEx btnHave;
    [SerializeField] ImageEx imgHave;
    [SerializeField] Image imgHaveRed;
 
    [SerializeField] ButtonEx btnUpgrade;
    [SerializeField] TextEx txtUpgrade;
    [SerializeField] ImageEx imgUpgrade;
    [SerializeField] Image imgUpgradeRed;
 
    [SerializeField] HorizontalLayoutGroup horizontalLayoutGroup;
    [SerializeField] List<HeroFatesIHItem> heroFatesIHItems;
    int[] spacingArr = new int[5] { 150, 150, 99, 68, 37 };
    [SerializeField] Transform transAttr;
    [SerializeField] List<TextEx> attrs;
    [SerializeField] Transform transItems;
    [SerializeField] List<ItemCell> items;
    HeroFatesManager manager { get { return HeroFatesManager.Instance; } }
    public void Display(int index, List<int> showList)
    {
        if (showList.IsNullOrEmpty() || index >= showList.Count || index < 0)
        {
            return;
        }
 
        int fatesId = showList[index];
        if (!manager.TryGetHeroFatesConfig(fatesId, out HeroFatesConfig config) || config.HeroIDList.IsNullOrEmpty())
        {
            return;
        }
 
        HeroFatesState state = manager.GetHeroFatesState(fatesId);
        bool isNoActive = state == HeroFatesState.Locked || state == HeroFatesState.Activatable;
        txtFateLV.SetActive(!isNoActive);
        txtFateNeedHeroHasCnt.SetActive(isNoActive);
        txtHasHeroTotalStar.SetActive(state == HeroFatesState.ActiveNotUpgradable || state == HeroFatesState.ActiveUpgradable);
 
        btnHave.SetActive(isNoActive);
        btnHave.interactable = state == HeroFatesState.Activatable;
        imgHave.gray = state == HeroFatesState.Locked;
        imgHaveRed.SetActive(state == HeroFatesState.Activatable);
 
        btnUpgrade.SetActive(!isNoActive);
        btnUpgrade.interactable = state != HeroFatesState.MaxLevel;
        imgUpgrade.gray = state == HeroFatesState.MaxLevel;
        txtUpgrade.text = Language.Get(state == HeroFatesState.MaxLevel ? "L1110" : "L1109");
        imgUpgradeRed.SetActive(state == HeroFatesState.ActiveUpgradable);
 
        imgBG.SetSprite(manager.GetCellBgByFatesQuality(config.BGQuality));
 
 
        int needHeroHasCnt = manager.GetFateNeedHeroHasCnt(fatesId);
        int needHeroCnt = config.HeroIDList.Length;
        txtFateNeedHeroHasCnt.text = Language.Get("BoneField09", needHeroHasCnt, needHeroCnt);
 
        bool hasNowLVAndNextLVConfig = manager.TryGetNowLVAndNextLVConfig(fatesId, out int nowLv, out HeroFatesQualityLVConfig nowLVConfig, out HeroFatesQualityLVConfig nextLVConfig);
        if (hasNowLVAndNextLVConfig)
        {
            int fatesNowStarCnt = manager.GetFatesNowStarCnt(fatesId);
            int nextNeedStarCnt = nextLVConfig.NeedStarTotal;
            txtHasHeroTotalStar.text = StringUtility.Concat(Language.Get("HeroFates05"), UIHelper.AppendColor(nextNeedStarCnt <= fatesNowStarCnt ? TextColType.LightGreen : TextColType.Red, Language.Get("HeroFates11", fatesNowStarCnt, nextNeedStarCnt)));
        }
 
        txtFateName.text = config.FatesName;
        txtFateName.color = UIHelper.GetUIColorByFunc(config.BGQuality);
        outlineFateName.OutlineColor = UIHelper.GetUIOutlineColor(config.BGQuality);
        DisplayLH(config);
 
        transAttr.SetActive(!isNoActive);
        DisplayAttrs(fatesId);
 
        transItems.SetActive(!config.AwardItemList.IsNullOrEmpty() && isNoActive);
        DisplayAwardItems(config);
 
        bool hasInfo = manager.TryGetHeroFates(fatesId, out HeroFates info);
        txtFateLV.text = Language.Get("L1113", hasInfo ? info.FatesLV : 0);
 
        btnHave.SetListener(() => manager.SendHeroFates(fatesId, 0));
        btnUpgrade.SetListener(() =>
        {
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.HeroFatesUpgrade, true))
                return;
            manager.chooseHeroFatesId = fatesId;
            UIManager.Instance.OpenWindow<HeroFatesUpgradeWin>();
        });
    }
 
    void DisplayLH(HeroFatesConfig config)
    {
        if (manager.TryGetNowMaxStarHeroDict(out Dictionary<int, HeroInfo> nowMaxStarHeroDict) || !nowMaxStarHeroDict.IsNullOrEmpty())
        {
            for (int i = 0; i < heroFatesIHItems.Count; i++)
            {
                if (i < config.HeroIDList.Length)
                {
                    int heroID = config.HeroIDList[i];
                    heroFatesIHItems[i].SetActive(true);
                    heroFatesIHItems[i].Display(config.HeroIDList, i, nowMaxStarHeroDict);
                }
                else
                {
                    heroFatesIHItems[i].SetActive(false);
                }
            }
 
            int index = Mathf.Max(config.HeroIDList.Length - 1, 0);
            if (index >= spacingArr.Length)
            {
                index = spacingArr.Length - 1;
            }
            int spacing = spacingArr[index];
            horizontalLayoutGroup.spacing = spacing;
        }
    }
 
    void DisplayAttrs(int fatesId)
    {
        if (attrs.IsNullOrEmpty())
            return;
        bool hasConfig = manager.TryGetAttrIDListAndLVAttrValueList(fatesId, out int[] attrIDList, out int[] lvAttrValueList);
        if (!hasConfig)
            return;
        for (int i = 0; i < attrs.Count; i++)
        {
            if (i < attrIDList.Length)
            {
                int attrID = attrIDList[i];
                int attrValue = manager.GetNowAttrValue(fatesId, i);
                attrs[i].text = PlayerPropertyConfig.GetFullDescription(attrID, attrValue);
                attrs[i].SetActive(true);
            }
            else
            {
                attrs[i].SetActive(false);
            }
        }
 
 
    }
 
    void DisplayAwardItems(HeroFatesConfig config)
    {
        if (items.IsNullOrEmpty() || config.AwardItemList.IsNullOrEmpty())
            return;
        for (int i = 0; i < items.Count; i++)
        {
            if (i < config.AwardItemList.Length)
            {
                int itemID = config.AwardItemList[i][0];
                int count = config.AwardItemList[i][1];
                items[i].Init(new ItemCellModel(itemID, false, count));
                items[i].button.SetListener(() => ItemTipUtility.Show(itemID));
                items[i].SetActive(true);
            }
            else
            {
                items[i].SetActive(false);
            }
        }
    }
}