diff options
Diffstat (limited to 'Global.gd')
-rw-r--r-- | Global.gd | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -38,9 +38,9 @@ func init_level_map(): for level in self.Levels: self.Level_Map.push_back({ time = 0, - cleared_by = { # Network.player - idx = -1, - name = "" + cleared_by = { + id = -1, + player = Network.create_player(), # NetworkPlayer }, meta = { path = "res://Levels/%s.tscn" % level, @@ -72,6 +72,9 @@ func get_instance_level(idx): func start_level(idx): + Network.player.current_level = idx + Network.update_player() + var instance_level = self.get_instance_level(idx) self.change_scene_to_instance(instance_level) @@ -82,7 +85,10 @@ func end_level(instance_level): var time = snapped(instance_level.timer, 0.01) if (global_level.time == 0 or time < global_level.time): global_level.time = time - global_level.cleared_by = Network.player + global_level.cleared_by = { + id = Network.peer.get_unique_id(), + player = Network.player, + } for id in Network.players: rpc_id(id, "_update_level_map", instance_level.idx, global_level) @@ -92,6 +98,8 @@ func end_level(instance_level): func cancel_level(): + Network.player.current_level = -1 + Network.update_player() get_tree().change_scene_to_file("res://UI/LevelSelect.tscn") @@ -118,12 +126,12 @@ func _on_Network_game_ended(): self.init() -func has_won(): +func check_has_won(): var has_won = false var cleared_levels_idx = [] for idx in range(self.Level_Map.size()): - if self.Level_Map[idx].cleared_by.idx == Network.player.idx: + if self.Level_Map[idx].cleared_by.id == Network.peer.get_unique_id(): cleared_levels_idx.push_back(idx) var possible_winning_conditions = [ @@ -154,7 +162,7 @@ func has_won(): func check_win(): - var has_won = self.has_won() + var has_won = self.check_has_won() if has_won: # TODO: start 10s timer with callback check_win_timer() @@ -167,9 +175,9 @@ func check_win(): func check_win_timer(): - var has_won = self.has_won() + #var has_won = self.check_has_won() - if self.has_won(): + if self.check_has_won(): emit_signal("game_won", Network.player) |