pir-serious-game-ethics/scenes/Main.gd

63 lines
1.6 KiB
GDScript3
Raw Normal View History

extends Node
2021-04-09 10:27:22 +02:00
onready var mini_game = $MiniGame;
2021-04-12 10:26:50 +02:00
var dialogic_node;
2021-04-23 15:59:32 +02:00
var STUDENT_MUSIC = "res://music/etudiant.ogg"
var ENGI_MUSIC = "res://music/ingenieur.ogg"
var USER_MUSIC = "res://music/utilisateur.ogg"
func _ready():
2021-04-23 15:59:32 +02:00
dialogic_node = Dialogic.start_from_save('00_start')
2021-04-12 10:59:06 +02:00
add_child_below_node($MiniGame, dialogic_node)
2021-04-10 18:29:03 +02:00
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
2021-04-23 15:59:32 +02:00
play_music()
func play_music():
var current_phase = Dialogic.get_variable("current_phase")
var music = STUDENT_MUSIC
match current_phase:
"0":
music = STUDENT_MUSIC
"1":
music = ENGI_MUSIC
"2":
music = USER_MUSIC
BackgroundMusic.crossfade_to(music, -10, 1)
func _on_Dialogic_signal_received(value: String):
2021-04-09 10:27:22 +02:00
var args = value.split(" ")
if args.size() > 0:
var type = args[0];
match type:
2021-04-23 15:59:32 +02:00
"play_music":
play_music()
2021-04-09 10:27:22 +02:00
"start_minigame":
start_minigame()
"setup_minigame":
if (args.size() >= 3):
2021-04-11 18:09:08 +02:00
setup_minigame(args[1], args[2], args[3])
2021-04-09 10:27:22 +02:00
else:
print("not enough arguments for start_minigame")
2021-04-26 17:41:28 +02:00
"end_game":
Transit.change_scene("res://scenes/animal/AnimalScene.tscn", 1)
2021-04-09 10:27:22 +02:00
_:
print("wrong type")
2021-03-25 22:47:09 +01:00
2021-04-09 10:27:22 +02:00
2021-04-11 18:09:08 +02:00
func setup_minigame(mode: String, next_timeline_lose: String, next_timeline_win):
mini_game.setup(mode, next_timeline_lose, next_timeline_win)
2021-04-09 10:27:22 +02:00
func start_minigame():
mini_game.start()
func _on_MiniGame_game_over(next_timeline: String):
2021-04-12 10:26:50 +02:00
dialogic_node = Dialogic.start(next_timeline)
2021-04-19 19:14:02 +02:00
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
2021-04-12 10:59:06 +02:00
add_child_below_node($MiniGame, dialogic_node)