Merge branch 'SXElectricityInformationAcquisition' of http://gitea.umayle.com/huangjiayu/ShanxiKnowledgeBase into SXElectricityInformationAcquisition

This commit is contained in:
yzx 2024-06-12 15:15:55 +08:00
commit 4fece283a9
4 changed files with 186 additions and 71 deletions

View File

@ -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()

View File

@ -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($"正确点击了:{clickedObject.name}");
currentAction.CurrentObjectIndex++; // 正确点击,递增对象索引
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($"正确点击了:{clickedObject.name}");
currentAction.CurrentObjectIndex++; // 正确点击,递增对象索引
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($"正确点击了:{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($"正确点击了:{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<string> correctObjectNames = new List<string>();
foreach (var obj in currentAction.TargetObjects)
{
if (!currentAction.ClickedObjects.Contains(obj))
{
correctObjectNames.Add(obj.name);
}
}
string correctObjects = string.Join(", ", correctObjectNames);
Debug.Log($"错误点击:{clickedObject.name} 正确的物体是:{correctObjects}");
}
}
}
else
{
Debug.Log($"错误点击:{clickedObject.name}");
}
}
}
}
}

View File

@ -1,3 +1,11 @@
fileFormatVersion: 2
guid: 51f73ee94f284a86b677a6bc74544094
timeCreated: 1717740090
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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,
@ -47,6 +128,23 @@
]
}
]
},
{
"stepDescription": "步骤 6 描述",
"score": 0,
"actions": [
{
"description": "打开集中器封印,去除螺丝;",
"score": 0,
"isSequential": false,
"targetObjects": [
"集中器_封印R",
"集中器_封印_L",
"壳固定螺丝_R",
"壳固定螺丝_L"
]
}
]
}
]
}