29 lines
660 B
GDScript
29 lines
660 B
GDScript
extends Node
|
|
class_name DialogueEncounter
|
|
|
|
var dialogue: DialogueScene
|
|
signal step()
|
|
|
|
func _init(path: Resource) -> void:
|
|
self.dialogue = path
|
|
await Start()
|
|
|
|
func _input(_event: InputEvent) -> void:
|
|
if Input.is_action_just_pressed("ui_accept"):
|
|
step.emit()
|
|
|
|
func Start():
|
|
await walk_scene(self.dialogue)
|
|
|
|
func walk_scene(next_scene: DialogueScene):
|
|
print("walking scene")
|
|
for dia : Dialogue in next_scene.get_scene():
|
|
print(dia.dialogue_str)
|
|
if dia.choices.size() > 0:
|
|
for choice: Choice in dia.choices:
|
|
print(choice.response)
|
|
if Input.is_key_pressed(KEY_1):
|
|
await walk_scene(dia.choices[0].get_target())
|
|
step.emit()
|
|
await step
|