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
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class StoryBossBattleWin : BaseBattleWin
{
    [SerializeField]
    public BossLifeBar bossLifeBar;
    [SerializeField]
    public SkillWordCell[] skillWordCells;
    [SerializeField]
    public BossHeadCell bossHeadCell;
    [SerializeField]
    public Text txtBossName;
 
    private BattleObject bossBattleObject = null;
 
    [SerializeField] public List<BattleBuffCell> buffCells;
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
 
        UIManager.Instance.CloseWindow<MainWin>();
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
 
        if (!UIManager.Instance.IsOpened<MainWin>())
            UIManager.Instance.OpenWindow<MainWin>();
 
        if (null != bossBattleObject)
        {
            bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
            bossBattleObject = null;
        }
    }
 
    protected override void OnCreateBattleField(string guid, BattleField field)
    {
        if (field is StoryBossBattleField)
        {
            SetBattleField(field);
        }
    }
 
    protected override void RefreshSpecific()
    {
        StoryBossBattleField storyBossField = battleField as StoryBossBattleField;
        if (storyBossField == null) return;
 
        NPCLineupConfig lineupConfig = storyBossField.GetBossLineupConfig();
 
        if (null != bossBattleObject)
        {
            bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
            bossBattleObject = null;
        }
 
        bossBattleObject = storyBossField.FindBoss();
 
        DisplaySkillWordsList(lineupConfig);
 
        if (null != bossBattleObject)
        {
            TeamHero teamHero = bossBattleObject.teamHero;
            bossHeadCell.SetTeamHero(teamHero);
            txtBossName.text = teamHero.name;
            NPCConfig npcConfig = NPCConfig.Get(teamHero.NPCID);
            bossLifeBar.SetBaseInfo(Mathf.Max(1, npcConfig.LifeBarCount), (ulong)teamHero.curHp, (ulong)teamHero.maxHp);
            bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
            bossBattleObject.buffMgr.onBuffChanged += OnBuffChanged;
        }
        else
        {
            bossHeadCell.SetTeamHero(null);
            txtBossName.text = string.Empty;
            bossLifeBar.SetBaseInfo(2, 2, 2);
            Debug.LogError("找不到boss");
        }
 
        OnRoundChange(battleField.round, battleField.turnMax); // 确保回合显示被调用
        OnBuffChanged();
    }
 
    private void OnBuffChanged()
    {
        var buffList = new List<HB428_tagSCBuffRefresh>();
        if (null != bossBattleObject)
        {
            buffList = bossBattleObject.buffMgr.GetBuffList();
        }
        RefreshBuff(buffList);
    }
 
    private void RefreshHP()
    {
        if (null != bossBattleObject)
        {
            TeamHero teamHero = bossBattleObject.teamHero;
            bossLifeBar.Show((ulong)teamHero.curHp, (ulong)teamHero.maxHp);
        }
    }
 
    protected override void OnDamageTaken(BattleDmgInfo info)
    {
        base.OnDamageTaken(info);
        if (battleField == null || info.battleFieldGuid != battleField.guid)
            return;
        if (bossBattleObject != null && info.hurtObj.ObjID == bossBattleObject.ObjID)
        {
            RefreshHP();
        }
    }
 
 
    public void DisplaySkillWordsList(NPCLineupConfig lineUPConfig)
    {
        if (skillWordCells.IsNullOrEmpty())
            return;
 
        if (null == lineUPConfig)
            return;
 
        for (int i = 0; i < skillWordCells.Length; i++)
        {
            if (i < lineUPConfig.SkillIDExList.Length)
            {
                skillWordCells[i].SetActive(true);
                int skillID = lineUPConfig.SkillIDExList[i];
                skillWordCells[i].Init(skillID, () =>
                {
                    SmallTipWin.showText = Language.Get("SmallTipFomat", SkillConfig.Get(skillID)?.SkillName, SkillConfig.Get(skillID)?.Description);
                    SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition);
                    SmallTipWin.isDownShow = true;
                    UIManager.Instance.OpenWindow<SmallTipWin>();
                });
            }
            else
            {
                skillWordCells[i].SetActive(false);
            }
        }
    }
 
    public void RefreshBuff(List<HB428_tagSCBuffRefresh> datas)
    {
        if (buffCells.IsNullOrEmpty())
            return;
 
 
        for (int i = 0; i < buffCells.Count; i++)
        {
            if (i < datas.Count)
            {
                buffCells[i].SetActive(true);
                HB428_tagSCBuffRefresh buffData = datas[i];
                buffCells[i].Init(buffData, () =>
                {
                    //  点击buff图标 显示buff描述/当前身上所有buff
                });
            }
            else
            {
                buffCells[i].SetActive(false);
            }
        }
    }
 
}