YanCheng_Metrology/Assets/Scripts/Project/Manager/ProcessManager.cs

133 lines
3.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
public class ProcessManager : BaseManager<ProcessManager>
{
/// <summary>
/// 构造函数
/// </summary>
private ProcessManager() { }
/// <summary>
/// 实操项目id
/// </summary>
public int id;
/// <summary>
/// 模式
/// </summary>
public E_ModeType mode;
/// <summary>
/// 当前的项目/方案
/// </summary>
public D_Scheme d_Scheme;
/// <summary>
/// 当前流程Id
/// </summary>
public int processId = -1;
/// <summary>
/// 当前子流程Id
/// </summary>
public int subProcessId = -1;
/// <summary>
/// 当前子流程步骤Id
/// </summary>
public int subProcessStepId = -1;
/// <summary>
/// 倒计时,剩余时长
/// </summary>
public int countDown = 0;
/// <summary>
/// 实训/考试时长
/// </summary>
private int time;
/// <summary>
/// 记录倒计时的协程
/// </summary>
private Coroutine coroutine;
/// <summary>
/// 初始化
/// 根据方案id 生成流程数据
/// </summary>
/// <param name="id">方案id</param>
public void Init(int id, E_ModeType mode,int countDown = 600)
{
this.id = id;
this.mode = mode;
coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
d_Scheme = DataManager.Instance.GetSchemeData(id);
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
d_Scheme.Init();
Debug.Log("流程初始化完成");
}
/// <summary>
/// 切换流程
/// </summary>
public void HandoverProcess(int processId, int subProcessId, int subProcessStepId)
{
if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
return;
d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
}
/// <summary>
/// 切换流程
/// </summary>
public void HandoverSubProcess(int subProcessId, int subProcessStepId)
{
if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
return;
d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
}
/// <summary>
/// 切换流程
/// </summary>
public void HandoverSubProcessStep(int subProcessStepId)
{
if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
return;
d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
}
/// <summary>
/// 倒计时
/// </summary>
/// <param name="time">倒计时多久</param>
/// <returns></returns>
private IEnumerator CountDown(int time)
{
this.time = time;
countDown = time;
WaitForSeconds waitForSeconds = new WaitForSeconds(1);
while (countDown > 0)
{
yield return waitForSeconds;
countDown --;
}
}
/// <summary>
/// 结束
/// </summary>
public void End()
{
id = -1;
mode = E_ModeType.None;
if (coroutine!= null)
GameManager.MonoMgr.StopCoroutine(coroutine);
d_Scheme = null;
}
}