diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 08:48:41 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 08:48:41 +0100 |
commit | 2a9cbb1fa0268c3be828c0d872180282704abb61 (patch) | |
tree | 4d2a9f805af004a7b960e7918b5d34ddfed7f2c8 /Global.gd | |
parent | 2a5d745c68f11131fb1b27ec42a30ecd6dc5da1d (diff) |
show other player puppetsv2.2.0
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) |