yyl
2025-12-10 8b13766dc43e3f4406a64873844dcecd24cabcb5
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
using System.Collections.Generic;
using UnityEngine;
 
public class BattleDetailWin : UIBase
{
    [SerializeField] TextEx redName;
    [SerializeField] TextEx blueName;
    [SerializeField] List<BattleDetailHeroInfoItem> redList = new List<BattleDetailHeroInfoItem>();
    [SerializeField] List<BattleDetailHeroInfoItem> blueList = new List<BattleDetailHeroInfoItem>();
    BattleSettlementManager manager { get { return BattleSettlementManager.Instance; } }
    protected override void OnPreOpen()
    {
        Display();
    }
 
    public void Display()
    {
        bool isMyStart = manager.isMyStartBattleDetail;
        BattleDetailMsg msg = manager.msg;
        string battleName = manager.BattleDetailBattleName;
 
        if (msg == null)
            return;
 
        if (isMyStart)
        {
            // 目前玩家主动发起的阵容一定是1,对方是 2, 如果是那种系统自动打的,一般1-左,2-右
            int myWinFaction = 1;
            string myName = PlayerDatas.Instance.baseData.PlayerName;
            string enemyName = manager.GetBattleDetailEnemyNameByMyStart(battleName);
            if (battleName == BattleConst.TianziBillboradBattleField)
            {
                redName.text = myWinFaction == msg.winFaction ? enemyName : myName;
                blueName.text = myWinFaction == msg.winFaction ? myName : enemyName;
            }
            else
            {
                redName.text = myWinFaction == msg.winFaction ? myName : enemyName;
                blueName.text = myWinFaction == msg.winFaction ? enemyName : myName;
            }
 
        }
 
        List<BattleDetailHeroInfo> redBattleDetailHeroInfoList = manager.GetHeroInfo(msg, isMyStart, battleName, true);
        List<BattleDetailHeroInfo> blueBattleDetailHeroInfoList = manager.GetHeroInfo(msg, isMyStart, battleName, false);
        DisplayDetail(redList, redBattleDetailHeroInfoList);
        DisplayDetail(blueList, blueBattleDetailHeroInfoList);
    }
 
    public void DisplayDetail(List<BattleDetailHeroInfoItem> teamItemList, List<BattleDetailHeroInfo> infoList)
    {
        int mvpIndex = GetMvpIndex(infoList);
        GetMaxAttr(infoList, out ulong maxAtk, out ulong maxDef, out ulong maxCure);
 
        for (int i = 0; i < teamItemList.Count; i++)
        {
            if (i < infoList.Count)
            {
                teamItemList[i].SetActive(true);
                teamItemList[i].Display(new BattleDetailHeroInfoItemData()
                {
                    index = i,
                    mvpIndex = mvpIndex,
                    maxAtk = maxAtk,
                    maxDef = maxDef,
                    maxCure = maxCure,
                    info = infoList[i],
                });
            }
            else
            {
                teamItemList[i].SetActive(false);
            }
        }
    }
 
    public int GetMvpIndex(List<BattleDetailHeroInfo> infos)
    {
        if (infos.IsNullOrEmpty())
            return -1;
        int mvpIndex = -1;
        ulong mvpScore = 0;
        for (int i = 0; i < infos.Count; i++)
        {
            BattleDetailHeroInfo nowInfo = infos[i];
            ulong nowValue = nowInfo.AtkHurt + nowInfo.DefHurt + nowInfo.CureHP;
            if (nowValue > mvpScore)
            {
                mvpIndex = i;
                mvpScore = nowValue;
            }
        }
        return mvpIndex;
    }
 
    public void GetMaxAttr(List<BattleDetailHeroInfo> infos, out ulong maxAtk, out ulong maxDef, out ulong maxCure)
    {
        maxAtk = 0;
        maxDef = 0;
        maxCure = 0;
        if (infos.IsNullOrEmpty())
            return;
 
        for (int i = 0; i < infos.Count; i++)
        {
            BattleDetailHeroInfo nowInfo = infos[i];
            if (nowInfo.AtkHurt > maxAtk)
                maxAtk = nowInfo.AtkHurt;
            if (nowInfo.DefHurt > maxDef)
                maxDef = nowInfo.DefHurt;
            if (nowInfo.CureHP > maxCure)
                maxCure = nowInfo.CureHP;
        }
    }
}
public class BattleDetailHeroInfoItemData
{
    public int index;
    public int mvpIndex;
    public ulong maxAtk;
    public ulong maxDef;
    public ulong maxCure;
    public BattleDetailHeroInfo info;
}