From c78c8a12d2422faf3b5a055f93b8f30fb26d1a5c Mon Sep 17 00:00:00 2001 From: taosuqi <2274240467@qq.com> Date: Wed, 12 Jun 2024 15:15:13 +0800 Subject: [PATCH] =?UTF-8?q?6.12=E4=B8=8B=E5=8D=88json=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/JunctionBox.cs | 1 - .../ProcessMode/AnimationProcessManager.cs | 148 ++++++++++-------- .../Assets/Scripts/ProcessMode/test.cs.meta | 10 +- .../StreamingAssets/DataConfig/StepData.json | 98 ++++++++++++ 4 files changed, 186 insertions(+), 71 deletions(-) diff --git a/SXElectricityInformationAcquisition/Assets/JunctionBox.cs b/SXElectricityInformationAcquisition/Assets/JunctionBox.cs index 1a77cc2f..ef9e32df 100644 --- a/SXElectricityInformationAcquisition/Assets/JunctionBox.cs +++ b/SXElectricityInformationAcquisition/Assets/JunctionBox.cs @@ -67,7 +67,6 @@ public class JunctionBox : MonoBehaviour if (AreAllObjectsHidden()) { TransparentlidObj.transform.DOLocalMove(new Vector3(0, -0.0914f, 0), 2f); - Debug.Log("所有对象都已隐藏"); } } public bool AreAllObjectsHidden() diff --git a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs index 437b85e1..28dd453e 100644 --- a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs +++ b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/AnimationProcessManager.cs @@ -34,96 +34,106 @@ namespace DefaultNamespace.ProcessMode } public void HandleClick(GameObject clickedObject) -{ - string type = currentMode.ToString(); - - if (processes.ContainsKey(type)) - { - AnimationProcess process = processes[type]; - - if (currentStepIndex < process.Steps.Count) { - AnimationStep step = process.Steps[currentStepIndex]; - ActionWithDescription currentAction = step.Actions[currentActionIndex]; + string type = currentMode.ToString(); - if (currentAction.IsSequential) + if (processes.ContainsKey(type)) { - // 鎸夐『搴忕偣鍑荤殑閫昏緫 - if (currentAction.CurrentObjectIndex < currentAction.TargetObjects.Count && - currentAction.TargetObjects[currentAction.CurrentObjectIndex] == clickedObject) + AnimationProcess process = processes[type]; + + if (currentStepIndex < process.Steps.Count) { - Debug.Log($"姝g‘鐐瑰嚮浜嗭細{clickedObject.name}"); - currentAction.CurrentObjectIndex++; // 姝g‘鐐瑰嚮锛岄掑瀵硅薄绱㈠紩 + AnimationStep step = process.Steps[currentStepIndex]; + ActionWithDescription currentAction = step.Actions[currentActionIndex]; - if (currentAction.CurrentObjectIndex >= currentAction.TargetObjects.Count) + if (currentAction.IsSequential) { - // 鎵鏈夊璞¢兘宸叉纭偣鍑伙紝瀹屾垚褰撳墠鍔ㄤ綔 - Debug.Log($"瀹屾垚浜嗗姩浣 {currentActionIndex + 1}"); - step.PlayAnimation(currentActionIndex); // 鎾斁褰撳墠鍔ㄤ綔鐨勫姩鐢 - DisplayActionFeedback(currentMode, currentAction); // 鏄剧ず鍙嶉 - - currentActionIndex++; - currentAction.CurrentObjectIndex = 0; // 閲嶇疆褰撳墠鍔ㄤ綔瀵硅薄绱㈠紩 - - if (currentActionIndex >= step.Actions.Count) + // 鎸夐『搴忕偣鍑荤殑閫昏緫 + if (currentAction.CurrentObjectIndex < currentAction.TargetObjects.Count && + currentAction.TargetObjects[currentAction.CurrentObjectIndex] == clickedObject) { - Debug.Log("鎵鏈夊姩浣滃畬鎴愶紒"); - currentActionIndex = 0; // 閲嶇疆鍔ㄤ綔绱㈠紩鎴栬繘鍏ヤ笅涓涓ぇ姝ラ - currentStepIndex++; + Debug.Log($"姝g‘鐐瑰嚮浜嗭細{clickedObject.name}"); + currentAction.CurrentObjectIndex++; // 姝g‘鐐瑰嚮锛岄掑瀵硅薄绱㈠紩 + + if (currentAction.CurrentObjectIndex >= currentAction.TargetObjects.Count) + { + // 鎵鏈夊璞¢兘宸叉纭偣鍑伙紝瀹屾垚褰撳墠鍔ㄤ綔 + Debug.Log($"瀹屾垚浜嗗姩浣 {currentActionIndex + 1}"); + step.PlayAnimation(currentActionIndex); // 鎾斁褰撳墠鍔ㄤ綔鐨勫姩鐢 + DisplayActionFeedback(currentMode, currentAction); // 鏄剧ず鍙嶉 + + currentActionIndex++; + currentAction.CurrentObjectIndex = 0; // 閲嶇疆褰撳墠鍔ㄤ綔瀵硅薄绱㈠紩 + + if (currentActionIndex >= step.Actions.Count) + { + Debug.Log("鎵鏈夊姩浣滃畬鎴愶紒"); + currentActionIndex = 0; // 閲嶇疆鍔ㄤ綔绱㈠紩鎴栬繘鍏ヤ笅涓涓ぇ姝ラ + currentStepIndex++; + } + else + { + Debug.Log("寮濮嬩笅涓涓姩浣滐紒"); + PrepareNextStep(currentMode, process, currentStepIndex); + } + } } else { - Debug.Log("寮濮嬩笅涓涓姩浣滐紒"); - PrepareNextStep(currentMode, process, currentStepIndex); + string correctObjectName = currentAction.TargetObjects[currentAction.CurrentObjectIndex].name; + Debug.Log($"閿欒鐐瑰嚮鎴栭『搴忛敊璇細{clickedObject.name}銆傛纭殑鐗╀綋鏄細{correctObjectName}"); } } - } - else - { - Debug.Log($"閿欒鐐瑰嚮鎴栭『搴忛敊璇細{clickedObject.name}"); - } - } - else - { - // 涓嶆寜椤哄簭鐐瑰嚮鐨勯昏緫 - if (currentAction.TargetObjects.Contains(clickedObject)) - { - if (!currentAction.ClickedObjects.Contains(clickedObject)) + else { - Debug.Log($"姝g‘鐐瑰嚮浜嗭細{clickedObject.name}"); - currentAction.ClickedObjects.Add(clickedObject); // 娣诲姞鍒板凡鐐瑰嚮瀵硅薄闆嗗悎 - - if (currentAction.ClickedObjects.Count >= currentAction.TargetObjects.Count) + // 涓嶆寜椤哄簭鐐瑰嚮鐨勯昏緫 + if (currentAction.TargetObjects.Contains(clickedObject)) { - Debug.Log($"瀹屾垚浜嗗姩浣 {currentActionIndex + 1}"); - step.PlayAnimation(currentActionIndex); // 鎾斁褰撳墠鍔ㄤ綔鐨勫姩鐢 - DisplayActionFeedback(currentMode, currentAction); // 鏄剧ず鍙嶉 - - currentActionIndex++; - currentAction.ClickedObjects.Clear(); // 閲嶇疆宸茬偣鍑诲璞¢泦鍚 - - if (currentActionIndex >= step.Actions.Count) + if (!currentAction.ClickedObjects.Contains(clickedObject)) { - Debug.Log("鎵鏈夊姩浣滃畬鎴愶紒"); - currentActionIndex = 0; // 閲嶇疆鍔ㄤ綔绱㈠紩鎴栬繘鍏ヤ笅涓涓ぇ姝ラ - currentStepIndex++; - } - else - { - Debug.Log("寮濮嬩笅涓涓姩浣滐紒"); - PrepareNextStep(currentMode, process, currentStepIndex); + Debug.Log($"姝g‘鐐瑰嚮浜嗭細{clickedObject.name}"); + currentAction.ClickedObjects.Add(clickedObject); // 娣诲姞鍒板凡鐐瑰嚮瀵硅薄闆嗗悎 + + if (currentAction.ClickedObjects.Count >= currentAction.TargetObjects.Count) + { + Debug.Log($"瀹屾垚浜嗗姩浣 {currentActionIndex + 1}"); + step.PlayAnimation(currentActionIndex); // 鎾斁褰撳墠鍔ㄤ綔鐨勫姩鐢 + DisplayActionFeedback(currentMode, currentAction); // 鏄剧ず鍙嶉 + + currentActionIndex++; + currentAction.ClickedObjects.Clear(); // 閲嶇疆宸茬偣鍑诲璞¢泦鍚 + + if (currentActionIndex >= step.Actions.Count) + { + Debug.Log("鎵鏈夊姩浣滃畬鎴愶紒"); + currentActionIndex = 0; // 閲嶇疆鍔ㄤ綔绱㈠紩鎴栬繘鍏ヤ笅涓涓ぇ姝ラ + currentStepIndex++; + } + else + { + Debug.Log("寮濮嬩笅涓涓姩浣滐紒"); + PrepareNextStep(currentMode, process, currentStepIndex); + } + } } } + else + { + List correctObjectNames = new List(); + foreach (var obj in currentAction.TargetObjects) + { + if (!currentAction.ClickedObjects.Contains(obj)) + { + correctObjectNames.Add(obj.name); + } + } + string correctObjects = string.Join(", ", correctObjectNames); + Debug.Log($"閿欒鐐瑰嚮锛歿clickedObject.name} 姝g‘鐨勭墿浣撴槸锛歿correctObjects}"); + } } } - else - { - Debug.Log($"閿欒鐐瑰嚮锛歿clickedObject.name}"); - } } } - } -} diff --git a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/test.cs.meta b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/test.cs.meta index f7baaeed..3c13d076 100644 --- a/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/test.cs.meta +++ b/SXElectricityInformationAcquisition/Assets/Scripts/ProcessMode/test.cs.meta @@ -1,3 +1,11 @@ fileFormatVersion: 2 guid: 51f73ee94f284a86b677a6bc74544094 -timeCreated: 1717740090 \ No newline at end of file +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/SXElectricityInformationAcquisition/Assets/StreamingAssets/DataConfig/StepData.json b/SXElectricityInformationAcquisition/Assets/StreamingAssets/DataConfig/StepData.json index 51dc5b1d..187f5c3d 100644 --- a/SXElectricityInformationAcquisition/Assets/StreamingAssets/DataConfig/StepData.json +++ b/SXElectricityInformationAcquisition/Assets/StreamingAssets/DataConfig/StepData.json @@ -1,5 +1,86 @@ { "steps": [ + { + "stepDescription": "姝ラ 1 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "浣跨敤楠岀數绗旇繘琛屼笁姝ラ獙鐢垫硶锛氱偣鍑绘彃搴р斺旂偣鍑绘煖闂ㄢ斺旂偣鍑绘彃搴с", + "score": 0, + "isSequential": true, + "targetObjects": [ + "鎻掑骇", + "鍙樼數绠盻闂", + "鎻掑骇" + ] + } + ] + }, + { + "stepDescription": "姝ラ 2 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "鐢ㄩ挸鍒鍓紑鏌滈棬灏佸嵃锛屾墦寮鏌滈棬銆", + "score": 0, + "isSequential": true, + "targetObjects": [ + "鏌滈棬_灏佸嵃" + ] + } + ] + }, + { + "stepDescription": "姝ラ 3 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "鐢ㄨ灪涓濆垁鎵撳紑鎺ョ嚎鐩", + "score": 0, + "isSequential": false, + "targetObjects": [ + "鎺ョ嚎鐩抇灏佸嵃R", + "鎺ョ嚎鐩抇灏佸嵃L", + "鍥哄畾铻轰笣_Ldown", + "鐩朹鍥哄畾铻轰笣_Rup" + ] + } + ] + }, + { + "stepDescription": "姝ラ 5 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "鐢ㄨ灪涓濆垁鎵撳紑鎺ョ嚎鐩掞紝灏嗘嫧鐗囪皟鏁磋嚦鏂數鐘舵侊紙甯︾數浣滀笟璋冩暣妯悜婊戝潡锛屾柇鐢典綔涓氳皟鏁寸珫鍚戞粦鍧楋紝绯荤粺榛樿鏂數浣滀笟锛夛紝寮濮嬩綔涓氾紱", + "score": 0, + "isSequential": false, + "targetObjects": [ + "鎺ョ嚎鐩掔旱鍚戞粦鍧001", + "鎺ョ嚎鐩掔旱鍚戞粦鍧002", + "鎺ョ嚎鐩掔旱鍚戞粦鍧003", + "鎺ョ嚎鐩掔旱鍚戞粦鍧004" + ] + } + ] + }, + { + "stepDescription": "姝ラ 6 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "鎵撳紑闆嗕腑鍣ㄥ皝鍗帮紝鍘婚櫎铻轰笣;", + "score": 0, + "isSequential": false, + "targetObjects": [ + "闆嗕腑鍣╛灏佸嵃R", + "闆嗕腑鍣╛灏佸嵃_L", + "澹冲浐瀹氳灪涓漘R", + "澹冲浐瀹氳灪涓漘L" + ] + } + ] + }, { "stepDescription": "姝ラ 4 鎻忚堪", "score": 0, @@ -24,6 +105,23 @@ ] } ] + }, + { + "stepDescription": "姝ラ 6 鎻忚堪", + "score": 0, + "actions": [ + { + "description": "鎵撳紑闆嗕腑鍣ㄥ皝鍗帮紝鍘婚櫎铻轰笣;", + "score": 0, + "isSequential": false, + "targetObjects": [ + "闆嗕腑鍣╛灏佸嵃R", + "闆嗕腑鍣╛灏佸嵃_L", + "澹冲浐瀹氳灪涓漘R", + "澹冲浐瀹氳灪涓漘L" + ] + } + ] } ] }