scene中挂载ReconnectMgr;自动保存移出ProcessManager;工具间模型恢复时穿戴装备;
This commit is contained in:
parent
0a524559a7
commit
11854f7fd6
|
@ -298,6 +298,25 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 049bfb1489c99ca49bfbcdcdca9d9cbf, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 049bfb1489c99ca49bfbcdcdca9d9cbf, type: 3}
|
||||||
|
--- !u!1 &275758848 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 1817104531314915916, guid: 049bfb1489c99ca49bfbcdcdca9d9cbf, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 275758847}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &275758849
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 275758848}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2b0607653b5fed643b96912f73248d7e, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
localStatFileName: realtimeStat.json
|
||||||
|
countDown_AutoSave: 120
|
||||||
--- !u!1 &744736104
|
--- !u!1 &744736104
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -70,4 +70,12 @@ public abstract class ScoreBase : MonoBehaviour
|
||||||
Debug.LogError(JsonConvert.SerializeObject(steps));
|
Debug.LogError(JsonConvert.SerializeObject(steps));
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置科目得分,用于断线重连恢复
|
||||||
|
/// </summary>
|
||||||
|
public void setCurrentScore(float _score)
|
||||||
|
{
|
||||||
|
this.currentScore = _score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,6 @@ public class ProcessManager : BaseManager<ProcessManager>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int countDown = 0;
|
public int countDown = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 断线重连接自动保存倒计时
|
|
||||||
/// </summary>
|
|
||||||
public int countDown_AutoSave = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 实训/考试时长
|
/// 实训/考试时长
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -76,12 +71,11 @@ public class ProcessManager : BaseManager<ProcessManager>
|
||||||
/// 根据方案id 生成流程数据
|
/// 根据方案id 生成流程数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">方案id</param>
|
/// <param name="id">方案id</param>
|
||||||
public void Init(int id, E_ModeType mode, int countDown = 600) //TODO 考试断线重连应该考虑初始化问题
|
public void Init(int id, E_ModeType mode, int countDown = 600) //TODO 考试断线重连应该考虑初始化问题(默认时间600)
|
||||||
{
|
{
|
||||||
this.schemeID = id;
|
this.schemeID = id;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
//coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
|
coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
|
||||||
coroutine = GameManager.MonoMgr.StartCoroutine(AutoSaveStat(countDown));//自动保存用户状态信息
|
|
||||||
d_Scheme = DataManager.Instance.GetSchemeData(id);
|
d_Scheme = DataManager.Instance.GetSchemeData(id);
|
||||||
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
|
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
|
||||||
GameManager.ToolAndmaterialMgr.Init(d_Scheme.ToolOrMaterilOrDevice);
|
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>
|
||||||
/// 结束
|
/// 结束
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Newtonsoft.Json.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
using System;
|
using System;
|
||||||
|
using Unity.Burst.CompilerServices;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 断线重连管理
|
/// 断线重连管理
|
||||||
|
@ -13,11 +14,12 @@ using System;
|
||||||
public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
||||||
{
|
{
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public float recordDuration = -1;
|
public string localStatFileName = "realtimeStat.json";//保存文件的文件名
|
||||||
private float recordCountdown = -1;
|
[HideInInspector]
|
||||||
|
public int countDown_AutoSave = 120;//自动保存的时间间隔
|
||||||
private TB_UserExamStat UserExamStat = new TB_UserExamStat();
|
private TB_UserExamStat UserExamStat = new TB_UserExamStat();
|
||||||
private string localStatPath = "";
|
private string localStatPath = "";
|
||||||
private string localStatFileName = "realtimeStat.json";
|
private Coroutine coroutine;//自动保存倒计时
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化函数,记录时间间隔
|
/// 初始化函数,记录时间间隔
|
||||||
|
@ -183,9 +185,14 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
||||||
|
|
||||||
//恢复已穿戴的装备
|
//恢复已穿戴的装备
|
||||||
List<ItemInfo> itemWear = ToolAndmaterialMgr.Instance.CreateItemInfoByName(UserExamStat.allWear);
|
List<ItemInfo> itemWear = ToolAndmaterialMgr.Instance.CreateItemInfoByName(UserExamStat.allWear);
|
||||||
|
TooRoomMannger tooRoomMannger = FindAnyObjectByType<TooRoomMannger>();
|
||||||
foreach (ItemInfo item in itemWear)
|
foreach (ItemInfo item in itemWear)
|
||||||
{
|
{
|
||||||
PacksackBagMgr.Instance.WearItemState(item, true);
|
PacksackBagMgr.Instance.WearItemState(item, true);
|
||||||
|
if (tooRoomMannger != null)//如果在工具间,则修改穿着
|
||||||
|
{
|
||||||
|
tooRoomMannger.Wear(item.toolName, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//恢复场景内各个触发器状态
|
//恢复场景内各个触发器状态
|
||||||
|
@ -205,9 +212,53 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//恢复记录的分数
|
||||||
|
ScoreBase scoreBase = FindFirstObjectByType<ScoreBase>();
|
||||||
|
Dictionary<int, ScoreSubjectStep> reconnectScore = scoreBase.GetStepScore();
|
||||||
|
foreach (var item in UserExamStat.allSubScore)
|
||||||
|
{
|
||||||
|
if (reconnectScore.ContainsKey(item.index))
|
||||||
|
{
|
||||||
|
reconnectScore[item.index].currentScore = item.currentScore;
|
||||||
|
reconnectScore[item.index].isDone = item.isDone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scoreBase.setCurrentScore(UserExamStat.currentScore);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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 <= 0)
|
||||||
|
{
|
||||||
|
ReconnectMgr.Instance.RealtimeStatWriter();//需要在GameManager里面初始化
|
||||||
|
Debug.Log("完成状态自动保存");
|
||||||
|
countDown = countDown_AutoSave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
coroutine = StartCoroutine(AutoSaveStat());
|
||||||
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue