diff --git a/Assets/Scripts/ExcelData/DataContainer/TB_UserExamStat.cs b/Assets/Scripts/ExcelData/DataContainer/TB_UserExamStat.cs index 168dd65..ba46a96 100644 --- a/Assets/Scripts/ExcelData/DataContainer/TB_UserExamStat.cs +++ b/Assets/Scripts/ExcelData/DataContainer/TB_UserExamStat.cs @@ -6,9 +6,20 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +//用于记录现场中各项出发物品信息 +[Serializable] +public class ReconnectTriggerInfo +{ + public int triggerID; + public string triggerName; + public Vector3 selfPosInScene; + public Vector3 selfRotInScene; +} + + //用于记录场景中物品的信息 [Serializable] -public class ReconnetItemInfo +public class ReconnectItemInfo { public int toolId; public int triggerID; @@ -38,9 +49,13 @@ public class TB_UserExamStat /// public string sceneName = ""; + /// + /// 当前场景内的所有装备和材料 + /// + public List currentSceneTools = new List(); + /// /// 当前场景内的所有可触发物品 /// - public List currentSceneTools = new List(); - + public List currentSceneTriggers = new List(); } diff --git a/Assets/Scripts/Project/Manager/ProcessManager.cs b/Assets/Scripts/Project/Manager/ProcessManager.cs index 3cfd8d6..6039203 100644 --- a/Assets/Scripts/Project/Manager/ProcessManager.cs +++ b/Assets/Scripts/Project/Manager/ProcessManager.cs @@ -328,7 +328,7 @@ public class ProcessManager : BaseManager if (countDown_AutoSave <= 0) { ReconnectMgr.Instance.RealtimeStatWriter();//闇瑕佸湪GameManager閲岄潰鍒濆鍖 - Debug.Log("瀹屾垚鐘舵佽嚜鍔ㄤ繚瀛"); + //Debug.Log("瀹屾垚鐘舵佽嚜鍔ㄤ繚瀛"); countDown_AutoSave = time; } } diff --git a/Assets/Scripts/Project/Manager/ReconnectMgr.cs b/Assets/Scripts/Project/Manager/ReconnectMgr.cs index 1004c70..13eeb91 100644 --- a/Assets/Scripts/Project/Manager/ReconnectMgr.cs +++ b/Assets/Scripts/Project/Manager/ReconnectMgr.cs @@ -76,8 +76,8 @@ public class ReconnectMgr : SingletonMono BaseToolOrDevice[] allThings = FindObjectsOfType(); foreach (BaseToolOrDevice item in allThings) { - Debug.Log(item.itemInfo.toolName); - ReconnetItemInfo rec = new ReconnetItemInfo(); + //Debug.Log(item.itemInfo.toolName); + ReconnectItemInfo rec = new ReconnectItemInfo(); rec.toolId = item.itemInfo.toolId; rec.toolName = item.itemInfo.toolName; rec.triggerID = item.itemInfo.triggerID; @@ -87,15 +87,21 @@ public class ReconnectMgr : SingletonMono } //获取场景内(现场)所有可以出发的装置 + UserExamStat.currentSceneTriggers.Clear(); PermanentTriggerBase[] allPermanentTriggers = FindObjectsOfType(); foreach (PermanentTriggerBase item in allPermanentTriggers) { - Debug.Log("场景内涉及的物品:" + item.gameObject.name); + ReconnectTriggerInfo ret = new ReconnectTriggerInfo(); + ret.triggerName = item.triggerName; + ret.triggerID = item.triggerID; + ret.selfPosInScene = item.transform.localPosition; + ret.selfRotInScene = item.transform.localEulerAngles; + UserExamStat.currentSceneTriggers.Add(ret); } //转换为JSON string UserJson = JsonConvert.SerializeObject(UserExamStat, Formatting.Indented); - Debug.Log("用户当前状态" + UserJson); + Debug.Log("自动保存成功"); File.WriteAllText(localStatPath, UserJson); } @@ -140,13 +146,14 @@ public class ReconnectMgr : SingletonMono foreach (BaseToolOrDevice item in allThings) { item.gameObject.SetActive(false);//先全部隐藏 - foreach (ReconnetItemInfo rec in UserExamStat.currentSceneTools) + foreach (ReconnectItemInfo 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); + break; } } } @@ -165,6 +172,24 @@ public class ReconnectMgr : SingletonMono { PacksackBagMgr.Instance.WearItemState(item, true); } + + //恢复场景内各个触发器状态 + PermanentTriggerBase[] allPermanentTriggers = FindObjectsOfType(); + List allReconTrigs = UserExamStat.currentSceneTriggers; + foreach (PermanentTriggerBase item in allPermanentTriggers) + { + item.gameObject.SetActive(false); + foreach (ReconnectTriggerInfo ret in allReconTrigs) + { + if (item.triggerName == ret.triggerName) + { + item.gameObject.SetActive(true); + item.transform.localPosition = ret.selfPosInScene; + item.transform.localEulerAngles = ret.selfRotInScene; + break; + } + } + } }); } // Start is called before the first frame update