yyl
2025-09-17 eb2fcb2536a8cce0b971f827c9232a138262b219
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
using System;
using LitJson;
using UnityEngine;
using System.Collections.Generic;
 
 
public class StoryBossBattleField : BattleField
{
    protected int chapter;//   章节
    protected int wave;//  波数
    protected int level;// 关卡
    protected JsonData extendData;
 
    protected MainChapterConfig chapterConfig;
 
    protected MainLevelConfig levelConfig;
 
 
    public StoryBossBattleField(string _guid) : base(_guid)
    {
        
    }
 
    public override void Init(int MapID, int FuncLineID, JsonData _extendData,
        List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList)
    {
        base.Init(MapID, FuncLineID, extendData, _redTeamList, _blueTeamList);
 
        chapter = FuncLineID / 10000;
        wave = MapID == 1 ? FuncLineID % 100 : 1;//第几波怪
        level = (FuncLineID % 10000) / 100;
 
        extendData = _extendData;
        chapterConfig = MainChapterConfig.Get(chapter);
        levelConfig = MainLevelConfig.Get(level);
 
        SetBattleMode(BattleMode.Record);
    }
 
    public override void Release()
    {
        base.Release();
    }
 
 
    public override void AutoSetBattleMode()
    {
        SetBattleMode(BattleMode.Record);
    }
 
    public override void TurnFightState(int TurnNum, int State,
        uint FuncLineID, JsonData extendData)
    {
        base.TurnFightState(TurnNum, State, FuncLineID, extendData);
 
        switch (State)
        {
            //  起始状态标记
            case 0:
                break;
            case 1://准备完毕
                break;
            case 2://战斗中
                break;
            case 3://战斗结束
                break;
            case 4://结算奖励
                break;
            case 5://结束状态标记
                break;
            default:
                BattleDebug.LogError("recieve a unknown State");
                break;
        }
    }
 
    protected override void OnSettlement(JsonData turnFightStateData)
    {
        base.OnSettlement(turnFightStateData);
 
 
    }
 
    private void WhaleFall()
    {
        //  YYL TODO 应该需要一个结算界面来做这些内容
        UIManager.Instance.CloseWindow<FullScreenBattleWin>();
        AutoFightModel.Instance.isPause = false;
        Destroy();
    }
 
    public override void OnBattleEnd(JsonData turnFightStateData)
    {
        BattleEndAction battleEndAction = new BattleEndAction(this, turnFightStateData, () =>
        {
            BattleDebug.LogError(turnFightStateData.ToJson());
            // 这里可以添加战斗结束的具体逻辑
            OnSettlement(turnFightStateData);
 
            int winFaction = (int)turnFightStateData["winFaction"];
            //获胜阵营:   一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了
 
            if (winFaction == 1)
            {
                Debug.LogError(guid + " : 战斗胜利");
                //  战斗胜利
            }
            else
            {
                //  战斗失败
                Debug.LogError(guid + " : 战斗失败");
            }
 
            IsBattleFinish = true;
 
 
            //提供外部 胜利等奖励显示
            EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData);
            WhaleFall();
 
        });
        recordPlayer.PlayRecord(battleEndAction);
    }
 
    public override void HaveRest()
    {
        //  主线BOSS战斗没有休息
    }
 
 
    // public override void OnBattleEnd(JsonData turnFightStateData)
    // {
    //     base.OnBattleEnd(turnFightStateData);
    //     // HaveRest();
    // }
 
    public override void Run()
    {
        if (operationAgent == null)
        {
            //防范异常
            return;
        }
        base.Run();
    }
 
    public override void DistributeNextPackage()
    {
        if (IsBattleFinish)
            return;
            
        //  不要调用base的函数
        BattleManager.Instance.DistributeNextReportPackage(guid);
    }
 
 
}