using cfg.ProcedureCfg;
using Gameplay;
using Gameplay.Level;
///
/// 强制流程基类
///
public abstract class ProcedureBase
{
///
/// 配置数据
///
public DataProcedure Cfg
{
get;
private set;
}
public ProcedureBase(DataProcedure cfg)
{
Cfg = cfg;
}
///
/// 是否可以开始
///
///
public abstract bool IsCanStart();
///
/// 是否正在流程中
///
///
public abstract bool IsProceduring();
///
/// 开始强制流程
///
public abstract void Begin();
}
///
/// 进入关卡
///
public sealed class EnterLevel_Procedure : ProcedureBase
{
private readonly int levelId;
public EnterLevel_Procedure(DataProcedure cfg) : base(cfg)
{
if (cfg.ProcedureParams.Length < 1)
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数数量错误,需要1个参数:关卡id");
return;
}
if (!int.TryParse(cfg.ProcedureParams[0], out int id))
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数类型错误,需要1个参数:关卡id");
return;
}
levelId = id;
}
public override void Begin()
{
LevelManager.Instance.TryEnterLevel(levelId, null, null, true);
}
public override bool IsCanStart()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass;
}
public override bool IsProceduring()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass; // 没有通关,则在该流程中
}
}
///
/// 进入队伍信息界面
///
public sealed class EnterTeamInfoUI_Procedure : ProcedureBase
{
private readonly int levelId;
public EnterTeamInfoUI_Procedure(DataProcedure cfg) : base(cfg)
{
if (cfg.ProcedureParams.Length < 1)
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数数量错误,需要1个参数:关卡id");
return;
}
if (!int.TryParse(cfg.ProcedureParams[0], out int id))
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数类型错误,需要1个参数:关卡id");
return;
}
levelId = id;
}
public override void Begin()
{
GameStateManager.Instance.ChangeState(new GameStateMainScene(false, false, async () =>
{
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.TeamInfoByGuide, levelId);
}));
}
public override bool IsCanStart()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass;
}
public override bool IsProceduring()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass; // 没有通关,则在该流程中
}
}
///
/// 进入编队信息界面
///
public sealed class EnterEditTeamUI_Procedure : ProcedureBase
{
private readonly int levelId;
public EnterEditTeamUI_Procedure(DataProcedure cfg) : base(cfg)
{
if (cfg.ProcedureParams.Length < 1)
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数数量错误,需要1个参数:关卡id");
return;
}
if (!int.TryParse(cfg.ProcedureParams[0], out int id))
{
DebugUtil.LogError($"强制流程id:{cfg.Id},参数类型错误,需要1个参数:关卡id");
return;
}
levelId = id;
}
public override void Begin()
{
GameStateManager.Instance.ChangeState(new GameStateMainScene(false, false, async () =>
{
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.TeamSelect, levelId);
}));
}
public override bool IsCanStart()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass;
}
public override bool IsProceduring()
{
if (!LevelManager.Instance.TryGetLevelInfoByID(levelId, out LevelInfo levelInfo))
return false;
return !levelInfo.IsPass; // 没有通关,则在该流程中
}
}