yyl
2025-08-07 d767a5a0efbac267507be14b5b09bd64015fe560
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
using System;
using LitJson;
using UnityEngine;
using System.Collections.Generic;
 
// 【主线战斗流程】
// 发送 B413  (ReqType 为 2 或 3)
//        后端回复  B425标记0开始   (中间N个战斗片段封包)  B425标记1结束
// 前端解析 N个战斗片段封包  ,拆解成前端支持的action指令,然后进行战斗表现
// 表现完毕后继续发送 B413  (ReqType 为 4)
//        后端回复  B425标记0开始   (中间N个战斗片段封包)  B425标记1结束
// 前端解析表现,然后一直循环即可
 
public enum StoryBattleState
{
    Break,
    Battle,
}
 
public class StoryBattleField : BattleField
{
    protected int chapter;//   章节
    protected int wave;//  波数
    protected int level;// 关卡
    protected JsonData extendData;
 
    protected MainChapterConfig chapterConfig;
 
    protected MainLevelConfig levelConfig;
 
    public StoryBattleState battleState;
 
    public StoryBattleField() : base(string.Empty)
    {
 
    }
 
    public override void Init(int MapID, int FuncLineID, JsonData _extendData,
        List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList)
    {
        base.Init(MapID, FuncLineID, extendData, _redTeamList, _blueTeamList);
 
        if (null == _blueTeamList || _blueTeamList.Count == 0)
        {
            battleState = StoryBattleState.Break;
        }
        else
        {
            battleState = StoryBattleState.Battle;
        }
 
        LoadBattleMode();
 
        chapter = FuncLineID / 10000;
        wave = MapID == 1 ? FuncLineID % 100 : 1;//第几波怪
        level = (FuncLineID % 10000) / 100;
 
        extendData = _extendData;
        chapterConfig = MainChapterConfig.Get(chapter);
        levelConfig = MainLevelConfig.Get(level);
 
        TeamManager.Instance.OnTeamChange += OnTeamChange;
    }
 
    public override void Release()
    {
        base.Release();
        TeamManager.Instance.OnTeamChange -= OnTeamChange;
    }
 
    protected void LoadBattleMode()
    {
        string savedStr = LocalSave.GetString("StoryBattleFieldBattleMode");
        if (string.IsNullOrEmpty(savedStr))
        {
            savedStr = "Hand";
        }
        SetBattleMode((BattleMode)Enum.Parse(typeof(BattleMode), savedStr));
    }
 
    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:
                Debug.LogError("recieve a unknown State");
                break;
        }
    }
 
    public override void OnTurnFightObjAction(int turnNum, int ObjID)
    {
        base.OnTurnFightObjAction(turnNum, ObjID);
    }
 
    public override void OnTurnFightState(int turnNum, int State, int FuncLineID, JsonData extendData)
    {
        base.OnTurnFightState(turnNum, State, FuncLineID, extendData);
 
    }
 
    protected void OnTeamChange(TeamType teamType)
    {
        if (teamType == TeamType.Story)
        {
            if (battleState == StoryBattleState.Break)
            {
                ReloadTeam();
            }
        }
    }
 
    public override void HaveRest()
    {
        base.HaveRest();
        battleState = StoryBattleState.Break;
    }
 
    protected void ReloadTeam()
    {
        battleObjMgr.ReloadTeam(TeamManager.Instance.GetTeam(TeamType.Story), BattleCamp.Red);
    }
 
    public override void OnBattleEnd(JsonData turnFightStateData)
    {   
        base.OnBattleEnd(turnFightStateData);
    }
 
    // public override void Run()
    // {
    //     //  一定要记住这个
    //     if (IsPause)
    //         return;
 
    //     base.Run();
    // }
}