extends Node

signal game_over

onready var background := $background
onready var foreground := $foreground
onready var spawner := $spawner
onready var player := $player2
onready var scoreUI := $scoreUI

var next_timeline := ""

func _ready():
	Signals.connect("die", self, "on_game_over")


func setup(mode: String, next: String):
	print("minigame: " + mode + " " + next)
	set_mode(mode)
	scoreUI.init()
	next_timeline = next


func set_mode(mode: String):
	match mode:
		_:
			print("unkonwn mini-game mode")
	

func start():
	print("starting minigame")
	foreground.start()
	player.start()
	spawner.start()


func stop():
	foreground.stop()
	player.stop()
	spawner.stop()
	


func on_game_over():
	stop()
	emit_signal("game_over", next_timeline)
