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

230 lines
6.5 KiB
GDScript3
Raw Normal View History

extends Node
## 实训名称
@export var trainingName: String = "实训"
## 场景描述
@export var trainingDesc: String = "场景描述"
2024-05-21 11:09:24 +08:00
var stepOperation = []
2024-05-22 11:10:03 +08:00
var handleStep = [
{
"stepName": "发现故障 步骤一站务员手指上行3号门门头灯。",
"stepOperation": [],
"next": true,
"waitTime": 3,
"play": false,
"playPath": "",
"notip": true,
"checkVoice": ""
},
{
"stepName": "步骤二站务员口呼上行3号门门头灯不亮开门故障。",
"stepOperation": [],
"next": false,
"checkVoice": "上行3号门门头灯不亮开门故障",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "现场处置 步骤一站务员用对讲机汇报值班员值班员上行3号门开门故障使用LCB开启站台门。",
"stepOperation": [],
"next": false,
"checkVoice": "值班员上行3号门开门故障使用LCB开启站台门。",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤二:值班员回复:收到。",
"stepOperation": [],
"next": false,
"checkVoice": "",
"play": true,
"playPath": "res://Assets/training_speech/sd.mp3",
"notip": false,
},
{
"stepName": "步骤三站务员用LCB打开3号故障门用 LCB钥匙1号将故障门3号门的LCB转至“开门”位置。",
"stepOperation": ["LCB3","LCB_Key1","confirmUseKey","LCB3RightRotate","LCB3RightRotate"],
"next": false,
"checkVoice": "",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤四:站台门打开后,站务员口呼:请有序下车。",
"stepOperation": [],
"next": false,
"checkVoice": "请有序下车。",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤五站务员用LCB关闭3号故障门停站时间到乘客乘降完毕后用 LCB钥匙1号将故障门3号门的LCB转至“关门”位置。",
"stepOperation": ["LCB3LeftRotate"],
"next": false,
"checkVoice": "",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤六:站务员口呼:故障门处置完毕。",
"stepOperation": [],
"next": false,
"checkVoice": "故障门处置完毕。",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤七:列车出清站台后,站务员用 LCB钥匙1号将故障门3号门的LCB转至“自动”位置取出钥匙。",
"stepOperation": ["LCB3LeftRotate","removeKeyOfWindowLCB3"],
"next": false,
"checkVoice": "",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤八站务员用对讲机汇报值班员值班员上行3号门故障已处理完毕。",
"stepOperation": [],
"next": false,
"checkVoice": "值班员上行3号门故障已处理完毕。",
"play": false,
"playPath": "",
"notip": true,
},
{
"stepName": "步骤九:值班员回复:收到。",
"stepOperation": [],
"next": false,
"checkVoice": "",
"play": true,
"playPath": "res://Assets/training_speech/sd.mp3",
"notip": false,
},
2024-05-17 17:37:41 +08:00
]
2024-05-22 11:10:03 +08:00
## 步骤操作执行index
2024-05-21 11:09:24 +08:00
var stepOperationIndex = 0
2024-05-22 11:10:03 +08:00
## 步骤执行index
2024-05-20 14:29:47 +08:00
var handleStepIndex = 0
2024-05-14 14:13:17 +08:00
func _ready():
$TrainingDescDialog.title = trainingName
$TrainingDescDialog.updateSceneDesc(trainingDesc)
2024-05-17 17:37:41 +08:00
$TrainingDescDialog.grab_focus()
$StepTip.visible = false
2024-05-22 11:10:03 +08:00
stepOperationIndex = 0
handleStepIndex = 0
func _on_training_desc_dialog_start_training():
$total.trainComeAndOpenScreenDoor()
2024-05-14 10:42:45 +08:00
$total.setAssignScreenDoorsOpenFault([TotalScene.ScreenDoor_name.screenDoor3])
2024-05-22 11:10:03 +08:00
func nextStep():
if handleStepIndex < handleStep.size():
var step = handleStep[handleStepIndex]
handleStepIndex = handleStepIndex + 1
if step.notip == true and $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepTip.updateOperationTip(step.stepName)
if step.stepOperation.size() > 0:
initStepOperation()
if step.next == true:
$StepTimer.connect("timeout", nextStep)
$StepTimer.start()
if step.checkVoice:
await $VoiceCommunication.speech_record_check(step.checkVoice)
if step.stepName == "步骤四:站台门打开后,站务员口呼:请有序下车。":
$DepartTimer.connect("timeout", closeScreenDoor)
$DepartTimer.start()
else :
nextStep()
if step.play:
var sound = load(step.playPath)
await $VoiceCommunication.play_reply(sound)
nextStep()
func setOperationNodeAndTip():
$total.currenNeedClickNode = stepOperation[stepOperationIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[stepOperation[stepOperationIndex]])
func initStepOperation():
stepOperation = handleStep[handleStepIndex-1].stepOperation
stepOperationIndex = 0
setOperationNodeAndTip()
##与站台交互点击信号
func _on_total_current_click_check_signal(isCorrect):
if $total.currentClickNode == 'removeKeyOfWindowLCB3' :
nextStep()
if isCorrect:
stepOperationIndex = stepOperationIndex + 1
$StepJudgment.hideError()
if stepOperationIndex < stepOperation.size():
$total.currenNeedClickNode = stepOperation[stepOperationIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[stepOperation[stepOperationIndex]])
else:
$TrainTip.setTrainingTip('')
else:
if $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepJudgment.showError()
2024-05-17 17:37:41 +08:00
##开门信号
2024-05-14 10:42:45 +08:00
func _on_total_screen_door_open_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor1":
2024-05-20 14:29:47 +08:00
if $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepTip.visible = true
handleStepIndex = 0
2024-05-22 11:10:03 +08:00
nextStep()
2024-05-14 10:42:45 +08:00
elif screenDoor.name == "screenDoor3":
2024-05-22 11:10:03 +08:00
handleStepIndex = 5
nextStep()
2024-05-14 10:42:45 +08:00
2024-05-17 17:37:41 +08:00
##关门信号
2024-05-14 10:42:45 +08:00
func _on_total_screen_door_close_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor3":
$total.trainLeave()
2024-05-22 11:10:03 +08:00
handleStepIndex = 7
nextStep()
2024-05-14 14:13:17 +08:00
elif screenDoor.name == "screenDoor1":
2024-05-22 11:10:03 +08:00
handleStepIndex = 6
nextStep()
2024-05-14 14:13:17 +08:00
2024-05-22 11:10:03 +08:00
##屏蔽门lcb状态变化信号
func _on_total_screen_door_lcb_state_change_signal(screenDoor: ScreenDoor,knob_state: LcbWindow.KNOB_STATE) -> void:
pass
2024-05-14 14:13:17 +08:00
2024-05-17 17:37:41 +08:00
2024-05-22 11:10:03 +08:00
##待解决
func _on_voice_communication_speech_recognition_successed123() -> void:
2024-05-20 14:29:47 +08:00
if handleStepIndex == 0 :
2024-05-22 11:10:03 +08:00
nextStep()
2024-05-20 14:29:47 +08:00
elif handleStepIndex == 3 :
2024-05-22 11:10:03 +08:00
nextStep()
2024-05-20 14:29:47 +08:00
elif handleStepIndex == 5 :
2024-05-22 11:10:03 +08:00
nextStep()
func closeScreenDoor():
$total.closeScreenDoor()
2024-05-20 14:29:47 +08:00
2024-05-17 17:37:41 +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()