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();
|
// }
|
}
|