关门故障调整

This commit is contained in:
joylink_fanyuhong 2024-05-22 09:46:29 +08:00
parent 4b537fc7ab
commit 77202e77e5

View File

@ -4,18 +4,19 @@ extends Node
@export var trainingName: String = "实训"
## 场景描述
@export var trainingDesc: String = "列车关门作业,突发单个站台门未正常关闭。"
## 当前步骤操作
var stepOperation = []
## 步骤列表
var handleStep = [
{
"stepName": "步骤一站务员手指上行2号门门头灯",
"stepOperation": [],
"next": true,
"waitTime": 3,
"play": false,
"notip": false,
"checkVoice": ""
"next": true, #是否直接进入下一步,与waitTime配合使用
"waitTime": 3, #进入下一步的等待时间
"play": false, #是否播放语音
"playPath": "", #播放语音路径
"notip": false, #是否有步骤提示
"checkVoice": "" #语音检查文字
},
{
"stepName": "步骤二站务员口呼上行2号门门头灯亮关门故障。",
@ -23,6 +24,7 @@ var handleStep = [
"next": false,
"checkVoice": "上行2号门门头灯亮关门故障。",
"play": false,
"playPath": "",
"notip": false,
},
{
@ -30,12 +32,14 @@ var handleStep = [
"next": false,
"checkVoice": "值班员上行2号门关门故障使用LCB关闭站台门。",
"play": false,
"playPath": "",
"notip": false,
},
{
"stepName": "值班员回复:收到。",
"stepOperation": [],
"play": true,
"playPath": "res://Assets/training_speech/sd.mp3",
"notip": true,
"next": false,
"checkVoice": ""
@ -44,6 +48,7 @@ var handleStep = [
"stepName": "步骤四站务员用LCB钥匙1号将故障门2号门的LCB转至“关门”位置。",
"stepOperation": ["LCB2","LCB_Key1","confirmUseKey","LCB2RightRotate"],
"play": false,
"playPath": "",
"notip": false,
"next": false,
"checkVoice": ""
@ -53,6 +58,7 @@ var handleStep = [
"next": true,
"waitTime": 3,
"play": false,
"playPath": "",
"notip": false,
"checkVoice": ""
},
@ -62,6 +68,7 @@ var handleStep = [
"checkVoice": "门头灯熄灭,关门成功。",
"next": false,
"play": false,
"playPath": "",
"notip": false,
},
{
@ -70,6 +77,7 @@ var handleStep = [
"checkVoice":"故障门处置完毕",
"next": false,
"play": false,
"playPath": "",
"notip": false,
},
{
@ -77,6 +85,7 @@ var handleStep = [
"stepOperation": ["LCB2LeftRotate","removeKeyOfWindowLCB2"],
"next": false,
"play": false,
"playPath": "",
"notip": false,
"checkVoice": ""
},
@ -92,13 +101,15 @@ var handleStep = [
"stepName": "值班员回复:收到。",
"stepOperation": [],
"play": true,
"notip": false,
"playPath": "res://Assets/training_speech/sd.mp3",
"notip": true,
"next": false,
"checkVoice": ""
},
]
## 步骤操作执行index
var stepOperationIndex = 0
## 步骤执行index
var stepIndex = 0
func _ready():
@ -107,26 +118,26 @@ func _ready():
stepOperationIndex = 0
stepIndex = 0
## 弹框点击开始实训
func _on_training_desc_dialog_start_training():
$total.trainComeAndOpenScreenDoor()
$total.setAssignScreenDoorsCloseFault([TotalScene.ScreenDoor_name.screenDoor2])
$DepartTimer.wait_time = 15
$DepartTimer.one_shot = true
$DepartTimer.connect("timeout", depart)
$DepartTimer.connect("timeout", closeScreenDoor)
$DepartTimer.start()
func depart():
## 关闭屏蔽门
func closeScreenDoor():
$total.closeScreenDoor()
func load_mp3(path):
var file = FileAccess.open(path, FileAccess.READ)
var sound = AudioStreamMP3.new()
sound.data = file.get_buffer(file.get_length())
return sound
#func load_mp3(path):
#var file = FileAccess.open(path, FileAccess.READ)
#var sound = AudioStreamMP3.new()
#sound.data = file.get_buffer(file.get_length())
#return sound
## 下一步
func nextStep():
if stepIndex < handleStep.size():
var step = handleStep[stepIndex]
@ -135,39 +146,38 @@ func nextStep():
$StepTip.updateOperationTip(step.stepName)
else:
$StepTip.updateOperationTip("")
if step.stepOperation.size() > 0:
if step.stepOperation.size() > 0: ## 如果步骤有具体操作进入操作并初始化
initStepOperation()
if step.next == true:
$StepTimer.wait_time = 2
if step.next == true: ## 如果步骤为直接进入下一步 则延时进入定时器
$StepTimer.wait_time = step.waitTime
$StepTimer.one_shot = true
$StepTimer.connect("timeout", nextStep)
$StepTimer.start()
if step.checkVoice:
if step.checkVoice: ## 如果步骤有需检查语音
await $VoiceCommunication.speech_record_check(step.checkVoice)
nextStep()
if step.play:
var sound = load_mp3("res://Assets/training_speech/sd.mp3")
if step.play: ## 如果步骤有需播放语音
var sound = load(step.playPath)
await $VoiceCommunication.play_reply(sound)
nextStep()
## 设置操作的node节点和特定模式下的提示
func setOperationNodeAndTip():
$total.currenNeedClickNode = stepOperation[stepOperationIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[stepOperation[stepOperationIndex]])
## 初始化步骤操作
func initStepOperation():
stepOperation = handleStep[stepIndex-1].stepOperation
stepOperationIndex = 0
setOperationNodeAndTip()
## 屏蔽门关闭成功
func _on_total_screen_door_close_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor1":
nextStep()
if screenDoor.name == "screenDoor2":
var sound3 = load_mp3("res://Assets/training_speech/gmgz/mtdxm.mp3")
await $VoiceCommunication.play_reply(sound3)
$total.trainLeave()
## 步骤操作节点点击正确
func _on_total_current_click_check_signal(isCorrect):
if isCorrect:
stepOperationIndex = stepOperationIndex + 1