From 9ed39a938289c2d96f797440ee6f6e829e24a87b Mon Sep 17 00:00:00 2001 From: yzx Date: Mon, 24 Jun 2024 17:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/JunctionBox.cs | 5 +- .../Assets/Scenes/Start.unity | 4 + .../Assets/Scenes/单独.unity | 6 +- .../Assets/Scenes/工具间Scenes/工具间.unity | 69 ----------- .../ProcessMode/AnimationProcessManager.cs | 114 +++++++++--------- .../FaultRecords/FaultRecords.json | 3 - 6 files changed, 66 insertions(+), 135 deletions(-) diff --git a/SXElectricityInformationAcquisition/Assets/JunctionBox.cs b/SXElectricityInformationAcquisition/Assets/JunctionBox.cs index f13eb046..066cae3c 100644 --- a/SXElectricityInformationAcquisition/Assets/JunctionBox.cs +++ b/SXElectricityInformationAcquisition/Assets/JunctionBox.cs @@ -68,9 +68,8 @@ public class JunctionBox : MonoBehaviour originalPosition.Add(GameObjectSlider[i].transform.localPosition); //originalRotation = GameObjectSlider[i].transform.localRotation; } - } - + /// /// Ƿ /// @@ -97,7 +96,7 @@ public class JunctionBox : MonoBehaviour // } // } //} - + void Update() { if (Input.GetMouseButtonDown(0)) diff --git a/SXElectricityInformationAcquisition/Assets/Scenes/Start.unity b/SXElectricityInformationAcquisition/Assets/Scenes/Start.unity index 52efa095..7bb1702a 100644 --- a/SXElectricityInformationAcquisition/Assets/Scenes/Start.unity +++ b/SXElectricityInformationAcquisition/Assets/Scenes/Start.unity @@ -259,6 +259,10 @@ PrefabInstance: propertyPath: m_Name value: APP objectReference: {fileID: 0} + - target: {fileID: 6053353591068959239, guid: fa12b84946083d14cb4447029910be28, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 6205274277508386708, guid: fa12b84946083d14cb4447029910be28, type: 3} propertyPath: m_Interactable value: 1 diff --git a/SXElectricityInformationAcquisition/Assets/Scenes/单独.unity b/SXElectricityInformationAcquisition/Assets/Scenes/单独.unity index 3d5d7b31..7a8a9d7a 100644 --- a/SXElectricityInformationAcquisition/Assets/Scenes/单独.unity +++ b/SXElectricityInformationAcquisition/Assets/Scenes/单独.unity @@ -8998,7 +8998,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8322912254063910965, guid: 8a244cdd2f00e534aadd2512c3bbfda1, type: 3} propertyPath: m_LocalPosition.y - value: -15.841 + value: -15.151 objectReference: {fileID: 0} - target: {fileID: 8322912254063910965, guid: 8a244cdd2f00e534aadd2512c3bbfda1, type: 3} propertyPath: m_LocalPosition.z @@ -18567,7 +18567,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &839913787 RectTransform: m_ObjectHideFlags: 0 @@ -23400,7 +23400,7 @@ Light: serializedVersion: 10 m_Type: 1 m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 1} m_Intensity: 1 m_Range: 10 m_SpotAngle: 30 diff --git a/SXElectricityInformationAcquisition/Assets/Scenes/工具间Scenes/工具间.unity b/SXElectricityInformationAcquisition/Assets/Scenes/工具间Scenes/工具间.unity index 0cd90c80..0c6b18f7 100644 --- a/SXElectricityInformationAcquisition/Assets/Scenes/工具间Scenes/工具间.unity +++ b/SXElectricityInformationAcquisition/Assets/Scenes/工具间Scenes/工具间.unity @@ -25132,74 +25132,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1807550687} m_CullTransparentMesh: 1 ---- !u!1 &1810945299 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1810945302} - - component: {fileID: 1810945301} - - component: {fileID: 1810945300} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1810945300 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1810945299} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &1810945301 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1810945299} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &1810945302 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1810945299} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1812223123 GameObject: m_ObjectHideFlags: 0 @@ -29607,7 +29539,6 @@ SceneRoots: - {fileID: 843085103} - {fileID: 27506717} - {fileID: 1703800128} - - {fileID: 1810945302} - {fileID: 505215069} - {fileID: 450266584} - {fileID: 25011097} diff --git a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs index 1d5e46e1..f80155ab 100644 --- a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs +++ b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs @@ -16,15 +16,15 @@ namespace DefaultNamespace.ProcessMode [ScriptDescription("流程模式管理器")] public class AnimationProcessManager : ModuleSingleton, IModule { - private Dictionary processes = new Dictionary(); - public ProcessMode currentMode; // 当前模式 - private int currentStepIndex; // 当前步骤索引 - private int currentActionIndex; // 当前动作索引,确保动作顺序 - private int currentActionGameIndex; // 当前动作索引,确保动作顺序 - private Dictionary> incorrectClicksPerStep; // 每个步骤的错误点击记录 + private Dictionary _processes = new Dictionary(); + private ProcessMode _currentMode; // 当前模式 + private int _currentStepIndex; // 当前步骤索引 + private int _currentActionIndex; // 当前动作索引,确保动作顺序 + private int _currentActionGameIndex; // 当前动作索引,确保动作顺序 + private Dictionary> _incorrectClicksPerStep; // 每个步骤的错误点击记录 private SceneStepData _sceneStepData; - public AnimationProcess CurrentProcess => processes[currentMode.ToString()]; + public AnimationProcess CurrentProcess => _processes[_currentMode.ToString()]; public delegate void CompleteEventHandler(); @@ -52,15 +52,15 @@ namespace DefaultNamespace.ProcessMode // Enum.TryParse(type, true, out currentMode); // } - processes[type] = new AnimationProcess(type); - Enum.TryParse(type, true, out currentMode); + _processes[type] = new AnimationProcess(type); + Enum.TryParse(type, true, out _currentMode); } public void AddStepToProcess(string type, AnimationStep step) { - if (processes.ContainsKey(type)) + if (_processes.ContainsKey(type)) { - processes[type].AddStep(step); + _processes[type].AddStep(step); } } @@ -71,27 +71,27 @@ namespace DefaultNamespace.ProcessMode /// 错误点击的物体 private void AddIncorrectClick(int stepIndex, string clickedObject) { - if (!incorrectClicksPerStep.ContainsKey(stepIndex)) + if (!_incorrectClicksPerStep.ContainsKey(stepIndex)) { - incorrectClicksPerStep[stepIndex] = new List(); + _incorrectClicksPerStep[stepIndex] = new List(); } - incorrectClicksPerStep[stepIndex].Add(clickedObject); + _incorrectClicksPerStep[stepIndex].Add(clickedObject); Debug.Log($"步骤 {stepIndex + 1} 错误点击的物体: {clickedObject}"); } public void HandleClick(string clickedObject) { - string type = currentMode.ToString(); + string type = _currentMode.ToString(); - if (processes.ContainsKey(type)) + if (_processes.ContainsKey(type)) { - AnimationProcess process = processes[type]; + AnimationProcess process = _processes[type]; - if (currentStepIndex < process.Steps.Count) + if (_currentStepIndex < process.Steps.Count) { - AnimationStep step = process.Steps[currentStepIndex]; - ActionWithDescription currentAction = step.Actions[currentActionIndex]; + AnimationStep step = process.Steps[_currentStepIndex]; + ActionWithDescription currentAction = step.Actions[_currentActionIndex]; if (currentAction.IsSequential) { @@ -101,7 +101,7 @@ namespace DefaultNamespace.ProcessMode { Debug.Log($"正确点击了:{clickedObject}"); - HandleModeFeedback(currentMode, currentAction); // 处理模式特定的反馈 + HandleModeFeedback(_currentMode, currentAction); // 处理模式特定的反馈 currentAction.CurrentObjectIndex++; // 正确点击,递增对象索引 currentAction.ClickedObjects.Add(clickedObject); // 添加到已点击对象集合 if (currentAction.CurrentObjectIndex >= currentAction.TargetObjects.Count) @@ -113,7 +113,7 @@ namespace DefaultNamespace.ProcessMode { string correctObjectName = currentAction.TargetObjects[currentAction.CurrentObjectIndex]; Debug.Log($"错误点击或顺序错误:{clickedObject}。正确的物体是:{correctObjectName}"); - AddIncorrectClick(currentStepIndex, clickedObject); + AddIncorrectClick(_currentStepIndex, clickedObject); } } else @@ -131,7 +131,7 @@ namespace DefaultNamespace.ProcessMode { Debug.Log($"正确点击了:{clickedObject}"); currentAction.ClickedObjects.Add(clickedObject); // 添加到已点击对象集合 - HandleModeFeedback(currentMode, currentAction); // 处理模式特定的反馈 + HandleModeFeedback(_currentMode, currentAction); // 处理模式特定的反馈 if (currentAction.ClickedObjects.Count >= currentAction.TargetObjects.Count) { @@ -153,7 +153,7 @@ namespace DefaultNamespace.ProcessMode string correctObjects = string.Join(",", correctObjectNames); Debug.Log($"正确的物体是:{correctObjects}"); - AddIncorrectClick(currentStepIndex, clickedObject); + AddIncorrectClick(_currentStepIndex, clickedObject); } } } @@ -167,21 +167,21 @@ namespace DefaultNamespace.ProcessMode /// 当前动作 private void CompleteAction(AnimationStep step, ActionWithDescription currentAction) { - Debug.Log($"完成了动作 {currentActionIndex + 1}"); - step.PlayAnimation(currentActionIndex); // 播放当前动作的动画 + Debug.Log($"完成了动作 {_currentActionIndex + 1}"); + step.PlayAnimation(_currentActionIndex); // 播放当前动作的动画 - currentActionIndex++; + _currentActionIndex++; currentAction.CurrentObjectIndex = 0; // 重置当前动作对象索引 currentAction.ClickedObjects.Clear(); // 重置已点击对象集合 currentAction.FeedbackDisplayed = false; // 重置反馈显示标志 - if (currentActionIndex >= step.Actions.Count) + if (_currentActionIndex >= step.Actions.Count) { Debug.Log("所有动作完成!"); - if (currentMode == ProcessMode.Practice) + if (_currentMode == ProcessMode.Practice) { - if (currentStepIndex < processes[currentMode.ToString()].Steps.Count) + if (_currentStepIndex < _processes[_currentMode.ToString()].Steps.Count) { // if (currentMode == ProcessMode.Practice) // { @@ -189,13 +189,13 @@ namespace DefaultNamespace.ProcessMode // HandleModeFeedback(currentMode, nextStep.Actions[0]); // 准备下一个步骤 // } - var nextStep = processes[currentMode.ToString()].Steps[currentStepIndex]; - HandleModeFeedback(currentMode, nextStep.Actions[0]); // 准备下一个步骤 + var nextStep = _processes[_currentMode.ToString()].Steps[_currentStepIndex]; + HandleModeFeedback(_currentMode, nextStep.Actions[0]); // 准备下一个步骤 - currentActionIndex = 0; // 重置动作索引或进入下一个大步骤 - currentStepIndex++; + _currentActionIndex = 0; // 重置动作索引或进入下一个大步骤 + _currentStepIndex++; - if (currentStepIndex == processes[currentMode.ToString()].Steps.Count) + if (_currentStepIndex == _processes[_currentMode.ToString()].Steps.Count) { CalculateTotalScore(); Debug.Log("全部完成了!!!!"); @@ -214,9 +214,9 @@ namespace DefaultNamespace.ProcessMode } else { - currentActionIndex = 0; // 重置动作索引或进入下一个大步骤 - currentStepIndex++; - if (currentStepIndex < processes[currentMode.ToString()].Steps.Count) + _currentActionIndex = 0; // 重置动作索引或进入下一个大步骤 + _currentStepIndex++; + if (_currentStepIndex < _processes[_currentMode.ToString()].Steps.Count) { // if (currentMode == ProcessMode.Practice) // { @@ -224,8 +224,8 @@ namespace DefaultNamespace.ProcessMode // HandleModeFeedback(currentMode, nextStep.Actions[0]); // 准备下一个步骤 // } - var nextStep = processes[currentMode.ToString()].Steps[currentStepIndex]; - HandleModeFeedback(currentMode, nextStep.Actions[0]); // 准备下一个步骤 + var nextStep = _processes[_currentMode.ToString()].Steps[_currentStepIndex]; + HandleModeFeedback(_currentMode, nextStep.Actions[0]); // 准备下一个步骤 } else { @@ -242,7 +242,7 @@ namespace DefaultNamespace.ProcessMode else { Debug.Log("开始下一个动作!"); - HandleModeFeedback(currentMode, step.Actions[currentActionIndex]); // 传递下一个动作对象 + HandleModeFeedback(_currentMode, step.Actions[_currentActionIndex]); // 传递下一个动作对象 } } @@ -382,9 +382,9 @@ namespace DefaultNamespace.ProcessMode /// 模式 public void SetCurrentMode(ProcessMode mode) { - currentMode = mode; - currentStepIndex = 0; - currentActionIndex = 0; + _currentMode = mode; + _currentStepIndex = 0; + _currentActionIndex = 0; } @@ -392,7 +392,7 @@ namespace DefaultNamespace.ProcessMode { if (nextStepOrAction is ActionWithDescription practiceAction) { - OnSendMessagePrompt(practiceAction.Description); + if (OnSendMessagePrompt != null) OnSendMessagePrompt(practiceAction.Description); Debug.Log($"练习模式:{practiceAction.Description}"); } } @@ -403,12 +403,12 @@ namespace DefaultNamespace.ProcessMode private void CalculateTotalScore() { float totalScore = 0; - foreach (var step in processes[currentMode.ToString()].Steps) + foreach (var step in _processes[_currentMode.ToString()].Steps) { - int stepIndex = processes[currentMode.ToString()].Steps.IndexOf(step); - if (incorrectClicksPerStep.ContainsKey(stepIndex)) + int stepIndex = _processes[_currentMode.ToString()].Steps.IndexOf(step); + if (_incorrectClicksPerStep.TryGetValue(stepIndex, out var value)) { - Debug.Log($"步骤 {stepIndex + 1} 错误点击的物体: {string.Join(", ", incorrectClicksPerStep[stepIndex])}"); + Debug.Log($"步骤 {stepIndex + 1} 错误点击的物体: {string.Join(", ", value)}"); } else { @@ -421,8 +421,8 @@ namespace DefaultNamespace.ProcessMode public void OnCreate(object createParam) { - processes = new Dictionary(); - incorrectClicksPerStep = new Dictionary>(); + _processes = new Dictionary(); + _incorrectClicksPerStep = new Dictionary>(); } public void OnUpdate() @@ -527,9 +527,9 @@ namespace DefaultNamespace.ProcessMode /// public void InitializeFirstStep() { - currentMode = MotionEngine.GetModule().GetProcessMode(); + _currentMode = MotionEngine.GetModule().GetProcessMode(); - AddProcess(currentMode.ToString()); + AddProcess(_currentMode.ToString()); string json = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/DataConfig/SceneStepData.json"); @@ -557,21 +557,21 @@ namespace DefaultNamespace.ProcessMode // AnimationStep step = new AnimationStep(stepData.StepDescription, _sceneStepData.taskList[0].stepList[index].defaultScore, actions); AnimationStep step = new AnimationStep(stepData.StepDescription,stepData.Score , actions); index++; - AddStepToProcess(currentMode.ToString(), step); + AddStepToProcess(_currentMode.ToString(), step); } //教学模式和培训模式需要初始化一下 - if (currentMode == ProcessMode.Teaching || currentMode == ProcessMode.Training) + if (_currentMode == ProcessMode.Teaching || _currentMode == ProcessMode.Training) { if (CurrentProcess.Steps.Count > 0) { AnimationStep firstStep = CurrentProcess.Steps[0]; if (firstStep.Actions.Count > 0) { - HandleModeFeedback(currentMode, firstStep.Actions[0]); + HandleModeFeedback(_currentMode, firstStep.Actions[0]); } } } @@ -580,7 +580,7 @@ namespace DefaultNamespace.ProcessMode public ProcessMode GetProcessMode() { - return currentMode; + return _currentMode; } } } \ No newline at end of file diff --git a/SXElectricityInformationAcquisition/Assets/StreamingAssets/FaultRecords/FaultRecords.json b/SXElectricityInformationAcquisition/Assets/StreamingAssets/FaultRecords/FaultRecords.json index 499c7320..de5245ca 100644 --- a/SXElectricityInformationAcquisition/Assets/StreamingAssets/FaultRecords/FaultRecords.json +++ b/SXElectricityInformationAcquisition/Assets/StreamingAssets/FaultRecords/FaultRecords.json @@ -38,9 +38,6 @@ }, { "content": "啊啥的啊啥的啊啥的" - }, - { - "content": "12312312" } ] } \ No newline at end of file