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

83 lines
2.3 KiB
GDScript3
Raw Normal View History

2024-05-10 08:31:11 +08:00
extends Node
## 实训名称
@export var trainingName: String = "实训"
## 场景描述
@export var trainingDesc: String = "场景描述"
2024-05-14 14:13:17 +08:00
var currentStep = ["LCB2","LCB_Key2","confirmUseKey","LCB2RightRotate","LCB2LeftRotate","removeKeyOfWindowLCB2"]
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-13 15:55:11 +08:00
stepIndex = 0
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
$DepartTimer.connect("timeout", depart)
$DepartTimer.start()
2024-05-13 14:08:41 +08:00
2024-05-10 09:30:37 +08:00
func depart():
$total.closeScreenDoor()
2024-05-11 14:27:21 +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-13 14:08:41 +08:00
func _on_total_screen_door_close_confirm_signal(screenDoor):
if screenDoor.name == "screenDoor1":
var sound = load_mp3("res://Assets/training_speech/gmgz/2hmgmgz.mp3")
await $VoiceCommunication.play_reply(sound)
2024-05-13 15:55:11 +08:00
$total.currenNeedClickNode = currentStep[stepIndex]
2024-05-13 17:42:02 +08:00
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[currentStep[stepIndex]])
2024-05-13 14:08:41 +08:00
if screenDoor.name == "screenDoor2":
var sound3 = load_mp3("res://Assets/training_speech/gmgz/mtdxm.mp3")
await $VoiceCommunication.play_reply(sound3)
$total.trainLeave()
func _input(event):
if event is InputEventKey:
if event.pressed:
if event.keycode == KEY_SPACE: # 检查是否按下了空格键
$VoiceCommunication.speech_record_check(event.keycode)
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:
stepIndex = stepIndex + 1
2024-05-14 08:59:06 +08:00
$StepJudgment.hideError()
2024-05-13 16:55:34 +08:00
if stepIndex < currentStep.size():
2024-05-13 16:05:03 +08:00
$total.currenNeedClickNode = currentStep[stepIndex]
2024-05-13 17:42:02 +08:00
if $total.trainingMode == TotalScene.Training_Mode.Teach:
$TrainTip.setTrainingTip($total.allClickEquipmentInfo[currentStep[stepIndex]])
2024-05-13 16:05:03 +08:00
else:
$TrainTip.setTrainingTip('')
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()