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

105 lines
4.2 KiB
GDScript3
Raw Normal View History

extends Node
## 实训名称
@export var trainingName: String = "实训"
## 场景描述
@export var trainingDesc: String = "场景描述"
2024-05-20 09:23:25 +08:00
var currentStep = []
2024-05-17 17:37:41 +08:00
var handleStep = [{"stepName": "步骤一站务员用对讲机汇报值班员值班员上行3号门开门故障使用LCB开启站台门。", "stepOperation": [],},
{"stepName": "步骤二:值班员回复:收到。", "stepOperation": []},
{"stepName": "步骤三站务员用LCB打开3号故障门用 LCB钥匙1号将故障门3号门的LCB转至“开门”位置。", "stepOperation": ["LCB3","LCB_Key1","confirmUseKey","LCB3RightRotate","LCB3RightRotate"]},
{"stepName": "步骤四:站台门打开后,站务员口呼:请有序下车。", "stepOperation": []},
2024-05-20 09:23:25 +08:00
{"stepName": "步骤五站务员用LCB关闭3号故障门停站时间到乘客乘降完毕后用 LCB钥匙1号将故障门3号门的LCB转至“关门”位置。", "stepOperation": ["LCB3LeftRotate"]},
2024-05-17 17:37:41 +08:00
{"stepName": "步骤六:故障门处置完毕。", "stepOperation": []},
2024-05-20 09:23:25 +08:00
{"stepName": "步骤七:列车出清站台后,站务员用 LCB钥匙1号将故障门3号门的LCB转至“自动”位置取出钥匙。", "stepOperation": ["LCB3LeftRotate","removeKeyOfWindowLCB3"]},
2024-05-17 17:37:41 +08:00
{"stepName": "步骤八站务员用对讲机汇报值班员值班员上行3号门故障已处理完毕。", "stepOperation": []},
{"stepName": "步骤九:值班员回复:收到。", "stepOperation": []},
]
2024-05-14 14:13:17 +08:00
var stepIndex = 0
func _ready():
$TrainingDescDialog.title = trainingName
$TrainingDescDialog.updateSceneDesc(trainingDesc)
2024-05-17 17:37:41 +08:00
$TrainingDescDialog.grab_focus()
$StepTip.visible = false
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-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-17 17:37:41 +08:00
$StepTip.visible = true
$StepTip.updateOperationTip(handleStep[0].stepName)
$textVoice.connect("timeout", replyReceived)
$textVoice.start()
2024-05-14 10:42:45 +08:00
elif screenDoor.name == "screenDoor3":
$DepartTimer.connect("timeout", depart)
$DepartTimer.start()
2024-05-17 17:37:41 +08:00
2024-05-14 10:42:45 +08:00
func depart():
$total.closeScreenDoor()
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-20 09:23:25 +08:00
$StepTip.updateOperationTip(handleStep[6].stepName)
stepIndex = 0
currentStep = handleStep[6].stepOperation
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[handleStep[6].stepOperation[0]])
2024-05-14 14:13:17 +08:00
elif screenDoor.name == "screenDoor1":
2024-05-17 17:37:41 +08:00
$StepTip.updateOperationTip(handleStep[4].stepName)
2024-05-20 09:23:25 +08:00
stepIndex = 0
currentStep = handleStep[4].stepOperation
2024-05-14 14:13:17 +08:00
$total.currenNeedClickNode = currentStep[stepIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
2024-05-20 09:23:25 +08:00
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[handleStep[4].stepOperation[0]])
2024-05-14 14:13:17 +08:00
func _on_total_current_click_check_signal(isCorrect):
if isCorrect:
stepIndex = stepIndex + 1
$StepJudgment.hideError()
2024-05-20 09:23:25 +08:00
if stepIndex < currentStep.size():
2024-05-14 14:13:17 +08:00
$total.currenNeedClickNode = currentStep[stepIndex]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[currentStep[stepIndex]])
else:
$TrainTip.setTrainingTip('')
else:
if $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepJudgment.showError()
2024-05-17 17:37:41 +08:00
##回复收到
func replyReceived() :
var sound = load_mp3("res://Assets/training_speech/sd.mp3")
await $VoiceCommunication.play_reply(sound)
$StepTip.updateOperationTip(handleStep[2].stepName)
$total.currenNeedClickNode = handleStep[2].stepOperation[0]
if $total.trainingMode == TotalScene.Training_Mode.Teach:
2024-05-20 09:23:25 +08:00
currentStep = handleStep[2].stepOperation
2024-05-17 17:40:06 +08:00
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[handleStep[2].stepOperation[0]])
2024-05-17 17:37:41 +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
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()