工具和材料状态的保存

This commit is contained in:
liuyu 2024-09-03 10:53:32 +08:00
parent 56eba812fe
commit a502be2aa0
5 changed files with 248 additions and 9 deletions

View File

@ -13,7 +13,7 @@ public class ReconnetItemInfo
public int toolId; public int toolId;
public int triggerID; public int triggerID;
public string toolName; public string toolName;
public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial; //public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
public Vector3 selfPosInToolRoom; public Vector3 selfPosInToolRoom;
} }
public class TB_UserExamStat public class TB_UserExamStat
@ -41,6 +41,6 @@ public class TB_UserExamStat
/// <summary> /// <summary>
/// 当前场景内的所有可触发物品 /// 当前场景内的所有可触发物品
/// </summary> /// </summary>
private List<ReconnetItemInfo> currentSceneTools = new List<ReconnetItemInfo>(); public List<ReconnetItemInfo> currentSceneTools = new List<ReconnetItemInfo>();
} }

View File

@ -79,8 +79,8 @@ public class ProcessManager : BaseManager<ProcessManager>
{ {
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));//自动保存用户状态信息 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);

View File

@ -43,7 +43,6 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
public void RealtimeStatWriter() public void RealtimeStatWriter()
{ {
//记录步骤相关各项信息 //记录步骤相关各项信息
/*UserExamStat.schemeID = ProcessManager.Instance.schemeID; /*UserExamStat.schemeID = ProcessManager.Instance.schemeID;
UserExamStat.processId = ProcessManager.Instance.processId; UserExamStat.processId = ProcessManager.Instance.processId;
@ -73,7 +72,7 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
UserExamStat.sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; UserExamStat.sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
//获取场景内所有可以出发的物品 //获取场景内所有可以出发的物品
currentSceneTools.Clear(); UserExamStat.currentSceneTools.Clear();
BaseToolOrDevice[] allThings = FindObjectsOfType<BaseToolOrDevice>(); BaseToolOrDevice[] allThings = FindObjectsOfType<BaseToolOrDevice>();
foreach (BaseToolOrDevice item in allThings) foreach (BaseToolOrDevice item in allThings)
{ {
@ -82,9 +81,9 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
rec.toolId = item.itemInfo.toolId; rec.toolId = item.itemInfo.toolId;
rec.toolName = item.itemInfo.toolName; rec.toolName = item.itemInfo.toolName;
rec.triggerID = item.itemInfo.triggerID; rec.triggerID = item.itemInfo.triggerID;
rec.toolOrDeviceOrMaterial = item.itemInfo.toolOrDeviceOrMaterial; //rec.toolOrDeviceOrMaterial = item.itemInfo.toolOrDeviceOrMaterial;
rec.selfPosInToolRoom = item.itemInfo.selfPosInToolRoom; rec.selfPosInToolRoom = item.itemInfo.selfPosInToolRoom;
currentSceneTools.Add(rec); UserExamStat.currentSceneTools.Add(rec);
} }
//转换为JSON //转换为JSON
string UserJson = JsonConvert.SerializeObject(UserExamStat, Formatting.Indented); string UserJson = JsonConvert.SerializeObject(UserExamStat, Formatting.Indented);
@ -119,6 +118,29 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
} }
} }
/// <summary>
/// »Ö¸´ÏÖ³¡
/// </summary>
public void RecoverScene()
{
ScenesManager.Instance.LoadSceneAsyn(UserExamStat.sceneName, () => {
BaseToolOrDevice[] allThings = FindObjectsOfType<BaseToolOrDevice>();
foreach (BaseToolOrDevice item in allThings)
{
item.gameObject.SetActive(false);
foreach (ReconnetItemInfo rec in UserExamStat.currentSceneTools)
{
if (item.itemInfo.toolName.Equals(rec.toolName) && item.itemInfo.toolId == rec.toolId)
{
if (item.itemInfo.selfPosInToolRoom.Equals(rec.selfPosInToolRoom))
{
item.gameObject.SetActive(true);
}
}
}
}
});
}
// Start is called before the first frame update // Start is called before the first frame update
//void Start() //void Start()
//{ //{
@ -137,7 +159,7 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
else if(Input.GetKeyDown(KeyCode.R)) else if(Input.GetKeyDown(KeyCode.R))
{ {
RealtimeStatReader(); RealtimeStatReader();
ScenesManager.Instance.LoadScene(UserExamStat.sceneName); RecoverScene();
/*ProcessManager.Instance.HandoverProcess(UserExamStat.processId, UserExamStat.subProcessId, UserExamStat.subProcessStepId); /*ProcessManager.Instance.HandoverProcess(UserExamStat.processId, UserExamStat.subProcessId, UserExamStat.subProcessStepId);
StepStateControl.instance.InvokeInitStepState(GameManager.Instance.systemId, GameManager.ProcessMgr.d_Scheme.id, UserExamStat.subProcessId); StepStateControl.instance.InvokeInitStepState(GameManager.Instance.systemId, GameManager.ProcessMgr.d_Scheme.id, UserExamStat.subProcessId);
GameManager.EventMgr.EventTrigger<int>(Enum_EventType.SwitchSubProcess, UserExamStat.subProcessId); GameManager.EventMgr.EventTrigger<int>(Enum_EventType.SwitchSubProcess, UserExamStat.subProcessId);

View File

@ -0,0 +1,210 @@
{
"allToolAndMaterial": [
"国网安全帽",
"工作服"
],
"allWear": [],
"sceneName": "04_ToolMaterialScene",
"currentSceneTools": [
{
"toolId": 5008,
"triggerID": 5008,
"toolName": "国网安全帽",
"selfPosInToolRoom": {
"x": 0.263,
"y": 1.60900009,
"z": -1.369
}
},
{
"toolId": 5003,
"triggerID": 5003,
"toolName": "绝缘螺丝刀",
"selfPosInToolRoom": {
"x": -3.22629857,
"y": 1.129,
"z": -1.12697673
}
},
{
"toolId": 5015,
"triggerID": 5015,
"toolName": "盒装封印",
"selfPosInToolRoom": {
"x": 0.305,
"y": 1.556,
"z": -3.328
}
},
{
"toolId": 5010,
"triggerID": 5010,
"toolName": "绝缘手套",
"selfPosInToolRoom": {
"x": 0.265,
"y": 0.6700001,
"z": -1.387
}
},
{
"toolId": 5017,
"triggerID": 5017,
"toolName": "三相四线电能表",
"selfPosInToolRoom": {
"x": -3.2316,
"y": 1.1067,
"z": -2.258
}
},
{
"toolId": 5002,
"triggerID": 5002,
"toolName": "剥线钳",
"selfPosInToolRoom": {
"x": -3.1648,
"y": 0.217400074,
"z": -0.731
}
},
{
"toolId": 5004,
"triggerID": 5004,
"toolName": "验电笔",
"selfPosInToolRoom": {
"x": -3.212,
"y": 1.128,
"z": -0.672
}
},
{
"toolId": 5009,
"triggerID": 5009,
"toolName": "工作服",
"selfPosInToolRoom": {
"x": 0.311,
"y": 1.1358,
"z": -1.381
}
},
{
"toolId": 5015,
"triggerID": 5015,
"toolName": "盒装封印",
"selfPosInToolRoom": {
"x": 0.305,
"y": 1.556,
"z": -3.808
}
},
{
"toolId": 5003,
"triggerID": 5003,
"toolName": "绝缘螺丝刀",
"selfPosInToolRoom": {
"x": -3.223,
"y": 1.124,
"z": -1.649
}
},
{
"toolId": 5004,
"triggerID": 5004,
"toolName": "验电笔",
"selfPosInToolRoom": {
"x": -3.21036649,
"y": 1.1167,
"z": -0.173
}
},
{
"toolId": 5017,
"triggerID": 5017,
"toolName": "三相四线电能表",
"selfPosInToolRoom": {
"x": -3.2316,
"y": 1.1067,
"z": -2.7405
}
},
{
"toolId": 5002,
"triggerID": 5002,
"toolName": "剥线钳",
"selfPosInToolRoom": {
"x": -3.1648,
"y": 0.217400074,
"z": -0.189
}
},
{
"toolId": 5010,
"triggerID": 5010,
"toolName": "绝缘手套",
"selfPosInToolRoom": {
"x": 0.265,
"y": 0.6700001,
"z": -1.849
}
},
{
"toolId": 5014,
"triggerID": 5014,
"toolName": "工作证",
"selfPosInToolRoom": {
"x": 0.238,
"y": 1.134,
"z": -3.807
}
},
{
"toolId": 5011,
"triggerID": 5011,
"toolName": "绝缘靴",
"selfPosInToolRoom": {
"x": 0.315,
"y": 0.207000017,
"z": -1.377
}
},
{
"toolId": 5014,
"triggerID": 5014,
"toolName": "工作证",
"selfPosInToolRoom": {
"x": 0.238,
"y": 1.134,
"z": -3.353
}
},
{
"toolId": 5016,
"triggerID": 5016,
"toolName": "绝缘胶带",
"selfPosInToolRoom": {
"x": 0.281,
"y": 1.55870008,
"z": -4.595
}
},
{
"toolId": 5016,
"triggerID": 5016,
"toolName": "绝缘胶带",
"selfPosInToolRoom": {
"x": 0.281,
"y": 1.55870008,
"z": -4.202
}
},
{
"toolId": 5011,
"triggerID": 5011,
"toolName": "绝缘靴",
"selfPosInToolRoom": {
"x": 0.315,
"y": 0.207000017,
"z": -1.852
}
}
]
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 07217e8cebb016f498b20710d61dc605
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: