51 lines
1.3 KiB
GDScript
51 lines
1.3 KiB
GDScript
extends Node
|
|
class_name IntroScript
|
|
|
|
export (NodePath) var dialogue_box_path
|
|
onready var dialogue_box = get_node(dialogue_box_path)
|
|
|
|
export (NodePath) var herbert_sprite_path
|
|
onready var herbert_sprite = get_node(herbert_sprite_path)
|
|
|
|
export (String, FILE, '*.json') var intro_dialogue : String
|
|
|
|
func _ready():
|
|
assert(dialogue_box != null)
|
|
assert(herbert_sprite != null)
|
|
|
|
yield(get_tree().create_timer(2.0), 'timeout')
|
|
yield(start_dialogue(intro_dialogue), 'end')
|
|
yield(get_tree().create_timer(2.0), 'timeout')
|
|
do_crab_step()
|
|
|
|
func start_dialogue(dialog_path : String) -> DialogueAction:
|
|
var dialogue = DialogueAction.new()
|
|
dialogue.dialogue_file_path = dialog_path
|
|
dialogue.dialogue_box = dialogue_box
|
|
dialogue.start()
|
|
return dialogue
|
|
|
|
var crab_finished = false
|
|
var crab_step = 0
|
|
func do_crab_step():
|
|
crab_finished = false
|
|
herbert_sprite.frame = 0
|
|
if crab_step == 0:
|
|
herbert_sprite.connect('animation_finished', self, 'crab_animation_finished')
|
|
herbert_sprite.play('eyes')
|
|
herbert_sprite.show()
|
|
elif crab_step == 1:
|
|
herbert_sprite.play('first_step')
|
|
elif crab_step == 2:
|
|
herbert_sprite.play('second_step')
|
|
elif crab_step == 3:
|
|
herbert_sprite.hide()
|
|
crab_step += 1
|
|
|
|
func crab_animation_finished():
|
|
crab_finished = true
|
|
|
|
func _input(event):
|
|
if crab_finished && event.is_action_pressed('ui_accept'):
|
|
do_crab_step()
|