hch
11 小时以前 bc6f633a2f3cfc01122d8fd4452f69313ddcb32b
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
using System.Linq;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
 
public class FuncPresetWin : UIBase
{
    [SerializeField] Text tileText;
    [SerializeField] Button globalPresetBtn;
    [SerializeField] Text globalPresetNameText;
    [SerializeField] Transform globalPresetObj;
    [SerializeField] FuncPresetChooseMoreCell[] morecells;  //全局
    [SerializeField] Transform heroCases;
    FuncPresetChooseCells heroPresetCells;
    [SerializeField] HeroSmallHeadCell[] heroHeads;
 
    //命格
    [SerializeField] Transform minggeObj;
    [SerializeField] Transform minggeCases;
    FuncPresetChooseCells minggePresetCells;
    [SerializeField] MinggeItemCell[] minggeItems;
    [SerializeField] Text[] suiteDescs;
 
 
 
    int battleType;
    protected override void InitComponent()
    {
        globalPresetBtn.AddListener(() =>
        {
            if (FuncPresetManager.Instance.GetShowFuncPresetCount((int)FuncPresetType.Global) == 0)
            {
                return;
            }
            globalPresetObj.SetActive(true);
        });
        var presetObj = UIUtility.CreateWidget("FuncPresetChooseCells", "FuncPresetChooseCells");
        presetObj.transform.SetParentEx(heroCases, Vector3.zero, Quaternion.identity, Vector3.one);
        heroPresetCells = presetObj.GetComponent<FuncPresetChooseCells>();
 
        var presetObj1 = UIUtility.CreateWidget("FuncPresetChooseCells", "FuncPresetChooseCells");
        presetObj1.transform.SetParentEx(minggeCases, Vector3.zero, Quaternion.identity, Vector3.one);
        minggePresetCells = presetObj1.GetComponent<FuncPresetChooseCells>();
    }
 
    protected override void OnPreOpen()
    {
        FuncPresetManager.Instance.OnFuncPresetUseDataEvent += OnFuncPresetUseDataEvent;
        Display();
    }
 
    protected override void OnPreClose()
    {
        FuncPresetManager.Instance.OnFuncPresetUseDataEvent -= OnFuncPresetUseDataEvent;
    }
 
    void OnFuncPresetUseDataEvent(int type)
    {
        Display();
        UIUtility.ForceRefreshLayout(layout).Forget();
    }
 
    void Display()
    {
        battleType = functionOrder;
 
        tileText.text = battleType == (int)BattlePreSetType.Story ? Language.Get("FuncPreset7") : Language.Get("FuncPreset13");
        var globalePresetID = FuncPresetManager.Instance.GetGlobalPresetID(battleType);
        var globalePreset = FuncPresetManager.Instance.GetFuncPreset((int)FuncPresetType.Global, globalePresetID);
        globalPresetNameText.text = globalePreset.PresetName;
 
        var showCnt = FuncPresetManager.Instance.GetShowFuncPresetCount((int)FuncPresetType.Global);
 
        for (int i = 0; i < morecells.Length; i++)
        {
            if (i < showCnt)
            {
                morecells[i].SetActive(true);
                morecells[i].Display(battleType, (int)FuncPresetType.Global, i + 1);
            }
            else
            {
                morecells[i].SetActive(false);
            }
        }
 
        heroPresetCells.unFoldID = FuncPresetManager.Instance.GetFuncPresetIDByBattleType(battleType, (int)FuncPresetType.Team);
        heroPresetCells.Display(battleType, (int)FuncPresetType.Team, true);
        var teamID = TeamManager.Instance.GetTeamID((BattlePreSetType)battleType);
        var team = TeamManager.Instance.GetTeam(teamID);
        int heroIndex = 0;
        foreach (var teamHero in team.serverHeroes)
        {
            if (teamHero == null)
            {
                continue;
            }
            HeroInfo heroInfo = HeroManager.Instance.GetHero(teamHero.guid);
            if (heroInfo == null)
            {
                continue;
            }
            heroHeads[heroIndex].SetActive(true);
            heroHeads[heroIndex].Display(heroInfo);
            heroIndex++;
        }
        for (int i = heroIndex; i < heroHeads.Length; i++)
        {
            heroHeads[i].SetActive(false);
        }
 
        if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Mingge))
        {
            minggeObj.SetActive(true);
            minggePresetCells.unFoldID = FuncPresetManager.Instance.GetFuncPresetIDByBattleType(battleType, (int)FuncPresetType.Mingge);
            minggePresetCells.Display(battleType, (int)FuncPresetType.Mingge, true);
 
 
            var presetID = FuncPresetManager.Instance.GetFuncPresetIDByBattleType(battleType, (int)FuncPresetType.Mingge);
            for (int i = 0; i < minggeItems.Length; i++)
            {
                var packIndex = MinggeManager.Instance.GetPackIndex(presetID, i + 1);//对应卦玉背包索引 
                var item = PackManager.Instance.GetItemByIndex(PackType.Mingge, packIndex);
                if (item == null)
                {
                    minggeItems[i].SetActive(false);
                    continue;
                }
                minggeItems[i].SetActive(true);
                minggeItems[i].Display(item.guid);
            }
 
            var dict = MinggeManager.Instance.GetMinggeSkillCountDictByPresetID(presetID);
            var keys = dict.Keys.ToList();
            keys.Sort();
            for (int i = 0; i < suiteDescs.Length; i++)
            {
                if (i < keys.Count)
                {
                    var skillID = keys[i];
                    suiteDescs[i].SetActive(true);
                    suiteDescs[i].text = Language.Get("L1039", Language.Get($"MinggeSkillType_{skillID}")) +
                        SkillConfig.Get(skillID + dict[skillID] - 1).Description + " " + Language.Get("HeroFates11", dict[skillID], MinggeManager.Instance.maxSuiteSkillCount);
       
                }
                else
                {
                    suiteDescs[i].SetActive(false);
                }
            }
        }
        else
        {
            minggeObj.SetActive(false);
        }
    }
 
 
}