From 3f4c07d2cf57bd364af6b09a3d5381d148aa713e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 22 Jan 2021 16:40:46 +0100 Subject: New Characters! New Levels! --- Global.gd | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'Global.gd') diff --git a/Global.gd b/Global.gd index cef7b9f..3c8a3a3 100644 --- a/Global.gd +++ b/Global.gd @@ -7,16 +7,16 @@ signal game_ended() signal game_won() -const Levels = [ - "Level_0001", - "Level_0001", - "Level_0001", - "Level_0001", - "Level_0001", - "Level_0001", +var Levels = [ "Level_0001", + "Level_0002", + "Level_0003", "Level_0001", + "Level_0002", + "Level_0003", "Level_0001", + "Level_0002", + "Level_0003", ] var Level_Map = [] @@ -30,6 +30,9 @@ func _ready(): func init(): + randomize() + self.Levels.shuffle() + for level in self.Levels: self.Level_Map.push_back({ time = 0, @@ -116,7 +119,7 @@ func _on_Network_game_ended(winning_player): self.init() -func check_win(): +func has_won(): var has_won = false var cleared_levels_idx = [] @@ -148,5 +151,24 @@ func check_win(): has_won = true break + return has_won + + +func check_win(): + var has_won = self.has_won() + + if has_won: + # TODO: start 10s timer with callback check_win_timer() + # SAVE IN REMOTE ARRAY USERS WITH CROWN = rpc_id + running timer? + # Check for each user that already has a crown if the win condition is still true + # if it's not, delete user from array and stop timer + # if it is, do nothing, keep running until game end + self.check_win_timer() + pass + + +func check_win_timer(): + var has_won = self.has_won() + if has_won: emit_signal("game_won", Network.player) -- cgit v1.2.3