1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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
- onready var start_timer_UI := $start_timer_UI
- onready var instructionsUI := $instructionsUI
-
- var next_timeline_lose := ""
- var next_timeline_win := ""
-
- var game_mode = ""
-
-
- func _ready():
- Signals.connect("die", self, "on_game_over")
- Signals.connect("win", self, "on_win")
-
-
- func setup(mode: String, next_lose: String, next_win: String):
- print("minigame: " + mode + " " + next_lose + " " + next_win)
- set_mode(mode)
- scoreUI.init(mode)
- next_timeline_lose = next_lose
- next_timeline_win = next_win
-
-
- func set_mode(mode: String):
- match mode:
- "score":
- game_mode = "score"
- "time":
- game_mode = "time"
- _:
- print("unkonwn mini-game mode")
-
-
- func start():
- print("starting minigame")
- start_timer_UI.init()
- var t = Timer.new()
- t.set_wait_time(1)
- add_child(t)
- t.start()
- for n in range(3,0,-1):
- start_timer_UI.update_timer(String(n))
- yield(t, "timeout")
- start_timer_UI.update_timer("GO !")
- foreground.start()
- player.start(game_mode)
- spawner.start()
- instructionsUI._init()
- scoreUI.start(game_mode)
- yield(t, "timeout")
- start_timer_UI.hide()
-
-
- func stop():
- foreground.stop()
- player.stop()
- spawner.stop()
-
-
- func on_win():
- stop()
- emit_signal("game_over", next_timeline_win)
-
- func on_game_over():
- stop()
- emit_signal("game_over", next_timeline_lose)
|