goodnight_jellybean/godot/assets/audio/voice_lines/LineReader.gd

79 lines
1.7 KiB
GDScript3
Raw Permalink Normal View History

2023-01-01 02:23:56 -07:00
extends Node
var voice_script = [
["the_long", "book"],
["the_tall", "book"],
["the_door"],
["the_clock"],
["under_the_bed"],
["frog"],
["squirrel"],
["the_attic"],
["the_fridge"],
["the_tall", "book"],
["under_the_bed"],
["the_long", "book"],
["behind_the_bookshelf"],
]
2023-06-05 08:00:14 -06:00
@export var impatience: float = 10.0
2023-01-01 02:23:56 -07:00
2023-01-01 14:02:34 -07:00
func stop_all():
for sound in $Sounds.get_children():
sound.stop()
2023-01-01 04:28:30 -07:00
func _ready():
2023-06-05 08:00:14 -06:00
await get_tree().create_timer(5.0).timeout
var _err = GlobalCursorState.connect("unchecked_goal",Callable(self,"check_goal"))
2023-01-01 04:28:30 -07:00
script_loop()
2023-01-01 02:23:56 -07:00
2023-01-01 14:02:34 -07:00
var current_phrase = null
2023-01-01 02:23:56 -07:00
func read_line(line):
2023-01-01 14:02:34 -07:00
current_phrase = line
2023-01-01 04:28:30 -07:00
$Sounds/show_me.play()
2023-06-05 08:00:14 -06:00
await $Sounds/show_me.finished
2023-01-01 04:28:30 -07:00
for phrase in line:
2023-01-01 14:02:34 -07:00
if completed:
break
2023-01-01 04:28:30 -07:00
var sound = get_node("Sounds/" + phrase)
sound.play()
2023-06-05 08:00:14 -06:00
await sound.finished
2023-01-01 02:23:56 -07:00
2023-06-05 08:00:14 -06:00
signal sig_advance(did_time_out)
2023-01-01 02:23:56 -07:00
func script_loop():
for line in voice_script:
2023-01-01 04:28:30 -07:00
completed = false
$ImpatienceTimer.stop()
2023-06-05 08:00:14 -06:00
await read_line(line)
2023-01-01 04:28:30 -07:00
$ImpatienceTimer.start(impatience)
2023-06-05 08:00:14 -06:00
while not completed and await self.sig_advance:
await read_line(line)
2023-01-01 14:54:37 -07:00
$ImpatienceTimer.start(impatience)
$ImpatienceTimer.stop()
2023-06-05 08:00:14 -06:00
await get_tree().create_timer(3).timeout
2023-01-01 04:28:30 -07:00
2023-06-05 08:00:14 -06:00
var _err = get_tree().change_scene_to_file("res://screens/finished.tscn")
2023-01-01 04:28:30 -07:00
var completed = false
func advance():
2023-01-01 14:02:34 -07:00
current_phrase = null
$ImpatienceTimer.stop()
2023-01-01 04:28:30 -07:00
completed = true
2023-01-01 14:02:34 -07:00
stop_all()
$Victory.play()
2023-06-05 08:00:14 -06:00
await $Victory.finished
await get_tree().create_timer(3).timeout
emit_signal("sig_advance", false)
2023-01-01 04:28:30 -07:00
2023-01-01 14:02:34 -07:00
func check_goal(phrase):
if current_phrase == phrase:
advance()
2023-01-01 04:28:30 -07:00
func _input(_event):
if Input.is_action_just_pressed("cheat"):
advance()
2023-01-01 02:23:56 -07:00
func _on_ImpatienceTimer_timeout():
2023-06-05 08:00:14 -06:00
emit_signal("sig_advance", true)