自动保存的启动放在ReconnectMgr中
This commit is contained in:
parent
096c742205
commit
a79129a467
|
@ -56,11 +56,6 @@ public class ProcessManager : BaseManager<ProcessManager>
|
|||
/// </summary>
|
||||
public int countDown = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 断线重连接自动保存倒计时
|
||||
/// </summary>
|
||||
public int countDown_AutoSave = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 实训/考试时长
|
||||
/// </summary>
|
||||
|
@ -76,12 +71,11 @@ public class ProcessManager : BaseManager<ProcessManager>
|
|||
/// 根据方案id 生成流程数据
|
||||
/// </summary>
|
||||
/// <param name="id">方案id</param>
|
||||
public void Init(int id, E_ModeType mode, int countDown = 60) //TODO 考试断线重连应该考虑初始化问题(默认时间600)
|
||||
public void Init(int id, E_ModeType mode, int countDown = 600) //TODO 考试断线重连应该考虑初始化问题(默认时间600)
|
||||
{
|
||||
this.schemeID = id;
|
||||
this.mode = mode;
|
||||
//coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
|
||||
coroutine = GameManager.MonoMgr.StartCoroutine(AutoSaveStat(countDown));//自动保存用户状态信息
|
||||
coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
|
||||
d_Scheme = DataManager.Instance.GetSchemeData(id);
|
||||
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
|
||||
GameManager.ToolAndmaterialMgr.Init(d_Scheme.ToolOrMaterilOrDevice);
|
||||
|
@ -312,29 +306,6 @@ public class ProcessManager : BaseManager<ProcessManager>
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动保存用户状态,
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerator AutoSaveStat(int time)
|
||||
{
|
||||
countDown_AutoSave = time;
|
||||
WaitForSeconds waitForSeconds = new WaitForSeconds(1);
|
||||
while (countDown_AutoSave > 0)
|
||||
{
|
||||
yield return waitForSeconds;
|
||||
countDown_AutoSave--;
|
||||
//Debug.Log("自动保存倒计时:" + countDown_AutoSave);
|
||||
if (countDown_AutoSave <= 0)
|
||||
{
|
||||
ReconnectMgr.Instance.RealtimeStatWriter();//需要在GameManager里面初始化
|
||||
//Debug.Log("完成状态自动保存");
|
||||
countDown_AutoSave = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 结束
|
||||
/// </summary>
|
||||
|
|
|
@ -14,18 +14,19 @@ using Unity.Burst.CompilerServices;
|
|||
public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
||||
{
|
||||
[HideInInspector]
|
||||
public float recordDuration = -1;
|
||||
private float recordCountdown = -1;
|
||||
private TB_UserExamStat UserExamStat = new TB_UserExamStat();
|
||||
private string localStatPath = "";
|
||||
private string localStatFileName = "realtimeStat.json";
|
||||
|
||||
public string localStatFileName = "realtimeStat.json";//保存文件的文件名
|
||||
[HideInInspector]
|
||||
public int countDown_AutoSave = 60;//自动保存的时间间隔
|
||||
private TB_UserExamStat UserExamStat = new TB_UserExamStat();
|
||||
private string localStatPath = "";
|
||||
private Coroutine coroutine;//自动保存倒计时
|
||||
|
||||
/// <summary>
|
||||
/// 初始化函数,记录时间间隔
|
||||
/// </summary>
|
||||
public void Init( )
|
||||
{
|
||||
localStatPath = Application.streamingAssetsPath + "/" + localStatFileName;
|
||||
localStatPath = Application.streamingAssetsPath + "/" + localStatFileName;
|
||||
//if (File.Exists( localStatPath ))//启动后检查有没有之前的遗留
|
||||
//{
|
||||
// File.Delete( localStatPath );
|
||||
|
@ -222,6 +223,37 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动保存用户状态,
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerator AutoSaveStat()
|
||||
{
|
||||
int countDown = countDown_AutoSave;
|
||||
WaitForSeconds waitForSeconds = new WaitForSeconds(1);
|
||||
while (countDown > 0)
|
||||
{
|
||||
yield return waitForSeconds;
|
||||
//Exam为考试模式,Practice为练习模式,考试模式加入后,进入要重置时间,重新启动
|
||||
if (ProcessManager.Instance.mode == E_ModeType.Practice)
|
||||
{
|
||||
countDown--;
|
||||
Debug.Log("自动保存倒计时:" + countDown);
|
||||
if (countDown_AutoSave <= 0)
|
||||
{
|
||||
ReconnectMgr.Instance.RealtimeStatWriter();//需要在GameManager里面初始化
|
||||
//Debug.Log("完成状态自动保存");
|
||||
countDown = countDown_AutoSave;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
coroutine = StartCoroutine(AutoSaveStat());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue