2024-12-02 16:12:29 +08:00
|
|
|
|
using cfg.GuideCfg;
|
|
|
|
|
|
using cfg.ProcedureCfg;
|
|
|
|
|
|
using Framework;
|
|
|
|
|
|
using PhxhSDK;
|
|
|
|
|
|
using System;
|
2024-12-02 14:44:17 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2024-12-02 16:12:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 强制流程管理器
|
|
|
|
|
|
/// </summary>
|
2024-12-03 17:50:07 +08:00
|
|
|
|
public class ProcedureManager : Singlenton<ProcedureManager>, IInitable
|
2024-12-02 14:44:17 +08:00
|
|
|
|
{
|
2024-12-02 16:12:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 强制流程数据,key:检查类型,value:强制流程数组
|
|
|
|
|
|
/// </summary>
|
2024-12-02 18:54:48 +08:00
|
|
|
|
private Dictionary<E_ProcedureCheck, List<ProcedureBase>> dicProcedure;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private ProcedureBase curProcedureBase;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否强制流程中
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsProceduring
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null == curProcedureBase)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return curProcedureBase.IsProceduring();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-02 16:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, InitData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
|
|
{
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.AllConfigLoad, InitData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 14:44:17 +08:00
|
|
|
|
/// <summary>
|
2024-12-03 17:50:07 +08:00
|
|
|
|
/// 检查是否可以进入强制流程
|
2024-12-02 14:44:17 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2024-12-02 16:12:29 +08:00
|
|
|
|
public bool CheckEnterProcedure(E_ProcedureCheck procedureCheck)
|
2024-12-02 14:44:17 +08:00
|
|
|
|
{
|
2024-12-03 17:50:07 +08:00
|
|
|
|
curProcedureBase = null;
|
2024-12-02 18:54:48 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!dicProcedure.TryGetValue(procedureCheck, out List<ProcedureBase> listProcedure))
|
2024-12-02 16:12:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"没有获得到{procedureCheck.GetType()}类型的配置");
|
2024-12-02 18:54:48 +08:00
|
|
|
|
curProcedureBase = null;
|
2024-12-02 16:12:29 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 18:54:48 +08:00
|
|
|
|
foreach (ProcedureBase procedure in listProcedure)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!procedure.IsCanStart())
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
curProcedureBase = procedure;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
curProcedureBase = null;
|
|
|
|
|
|
return false;
|
2024-12-02 14:44:17 +08:00
|
|
|
|
}
|
2024-12-02 16:12:29 +08:00
|
|
|
|
|
2024-12-03 17:50:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 进入强制流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void EnterProcedure()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null == curProcedureBase)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
curProcedureBase.Begin();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 16:12:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void InitData()
|
|
|
|
|
|
{
|
2024-12-02 18:54:48 +08:00
|
|
|
|
dicProcedure = new();
|
2024-12-02 16:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (DataProcedure cfg in TableManager.Instance.Tables.ProcedureConfig.DataList)
|
|
|
|
|
|
{
|
2024-12-02 18:54:48 +08:00
|
|
|
|
ProcedureBase procedureBase = cfg.ProcedureType switch
|
|
|
|
|
|
{
|
|
|
|
|
|
E_Procedure.EnterLevel => new EnterLevel_Procedure(cfg),
|
|
|
|
|
|
E_Procedure.EnterTeamInfoUI => new EnterTeamInfoUI_Procedure(cfg),
|
|
|
|
|
|
E_Procedure.EnterEditTeamUI => new EnterEditTeamUI_Procedure(cfg),
|
|
|
|
|
|
_ => throw new Exception($"未处理类型{cfg.ProcedureType}"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-12-02 16:12:29 +08:00
|
|
|
|
foreach (E_ProcedureCheck procedureCheck in cfg.ProcedureCheckType)
|
|
|
|
|
|
{
|
2024-12-02 18:54:48 +08:00
|
|
|
|
if (!dicProcedure.TryGetValue(procedureCheck, out List<ProcedureBase> listProcedure))
|
2024-12-02 16:12:29 +08:00
|
|
|
|
{
|
2024-12-02 18:54:48 +08:00
|
|
|
|
listProcedure = new();
|
|
|
|
|
|
dicProcedure[procedureCheck] = listProcedure;
|
2024-12-02 16:12:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 18:54:48 +08:00
|
|
|
|
listProcedure.Add(procedureBase);
|
2024-12-02 16:12:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-02 14:44:17 +08:00
|
|
|
|
}
|