godot-psd-training/trainings/trainingPinchPeopleFault/trainingPinchPeopleFault.gd
2024-06-06 11:04:52 +08:00

257 lines
7.6 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Node
## 实训名称
@export var trainingName: String = "实训"
## 场景描述
@export var trainingDesc: String = "场景描述"
var stepOperation = []
var handleStep = [
{
"stepName": "步骤一站务员手指上行2号门。站务员口呼上行2号门夹人。",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "上行2号门夹人。"
},
{
"stepName": "步骤二:站务员按下上行站台紧急停车按钮(阻止列车出站)。",
"stepOperation": ["JJTC","JJTC_Key","confirmUseKey","JJTCRightRotate","JJTCButton","JJTCCloseBox","JJTCLeftRotate"],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": ""
},
{
"stepName": "步骤三站务员用对讲机汇报值班员值班员上行2号站台门、车门夹人已按下上行紧急停车按钮。",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "值班员上行2号站台门、车门夹人已按下上行紧急停车按钮。"
},
{
"stepName": "值班员回复站务员:收到。",
"stepOperation": [],
"next": false,
"checkVoice": "",
"play": true,
"playPath": "res://Assets/training_speech/sd.mp3",
"stepTip": false,
},
{
"stepName": "步骤四:站务员对讲机联系行值:车控室,上行站台是否扣车?",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "车控室,上行站台是否扣车?"
},
{
"stepName": "行值对讲机回复:上行站台已扣车。",
"stepOperation": [],
"next": false,
"checkVoice": "",
"play": true,
"playPath": "res://Assets/training_speech/trainingPinchPeopleFault/sxztykc.mp3",
"stepTip": false,
},
{
"stepName": "步骤五:站务员按压联动开门按钮,打开车门和站台门。",
"stepOperation": ["PSL","interconnectedOpenButton"],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": ""
},
{
"stepName": "步骤六:站务员帮助乘客脱困(书包带现象消失)。站务员按压联动关门按钮,关闭车门和站台门。",
"stepOperation": ["interconnectedCloseButton"],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": ""
},
{
"stepName": "步骤七:确认站台门关闭后,口呼:站台门已关闭。",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "站台门已关闭。"
},
{
"stepName": "步骤八:站务员对讲机联系值班员:值班员,现场处置完毕,请恢复上行紧急停车及扣车。",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "值班员,现场处置完毕,请恢复上行紧急停车及扣车。"
},
{
"stepName": "值班员对讲机回复站务员:收到,恢复上行紧急停车及扣车。",
"stepOperation": [],
"next": false,
"play": true,
"playPath": "res://Assets/training_speech/trainingPinchPeopleFault/sdhfsxjttcjkc.mp3",
"stepTip": false,
"checkVoice": ""
},
{
"stepName": "值班员对讲机联系站务员:上行紧急停车已恢复,请协助发车。",
"stepOperation": [],
"next": false,
"play": true,
"playPath": "res://Assets/training_speech/trainingPinchPeopleFault/sxjjtcyhfqxzfc.mp3",
"stepTip": false,
"checkVoice": ""
},
{
"stepName": "步骤九:站务员对讲机回复:收到",
"stepOperation": [],
"next": false,
"play": false,
"playPath": "",
"stepTip": true,
"checkVoice": "收到。"
},
{
"stepName": "实训已完成!",
"stepOperation": [],
"next": false,
"checkVoice": "",
"play": false,
"playPath": "",
"stepTip": true,
},
]
## 步骤操作执行index
var stepOperationIndex = 0
## 步骤执行index
var handleStepIndex = 0
func _ready():
$TrainingDescDialog.title = trainingName
$TrainingDescDialog.updateSceneDesc(trainingDesc)
$TrainingDescDialog.grab_focus()
stepOperationIndex = 0
handleStepIndex = 0
var voiceCommunication
func _on_training_desc_dialog_start_training():
voiceCommunication = preload("res://Communication/voice_communication.tscn").instantiate()
add_child(voiceCommunication)
$total.trainComeAndOpenScreenDoor()
$total.setAssignScreenDoorsPinchPeopleFault([TotalScene.ScreenDoor_name.screenDoor2])
func nextStep():
if handleStepIndex < handleStep.size():
var step = handleStep[handleStepIndex]
handleStepIndex = handleStepIndex + 1
if step.stepTip == 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)
nextStep()
if step.play:
var sound = load(step.playPath)
await voiceCommunication.play_reply(sound)
nextStep()
if step.stepName == "实训已完成!":
$total.trainLeave()
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 isCorrect:
if $total.currentClickNode == 'JJTCLeftRotate' :
nextStep()
elif $total.currentClickNode == 'interconnectedOpenButton' :
$total.removeAssignScreenDoorsFault([TotalScene.ScreenDoor_name.screenDoor2])
screenDoor2.peopleWalkToPlatform()
clickInterconnectedOpenButton = true
$total.openScreenDoor()
elif $total.currentClickNode == 'interconnectedCloseButton' :
clickInterconnectedCloseButton = true
$total.closeScreenDoor()
stepOperationIndex = stepOperationIndex + 1
$StepJudgment.hideError()
if stepOperationIndex < stepOperation.size():
setOperationNodeAndTip()
else:
$TrainTip.setTrainingTip('')
else:
if $total.trainingMode != TotalScene.Training_Mode.Exam:
$StepJudgment.showError()
##开门信号
var clickInterconnectedOpenButton = false
var screenDoor2 = null
func _on_total_screen_door_open_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor2" and screenDoor2 == null :
screenDoor2 = screenDoor
if screenDoor.name == "screenDoor1" and !clickInterconnectedOpenButton:
$CloseScreenDoorTimer.start()
elif screenDoor.name == "screenDoor1" and clickInterconnectedOpenButton:
nextStep()
clickInterconnectedOpenButton = false
##关门信号
var clickInterconnectedCloseButton = false
func _on_total_screen_door_close_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor1" and !clickInterconnectedCloseButton:
$sayPinchPeopleTimer.start()
elif screenDoor.name == "screenDoor1" and clickInterconnectedCloseButton:
nextStep()
clickInterconnectedCloseButton = false
func _on_close_screen_door_timer_timeout() -> void:
$total.closeScreenDoor()
func _on_say_pinch_people_timer_timeout() -> void:
handleStepIndex = 0
nextStep()
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[handleStepIndex-1]
if step.checkVoice:
voiceCommunication._reset_record_state()
nextStep()