the-crypt/npc/Wizard.gd

54 lines
1.2 KiB
GDScript3
Raw Normal View History

2020-07-22 18:15:21 -05:00
extends KinematicBody2D
var velocity = Vector2.ZERO
var line0 = ""
var line1 = "Good, you've finally made it!"
var line2 = "This will be the final stage of your training."
var line3 = "Even so, this final test will be no picnic..."
var line4 = "I have faith in your abilities, my apprentice."
2020-07-23 19:51:49 -05:00
var line5 = "Go on ahead, I'll meet you at the end of The Crypt."
2020-07-22 18:15:21 -05:00
var lines = [line0, line1, line2, line3, line4, line5]
var line_number = 0
var current_line
2020-07-22 23:57:55 -05:00
signal dialogue_finished
2020-07-22 18:15:21 -05:00
func _process(delta):
var p = Player.position
if p.x > position.x:
$Sprite.flip_h = false
if p.x < position.x:
$Sprite.flip_h = true
current_line = lines[line_number]
$Label.text = current_line
func _physics_process(delta):
velocity.y += 20
velocity = move_and_slide(velocity)
func next_line():
if line_number != 5:
$Typewriter.play("Typewriter")
line_number = clamp(line_number + 1, 0, 5)
else:
$Timer.stop()
2020-07-22 23:57:55 -05:00
emit_signal("dialogue_finished")
do_exit()
2020-07-22 18:15:21 -05:00
pass
func _on_Timer_timeout():
next_line()
func _on_Delay_timeout():
next_line()
$Timer.start()
2020-07-22 23:57:55 -05:00
func do_exit():
$Typewriter.play("Exit")
2020-07-23 19:08:59 -05:00
func _on_CanvasLayer_finished():
Music.get_node("MainMusic").play(0.0)
$Delay.start()