yyl
2025-07-29 80dddf17d8edba62f002d1237a604a509669340e
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.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
/// <summary>
/// 武将布阵: functionOrder:布阵类型
/// </summary>
public class HeroPosWin : UIBase
{
    [SerializeField] Text[] attrOnList; //上阵属性加成
    [SerializeField] Image countryOnImg;    //上阵阵型激活国家
    [SerializeField] List<Image> OnCountImgs;    //上阵数量激活
    [SerializeField] List<Image> scenePosImgs;  //场景布阵位置
    [SerializeField] HeroScenePosCell[] sceneHero;
 
    [SerializeField] GroupButtonEx attackTeamBtn;
    [SerializeField] GroupButtonEx defendTeamBtn;
 
    [SerializeField] Text fightPowerText;   //由客户端自己预算的战力
    [SerializeField] ScrollerController heroListScroller;
    [SerializeField] Transform heroListEmpty;
    [SerializeField] Toggle showConnTipToggleBtn;
    [SerializeField] HeroSelectBehaviour fiterManager;  //武将筛选
 
    [SerializeField] Button oneKeyOnBtn;     //一键上阵
    [SerializeField] Button saveBtn;        //保存阵型
    [SerializeField] Button backBtn;      //退出界面
    [SerializeField] GroupButtonEx jjcBtn;       //竞技场
    [SerializeField] GroupButtonEx tttBtn;        //通天塔
    [SerializeField] GroupButtonEx mainFBBtn;     //主线副本
 
    //羁绊
    [SerializeField] HeroConnectionCell connetionForm;
 
 
    protected override void InitComponent()
    {
        attackTeamBtn.AddListener(() =>
        {
            if (HeroUIManager.Instance.selectTeamType == TeamType.Arena)
            {
                return;
            }
 
            HeroUIManager.Instance.selectTeamType = TeamType.Arena;
            Refresh();
        });
        defendTeamBtn.AddListener(() =>
        {
            if (HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense)
            {
                return;
            }
            HeroUIManager.Instance.selectTeamType = TeamType.ArenaDefense;
            Refresh();
        });
    }
 
 
    protected override void OnPreOpen()
    {
        heroListScroller.OnRefreshCell += OnRefreshCell;
        CreateScroller();
        Refresh();
    }
 
    protected override void OnPreClose()
    {
        heroListScroller.OnRefreshCell -= OnRefreshCell;
    }
 
 
    public override void Refresh()
    {
        OnBattleTeamAttrPer();
        RefreshOnTeamCountry();
        RefreshOnTeamBtn();
    }
 
 
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as HeroCardLineCell;
        _cell.Display(cell.index);
    }
 
    void CreateScroller()
    {
        heroListScroller.Refresh();
        for (int i = 0; i < HeroUIManager.Instance.heroSortList.Count; i++)
        {
            if (i % 4 == 0)
            {
                heroListScroller.AddCell(ScrollerDataType.Header, i);
            }
        }
        heroListScroller.Restart();
    }
 
    //上阵加成
    void OnBattleTeamAttrPer()
    {
        var valuePer = 0;
        var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
        if (team != null)
        {
            for (int i = 0; i < team.serverHeroes.Length; i++)
            {
                var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid);
                if (hero != null)
                {
                    valuePer += hero.GetOnBattleAddPer();
                }
            }
 
        }
        //上阵属性
        for (int i = 0; i < attrOnList.Length; i++)
        {
            attrOnList[i].text = PlayerPropertyConfig.GetFullDescription(new Int2(PlayerPropertyConfig.basePerAttrs[i], valuePer));
        }
    }
 
    //上阵武将国家光环激活
    void RefreshOnTeamCountry()
    {
        Int2 result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.selectTeamType);
 
        var config = HeroLineupHaloConfig.GetConfig(result.x, result.y);
        if (config == null)
        {
            countryOnImg.SetSprite("heroTeamCountry" + result.x);
            for (int i = 0; i < OnCountImgs.Count; i++)
            {
                OnCountImgs[i].SetActive(false);
            }
        }
        else
        {
            countryOnImg.SetSprite("heroTeamCountry" + result.x);
            for (int i = 0; i < OnCountImgs.Count; i++)
            {
                if (i < result.y)
                {
                    OnCountImgs[i].SetActive(true);
                    OnCountImgs[i].SetSprite("heroTeamCountryPoint" + result.x);
                }
                else
                {
                    OnCountImgs[i].SetActive(false);
                }
            }
        }
 
    }
 
    //管理布阵入口按钮:如竞技场是否根据功能显隐,通天塔和主线只有进攻方布阵默认不显示
    void RefreshOnTeamBtn()
    {
        if (HeroUIManager.Instance.selectTeamType == TeamType.Arena ||
            HeroUIManager.Instance.selectTeamType == TeamType.ArenaDefense)
        {
            attackTeamBtn.SetActive(true);
            defendTeamBtn.SetActive(true);
            if (HeroUIManager.Instance.selectTeamType == TeamType.Arena)
            {
                attackTeamBtn.SelectBtn(true);
            }
            else
            {
                defendTeamBtn.SelectBtn(true);
            }
        }
        else
        {
            attackTeamBtn.SetActive(false);
            defendTeamBtn.SetActive(false);
        }
 
    }
 
 
 
 
}