This commit is contained in:
YangHua 2024-09-04 11:58:24 +08:00
commit 0a524559a7
12 changed files with 244 additions and 72 deletions

View File

@ -6229,7 +6229,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6589deeaefa4a17428d6c3ce0d699c77, type: 3}
m_Name:
m_EditorClassIdentifier:
device_Control: {fileID: 0}
device_Control: {fileID: 1723332379}
--- !u!114 &1577392988 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5948617165317844720, guid: c80ccdb516dbab94083bd57fa1650eda, type: 3}
@ -6493,7 +6493,7 @@ MonoBehaviour:
- {fileID: 302277748}
- {fileID: 302277752}
- {fileID: 1352022184}
dianCollider: {fileID: 478648694}
dianTrigger: {fileID: 0}
sundries: {fileID: 737359439}
inSwitchScrews:
- {fileID: 1775693151}

View File

@ -5469,7 +5469,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6589deeaefa4a17428d6c3ce0d699c77, type: 3}
m_Name:
m_EditorClassIdentifier:
device_Control: {fileID: 0}
device_Control: {fileID: 1723332379}
--- !u!114 &1577392988 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5948617165317844720, guid: c80ccdb516dbab94083bd57fa1650eda, type: 3}

View File

@ -2,6 +2,7 @@ using DG.Tweening;
using Sirenix.Utilities;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/// <summary>
@ -202,6 +203,7 @@ public class Device_3Phase4WireMeter : Device_Base
{
transform.parent = device_MeasuringCabinet.transform;
device_MeasuringCabinet.meteringDevice = this;
transform.GetComponentsInChildren<PermanentTriggerBase>(true).ToList().ForEach(a => a.Awake());
//默认是拆除的状态
Init(false);
hand_out_action?.Invoke();

View File

@ -134,12 +134,14 @@ public class Device_Cover : Device_Base
if (obj == null)
{
//收回
cover_seal_left_Trigger.gameObject.SetActive(false);
Debug.Log("收回");
cover_seal_left_Trigger.gameObject.SetActive(false);
cover_seal_right_Trigger.gameObject.SetActive(false);
}
else
{
//拿出
Debug.Log("拿出");
if (obj.name == "盒装封印")
{
if (!isOpen && cover_seal_Left.isCut && cover_screw_Left.isInstall)
@ -200,13 +202,4 @@ public class Device_Cover : Device_Base
});
}
}
private void OnDestroy()
{
EventCenter.Instance.RemoveEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, CheckTriggerShow);
}
private void OnDisable()
{
EventCenter.Instance.RemoveEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, CheckTriggerShow);
}
}

View File

@ -49,12 +49,13 @@ public class Device_Control_1002 : Device_Control
private void Awake()
{
//设置控制脚本
StepStateControl.instance.SetDeviceControl(1002,this);
AddActions();
//if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
// GameManager.EventMgr.AddEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
sundries.gameObject.SetActive(false);
ScoreManager.instance.SetDeviceControl(1002,this);
AddActions();
sundries.gameObject.SetActive(false);
check_JieXian.tool_Lines = jieXian_lines;
check_JieXian.tool_Screws = meteringDevice.jieXian_screws;
@ -131,17 +132,7 @@ public class Device_Control_1002 : Device_Control
});
});
}
//private void SwitchSubProcessStepTriggerID(string arg0)
//{
// if (dianTrigger.triggerName == arg0)
// {
// dianTrigger.GetComponent<HighlightEffect>().SetHighlighted(true);
// }
// else
// {
// dianTrigger.GetComponent<HighlightEffect>().SetHighlighted(false);
// }
//}
/// <summary>
/// »¹Ô­¼ÆÁ¿¹ñ״̬
/// </summary>
@ -286,15 +277,4 @@ public class Device_Control_1002 : Device_Control
}
}
}
//private void OnDestroy()
//{
// if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
// GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
//}
//private void OnDisable()
//{
// if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
// GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
//}
}

View File

@ -23,6 +23,16 @@ public class ScoreManager : MonoBehaviour
a.Init();
});
}
/// <summary>
/// 设置控制脚本
/// </summary>
/// <param name="subejctid"></param>
/// <param name="control"></param>
public void SetDeviceControl(int subejctid, Device_Control control)
{
scoreSubjectList.Find(a => a.schemeId == subejctid).SetDeviceControl(control);
}
/// <summary>
/// 检测分数
/// </summary>

View File

@ -1,6 +1,7 @@
using Cysharp.Threading.Tasks.Triggers;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/// <summary>
@ -17,5 +18,7 @@ public class SiteManager : MonoBehaviour
private void Awake()
{
instance = this;
//基类全部初始化
device_Control.transform.GetComponentsInChildren<PermanentTriggerBase>(true).ToList().ForEach(a=>a.Awake());
}
}

View File

@ -1,27 +1,78 @@
/// <summary>
/// 保存用户考试状态
/// </summary>
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//用于记录当前得分情况
[Serializable]
public class ReconnectSubScoreInfo
{
public int index = -1;
public int subProcessId;
public float currentScore = 0.0f;
public bool isDone;
}
//用于记录现场中各项出发物品信息
[Serializable]
public class ReconnectTriggerInfo
{
public int triggerID;
public string triggerName;
public Vector3 selfPosInScene;
public Vector3 selfRotInScene;
}
//用于记录场景中物品的信息
[Serializable]
public class ReconnectItemInfo
{
public int toolId;
public int triggerID;
public string toolName;
//public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
public Vector3 selfPosInToolRoom;
}
public class TB_UserExamStat
{
/// <summary>
///当前方案ID
/// </summary>
public int schemeID = -1;
public int systemID = -1;//当前系统ID
public int schemeID = -1;//当前方案ID
/*public int processId = -1;// 当前流程Id
public int subProcessId = -1;//当前子流程Id
public int subProcessStepId = -1;//当前子流程步骤Id*/
/// <summary>
/// 当前流程Id
/// 当前得分情况
/// </summary>
public int processId = -1;
public float currentScore = 0;
public List<ReconnectSubScoreInfo> allSubScore = new List<ReconnectSubScoreInfo>();
/// <summary>
/// 当前子流程Id
/// 背包中所有的工具和材料
/// </summary>
public int subProcessId = -1;
public List<string> allToolAndMaterial = new List<string>();
/// <summary>
/// 当前子流程步骤Id
/// 所有已经穿戴的装备
/// </summary>
public int subProcessStepId = -1;
public List<string> allWear = new List<string>();
/// <summary>
/// 场景名称
/// </summary>
public string sceneName = "";
/// <summary>
/// 当前场景内的所有装备和材料
/// </summary>
public List<ReconnectItemInfo> currentSceneTools = new List<ReconnectItemInfo>();
/// <summary>
/// 当前场景内的所有可触发物品
/// </summary>
public List<ReconnectTriggerInfo> currentSceneTriggers = new List<ReconnectTriggerInfo>();
}

View File

@ -126,7 +126,7 @@ public class GameManager : SingletonAutoMono<GameManager>
RunModelMgr = RunModelMgr.Instance;
ToolAndmaterialMgr = ToolAndmaterialMgr.Instance;
PacksackBagMgr = PacksackBagMgr.Instance;
//ReconnectMgr = ReconnectMgr.Instance;//重连管理初始化
ReconnectMgr = ReconnectMgr.Instance;//重连管理初始化
DataMgr.Init();
InitData();

View File

@ -80,8 +80,8 @@ public class ProcessManager : BaseManager<ProcessManager>
{
this.schemeID = id;
this.mode = mode;
coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
//coroutine = GameManager.MonoMgr.StartCoroutine(AutoSaveStat(countDown));//自动保存用户状态信息
//coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
coroutine = GameManager.MonoMgr.StartCoroutine(AutoSaveStat(countDown));//自动保存用户状态信息
d_Scheme = DataManager.Instance.GetSchemeData(id);
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
GameManager.ToolAndmaterialMgr.Init(d_Scheme.ToolOrMaterilOrDevice);

View File

@ -1,11 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using LitJson;
using System;
/// <summary>
/// 断线重连管理
@ -18,6 +18,7 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
private TB_UserExamStat UserExamStat = new TB_UserExamStat();
private string localStatPath = "";
private string localStatFileName = "realtimeStat.json";
/// <summary>
/// 初始化函数,记录时间间隔
/// </summary>
@ -42,13 +43,81 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
{
//记录步骤相关各项信息
UserExamStat.schemeID = ProcessManager.Instance.schemeID;
UserExamStat.processId = ProcessManager.Instance.processId;
//记录得分情况
ScoreBase scoreBase = FindFirstObjectByType<ScoreBase>();
UserExamStat.systemID = scoreBase.systemId;
UserExamStat.allSubScore.Clear();
if ( scoreBase != null )
{
foreach (var item in scoreBase.GetStepScore())
{
ReconnectSubScoreInfo sub = new ReconnectSubScoreInfo();
sub.index = item.Key;
sub.subProcessId = item.Value.subProcessId;
sub.currentScore = item.Value.currentScore;
sub.isDone = item.Value.isDone;
UserExamStat.allSubScore.Add( sub );
};
}
/*UserExamStat.processId = ProcessManager.Instance.processId;
UserExamStat.subProcessId = ProcessManager.Instance.subProcessId;
UserExamStat.subProcessStepId = ProcessManager.Instance.subProcessStepId;
UserExamStat.subProcessStepId = ProcessManager.Instance.subProcessStepId;*/
//记录装备材料信息
UserExamStat.allToolAndMaterial.Clear();
Dictionary<string, List<ItemInfo>> toolAndMaterialDic = PacksackBagMgr.Instance.GetCurrentBagData();
foreach (var item in toolAndMaterialDic)
{
foreach (var itemInfo in item.Value)
{
UserExamStat.allToolAndMaterial.Add(((ItemInfo)itemInfo).toolName);
}
}
//记录已穿戴设备
UserExamStat.allWear.Clear();
Dictionary<string, ItemInfo> wearDic = PacksackBagMgr.Instance.wearDic;
foreach (var item in wearDic)
{
UserExamStat.allWear.Add(((ItemInfo)item.Value).toolName);
}
//获取当前所加载场景的名字
UserExamStat.sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
//获取场景内(工具间)所有可以装备材料的物品
UserExamStat.currentSceneTools.Clear();
BaseToolOrDevice[] allThings = FindObjectsOfType<BaseToolOrDevice>();
foreach (BaseToolOrDevice item in allThings)
{
//Debug.Log(item.itemInfo.toolName);
ReconnectItemInfo rec = new ReconnectItemInfo();
rec.toolId = item.itemInfo.toolId;
rec.toolName = item.itemInfo.toolName;
rec.triggerID = item.itemInfo.triggerID;
//rec.toolOrDeviceOrMaterial = item.itemInfo.toolOrDeviceOrMaterial;
rec.selfPosInToolRoom = item.itemInfo.selfPosInToolRoom;
UserExamStat.currentSceneTools.Add(rec);
}
//获取场景内(现场)所有可以出发的装置
UserExamStat.currentSceneTriggers.Clear();
PermanentTriggerBase[] allPermanentTriggers = FindObjectsOfType<PermanentTriggerBase>();
foreach (PermanentTriggerBase item in allPermanentTriggers)
{
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);
}
@ -65,7 +134,6 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
string user_last_stat = sr.ReadToEnd();
sr.Close();
UserExamStat = JsonMapper.ToObject<TB_UserExamStat>(user_last_stat);
Debug.Log("用户当前schemeID:" + UserExamStat.schemeID);
return true;
}
catch (System.Exception e)
@ -79,28 +147,83 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
}
}
// Start is called before the first frame update
//void Start()
//{
//}
/// <summary>
/// 恢复现场
/// </summary>
public void RecoverScene()
{
//先恢复场景
ScenesManager.Instance.LoadSceneAsyn(UserExamStat.sceneName, () => {
//右侧工具栏切换
GameManager.EventMgr.EventTrigger(Enum_EventType.SwitchScene, GameManager.RunModelMgr.SceneType);
//恢复场景中各项装备
BaseToolOrDevice[] allThings = FindObjectsOfType<BaseToolOrDevice>();
foreach (BaseToolOrDevice item in allThings)
{
item.gameObject.SetActive(false);//先全部隐藏
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;
}
}
}
}
//恢复背包中的装备
List<ItemInfo> itemInPack = ToolAndmaterialMgr.Instance.CreateItemInfoByName(UserExamStat.allToolAndMaterial);
foreach (ItemInfo item in itemInPack)
{
PacksackBagMgr.Instance.AddOneToolOrMater(item);
}
//恢复已穿戴的装备
List<ItemInfo> itemWear = ToolAndmaterialMgr.Instance.CreateItemInfoByName(UserExamStat.allWear);
foreach (ItemInfo item in itemWear)
{
PacksackBagMgr.Instance.WearItemState(item, true);
}
//恢复场景内各个触发器状态
PermanentTriggerBase[] allPermanentTriggers = FindObjectsOfType<PermanentTriggerBase>();
List<ReconnectTriggerInfo> 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;
}
}
}
});
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.S))//测试用,按S读取状态保存
if (Input.GetKeyDown(KeyCode.T))//测试用,按T读取状态保存
{
RealtimeStatWriter();
Debug.Log("当前场景:" + UserExamStat.sceneName);
}
else if(Input.GetKeyDown(KeyCode.R))
else if(Input.GetKeyDown(KeyCode.Y))
{
RealtimeStatReader();
ProcessManager.Instance.HandoverProcess(UserExamStat.processId, UserExamStat.subProcessId, UserExamStat.subProcessStepId);
RecoverScene();
/*ProcessManager.Instance.HandoverProcess(UserExamStat.processId, UserExamStat.subProcessId, UserExamStat.subProcessStepId);
StepStateControl.instance.InvokeInitStepState(GameManager.Instance.systemId, GameManager.ProcessMgr.d_Scheme.id, UserExamStat.subProcessId);
GameManager.EventMgr.EventTrigger<int>(Enum_EventType.SwitchSubProcess, UserExamStat.subProcessId);
//Debug.LogError(ProcessManager.Instance.subProcessStepTriggerID);
GameManager.EventMgr.EventTrigger<string>(Enum_EventType.SwitchSubProcessStepTriggerID, ProcessManager.Instance.subProcessStepTriggerID);
GameManager.EventMgr.EventTrigger<string>(Enum_EventType.SwitchSubProcessStepTriggerID, ProcessManager.Instance.subProcessStepTriggerID);*/
}
}
}

View File

@ -4,6 +4,7 @@ using UnityEngine;
using HighlightPlus;
using UnityEngine.EventSystems;
using System;
using Unity.VisualScripting;
/// <summary>
/// 常驻交互
@ -26,11 +27,20 @@ public class PermanentTriggerBase : MonoBehaviour
/// 收回手里的回调
/// </summary>
protected Action hand_back_action;
/// <summary>
/// 是否初始化了
/// </summary>
private bool isInit;
private void Awake()
public void Awake()
{
OnAwake();
AddScoreAction(ScoreManager.instance.Check);
if (!isInit)
{
isInit = true;
OnAwake();
AddScoreAction(ScoreManager.instance.Check);
}
}
private void Start()