godot-psd-training/trainings/trainingCloseDoorFault/trainingCloseDoorFault.gd

207 lines
6.1 KiB
GDScript3
Raw Normal View History

2024-05-10 08:31:11 +08:00
extends Node
## 实训名称
@export var trainingName: String = "实训"
## 场景描述
2024-05-20 10:40:31 +08:00
@export var trainingDesc: String = "列车关门作业,突发单个站台门未正常关闭。"
2024-05-22 09:46:29 +08:00
## 当前步骤操作
2024-05-20 14:21:03 +08:00
var stepOperation = []
2024-05-22 09:46:29 +08:00
## 步骤列表
2024-05-20 14:21:03 +08:00
var handleStep = [
{
"stepName": "步骤一站务员手指上行2号门门头灯",
"stepOperation": [],
2024-05-22 09:46:29 +08:00
"next": true, #是否直接进入下一步,与waitTime配合使用
"waitTime": 3, #进入下一步的等待时间
"play": false, #是否播放语音
"playPath": "", #播放语音路径
"notip": false, #是否有步骤提示
"checkVoice": "" #语音检查文字
2024-05-20 14:21:03 +08:00
},
{
"stepName": "步骤二站务员口呼上行2号门门头灯亮关门故障。",
"stepOperation": [],
"next": false,
"checkVoice": "上行2号门门头灯亮关门故障。",
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
},
{
"stepName": "步骤三站务员用对讲机汇报值班员值班员上行2号门关门故障使用LCB关闭站台门。", "stepOperation": [],
"next": false,
"checkVoice": "值班员上行2号门关门故障使用LCB关闭站台门。",
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
},
{
"stepName": "值班员回复:收到。",
"stepOperation": [],
"play": true,
2024-05-22 09:46:29 +08:00
"playPath": "res://Assets/training_speech/sd.mp3",
2024-05-20 14:21:03 +08:00
"notip": true,
"next": false,
2024-05-20 14:47:34 +08:00
"checkVoice": ""
2024-05-20 14:21:03 +08:00
},
{
"stepName": "步骤四站务员用LCB钥匙1号将故障门2号门的LCB转至“关门”位置。",
"stepOperation": ["LCB2","LCB_Key1","confirmUseKey","LCB2RightRotate"],
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
"next": false,
2024-05-20 14:47:34 +08:00
"checkVoice": ""
2024-05-20 14:21:03 +08:00
},
{
"stepName": "步骤五站务员确认故障门关闭。站务员手指上行2号门门头灯和上行2号站台门。", "stepOperation": [],
"next": true,
"waitTime": 3,
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
2024-05-20 14:47:34 +08:00
"checkVoice": ""
2024-05-20 14:21:03 +08:00
},
{
"stepName": "步骤六:站务员口呼:门头灯熄灭,关门成功。",
"stepOperation": [],
"checkVoice": "门头灯熄灭,关门成功。",
"next": false,
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
},
{
"stepName": "步骤七:站务员口呼:故障门处置完毕。",
"stepOperation": [],
"checkVoice":"故障门处置完毕",
"next": false,
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
},
{
"stepName": "步骤八列车出清站台后站务员用LCB钥匙1号将故障门2号门的LCB转至“自动”位置取出钥匙。",
"stepOperation": ["LCB2LeftRotate","removeKeyOfWindowLCB2"],
"next": false,
"play": false,
2024-05-22 09:46:29 +08:00
"playPath": "",
2024-05-20 14:21:03 +08:00
"notip": false,
2024-05-20 14:47:34 +08:00
"checkVoice": ""
2024-05-20 14:21:03 +08:00
},
{
"stepName": "步骤九站务员用对讲机汇报值班员值班员上行2号门故障已处理完毕。",
"stepOperation": [],
"checkVoice":"值班员上行2号门故障已处理完毕。",
"next": false,
"play": false,
"notip": false,
},
{
"stepName": "值班员回复:收到。",
"stepOperation": [],
"play": true,
2024-05-22 09:46:29 +08:00
"playPath": "res://Assets/training_speech/sd.mp3",
"notip": true,
2024-05-20 14:47:34 +08:00
"next": false,
"checkVoice": ""
2024-05-20 14:21:03 +08:00
},
2024-05-20 10:40:31 +08:00
]
2024-05-22 09:46:29 +08:00
## 步骤操作执行index
2024-05-20 14:21:03 +08:00
var stepOperationIndex = 0
2024-05-22 09:46:29 +08:00
## 步骤执行index
2024-05-13 15:55:11 +08:00
var stepIndex = 0
2024-05-10 08:31:11 +08:00
func _ready():
$TrainingDescDialog.title = trainingName
$TrainingDescDialog.updateSceneDesc(trainingDesc)
2024-05-22 13:12:11 +08:00
$TrainingDescDialog.grab_focus()
2024-05-20 14:21:03 +08:00
stepOperationIndex = 0
2024-05-13 15:55:11 +08:00
stepIndex = 0
2024-05-10 08:31:11 +08:00
2024-05-22 09:46:29 +08:00
## 弹框点击开始实训
2024-05-10 08:31:11 +08:00
func _on_training_desc_dialog_start_training():
$total.trainComeAndOpenScreenDoor()
$total.setAssignScreenDoorsCloseFault([TotalScene.ScreenDoor_name.screenDoor2])
2024-05-10 09:36:11 +08:00
$DepartTimer.wait_time = 15
2024-05-10 09:30:37 +08:00
$DepartTimer.one_shot = true
2024-05-22 09:46:29 +08:00
$DepartTimer.connect("timeout", closeScreenDoor)
2024-05-10 09:30:37 +08:00
$DepartTimer.start()
2024-05-13 14:08:41 +08:00
2024-05-22 09:46:29 +08:00
## 关闭屏蔽门
func closeScreenDoor():
2024-05-10 09:30:37 +08:00
$total.closeScreenDoor()
2024-05-11 14:27:21 +08:00
2024-05-22 09:46:29 +08:00
#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
## 下一步
2024-05-20 14:21:03 +08:00
func nextStep():
if stepIndex < handleStep.size():
var step = handleStep[stepIndex]
stepIndex = stepIndex + 1
2024-05-22 13:12:11 +08:00
if step.notip == false and $total.trainingMode != TotalScene.Training_Mode.Exam:
2024-05-21 11:09:24 +08:00
$StepTip.updateOperationTip(step.stepName)
else:
$StepTip.updateOperationTip("")
2024-05-22 09:46:29 +08:00
if step.stepOperation.size() > 0: ## 如果步骤有具体操作进入操作并初始化
2024-05-20 14:21:03 +08:00
initStepOperation()
2024-05-22 09:46:29 +08:00
if step.next == true: ## 如果步骤为直接进入下一步 则延时进入定时器
$StepTimer.wait_time = step.waitTime
2024-05-20 14:21:03 +08:00
$StepTimer.one_shot = true
$StepTimer.connect("timeout", nextStep)
$StepTimer.start()
2024-05-22 09:46:29 +08:00
if step.checkVoice: ## 如果步骤有需检查语音
2024-05-20 14:47:34 +08:00
await $VoiceCommunication.speech_record_check(step.checkVoice)
nextStep()
2024-05-22 09:46:29 +08:00
if step.play: ## 如果步骤有需播放语音
var sound = load(step.playPath)
2024-05-20 14:21:03 +08:00
await $VoiceCommunication.play_reply(sound)
nextStep()
2024-05-22 09:46:29 +08:00
## 设置操作的node节点和特定模式下的提示
2024-05-20 14:21:03 +08:00
func setOperationNodeAndTip():
$total.currenNeedClickNode = stepOperation[stepOperationIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[stepOperation[stepOperationIndex]])
2024-05-22 09:46:29 +08:00
## 初始化步骤操作
2024-05-20 14:21:03 +08:00
func initStepOperation():
2024-05-20 14:47:34 +08:00
stepOperation = handleStep[stepIndex-1].stepOperation
2024-05-20 14:21:03 +08:00
stepOperationIndex = 0
2024-05-20 14:47:34 +08:00
setOperationNodeAndTip()
2024-05-22 09:46:29 +08:00
## 屏蔽门关闭成功
2024-05-13 14:08:41 +08:00
func _on_total_screen_door_close_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor1":
2024-05-20 14:21:03 +08:00
nextStep()
2024-05-13 14:08:41 +08:00
if screenDoor.name == "screenDoor2":
$total.trainLeave()
2024-05-22 09:46:29 +08:00
## 步骤操作节点点击正确
2024-05-13 15:55:11 +08:00
func _on_total_current_click_check_signal(isCorrect):
2024-05-13 16:05:03 +08:00
if isCorrect:
2024-05-20 14:21:03 +08:00
stepOperationIndex = stepOperationIndex + 1
2024-05-14 08:59:06 +08:00
$StepJudgment.hideError()
2024-05-20 14:21:03 +08:00
if stepOperationIndex < stepOperation.size():
setOperationNodeAndTip()
2024-05-13 16:05:03 +08:00
else:
$TrainTip.setTrainingTip('')
2024-05-20 14:21:03 +08:00
nextStep()
2024-05-13 17:23:45 +08:00
else:
2024-05-13 17:42:02 +08:00
if $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepJudgment.showError()
2024-05-13 15:55:11 +08:00
2024-05-16 16:30:14 +08:00
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()