43 lines
1.1 KiB
GDScript
43 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
onready var mini_game = $MiniGame;
|
|
|
|
var dialogic_node;
|
|
|
|
func _ready():
|
|
dialogic_node = Dialogic.start_from_save('0_start')
|
|
add_child_below_node($MiniGame, dialogic_node)
|
|
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
|
|
|
|
|
func _on_Dialogic_signal_received(value: String):
|
|
print("signal received")
|
|
var args = value.split(" ")
|
|
if args.size() > 0:
|
|
var type = args[0];
|
|
match type:
|
|
"start_minigame":
|
|
start_minigame()
|
|
"setup_minigame":
|
|
if (args.size() >= 3):
|
|
setup_minigame(args[1], args[2], args[3])
|
|
else:
|
|
print("not enough arguments for start_minigame")
|
|
_:
|
|
print("wrong type")
|
|
|
|
|
|
func setup_minigame(mode: String, next_timeline_lose: String, next_timeline_win):
|
|
mini_game.setup(mode, next_timeline_lose, next_timeline_win)
|
|
|
|
|
|
func start_minigame():
|
|
mini_game.start()
|
|
|
|
|
|
func _on_MiniGame_game_over(next_timeline: String):
|
|
print("Game over received")
|
|
print("next timeline: " + next_timeline)
|
|
dialogic_node = Dialogic.start(next_timeline)
|
|
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
|
add_child_below_node($MiniGame, dialogic_node)
|