216 lines
6.2 KiB
GDScript
216 lines
6.2 KiB
GDScript
extends Node
|
||
|
||
## 实训名称
|
||
@export var trainingName: String = "实训"
|
||
## 场景描述
|
||
@export var trainingDesc: String = "列车关门作业,突发单个站台门未正常关闭。"
|
||
## 当前步骤操作
|
||
var stepOperation = []
|
||
## 步骤列表
|
||
var handleStep = [
|
||
{
|
||
"stepName": "步骤一:站务员手指:上行2号门门头灯;站务员口呼:上行2号门门头灯亮,关门故障。",
|
||
"stepOperation": [],
|
||
"next": false,
|
||
"checkVoice": "上行2号门门头灯亮,关门故障。",
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
},
|
||
{
|
||
"stepName": "步骤二:站务员用对讲机汇报值班员:值班员,上行2号门关门故障,使用LCB关闭站台门。", "stepOperation": [],
|
||
"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": ""
|
||
},
|
||
{
|
||
"stepName": "步骤三:站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“关门”位置。",
|
||
"stepOperation": ["LCB2","LCB_Key1","confirmUseKey","LCB2RightRotate"],
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
"next": false,
|
||
"checkVoice": ""
|
||
},
|
||
{
|
||
"stepName": "步骤四:站务员确认故障门关闭。站务员手指:上行2号门门头灯和上行2号站台门。", "stepOperation": [],
|
||
"next": true,
|
||
"waitTime": 3,
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
"checkVoice": ""
|
||
},
|
||
{
|
||
"stepName": "步骤五:站务员口呼:门头灯熄灭,关门成功。",
|
||
"stepOperation": [],
|
||
"checkVoice": "门头灯熄灭,关门成功。",
|
||
"next": false,
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
},
|
||
{
|
||
"stepName": "步骤六:站务员口呼:故障门处置完毕。",
|
||
"stepOperation": [],
|
||
"checkVoice":"故障门处置完毕",
|
||
"next": false,
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
},
|
||
{
|
||
"stepName": "步骤七:列车出清站台后,站务员用LCB钥匙(1号)将故障门(2号门)的LCB转至“自动”位置,取出钥匙。",
|
||
"stepOperation": ["LCB2LeftRotate","removeKeyOfWindowLCB2"],
|
||
"next": false,
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
"checkVoice": ""
|
||
},
|
||
{
|
||
"stepName": "步骤八:站务员用对讲机汇报值班员:值班员,上行2号门故障已处理完毕。",
|
||
"stepOperation": [],
|
||
"checkVoice":"值班员,上行2号门故障已处理完毕。",
|
||
"next": false,
|
||
"play": false,
|
||
"notip": false,
|
||
},
|
||
{
|
||
"stepName": "值班员回复:收到。",
|
||
"stepOperation": [],
|
||
"play": true,
|
||
"playPath": "res://Assets/training_speech/sd.mp3",
|
||
"notip": true,
|
||
"next": false,
|
||
"checkVoice": ""
|
||
},
|
||
{
|
||
"stepName": "实训已结束",
|
||
"stepOperation": [],
|
||
"play": false,
|
||
"playPath": "",
|
||
"notip": false,
|
||
"next": false,
|
||
"checkVoice": ""
|
||
},
|
||
]
|
||
## 步骤操作执行index
|
||
var stepOperationIndex = 0
|
||
## 步骤执行index
|
||
var stepIndex = 0
|
||
|
||
func _ready():
|
||
$TrainingDescDialog.title = trainingName
|
||
$TrainingDescDialog.updateSceneDesc(trainingDesc)
|
||
$TrainingDescDialog.grab_focus()
|
||
stepOperationIndex = 0
|
||
stepIndex = 0
|
||
|
||
## 弹框点击开始实训
|
||
var voiceCommunication
|
||
func _on_training_desc_dialog_start_training():
|
||
voiceCommunication = preload("res://Communication/voice_communication.tscn").instantiate()
|
||
add_child(voiceCommunication)
|
||
$total.trainComeAndOpenScreenDoor()
|
||
$total.setAssignScreenDoorsCloseFault([TotalScene.ScreenDoor_name.screenDoor2])
|
||
$DepartTimer.wait_time = 15
|
||
$DepartTimer.one_shot = true
|
||
$DepartTimer.connect("timeout", closeScreenDoor)
|
||
$DepartTimer.start()
|
||
|
||
## 关闭屏蔽门
|
||
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 nextStep():
|
||
if stepIndex < handleStep.size():
|
||
var step = handleStep[stepIndex]
|
||
stepIndex = stepIndex + 1
|
||
if step.notip == false and $total.trainingMode != TotalScene.Training_Mode.Exam:
|
||
$StepTip.updateOperationTip(step.stepName)
|
||
else:
|
||
$StepTip.updateOperationTip("")
|
||
if step.stepOperation.size() > 0: ## 如果步骤有具体操作进入操作并初始化
|
||
initStepOperation()
|
||
if step.next == true: ## 如果步骤为直接进入下一步 则延时进入定时器
|
||
$StepTimer.wait_time = step.waitTime
|
||
$StepTimer.one_shot = true
|
||
$StepTimer.connect("timeout", nextStep)
|
||
$StepTimer.start()
|
||
if step.checkVoice: ## 如果步骤有需检查语音
|
||
await voiceCommunication.speech_record_check(step.checkVoice)
|
||
nextStep()
|
||
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":
|
||
$total.trainLeave()
|
||
## 步骤操作节点点击正确
|
||
func _on_total_current_click_check_signal(isCorrect):
|
||
if isCorrect:
|
||
stepOperationIndex = stepOperationIndex + 1
|
||
$StepJudgment.hideError()
|
||
if stepOperationIndex < stepOperation.size():
|
||
setOperationNodeAndTip()
|
||
else:
|
||
$TrainTip.setTrainingTip('')
|
||
nextStep()
|
||
else:
|
||
if $total.trainingMode != TotalScene.Training_Mode.Exam:
|
||
$StepJudgment.showError()
|
||
|
||
|
||
|
||
|
||
|
||
|
||
func _on_confirm_dialog_two_cancel():
|
||
get_tree().paused = false
|
||
|
||
|
||
func _on_confirm_dialog_two_confirm():
|
||
get_tree().paused = false
|
||
get_tree().reload_current_scene()
|
||
|
||
|
||
func _on_step_tip_click_next_step() -> void:
|
||
var step = handleStep[stepIndex-1]
|
||
if step.checkVoice:
|
||
voiceCommunication._reset_record_state()
|
||
nextStep()
|