diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-01-09 23:30:27 +0100 |
commit | 485cd463b22e12394cd232812e2c3789ef37ab1c (patch) | |
tree | 5c455ec9c80b59a9f71ba5827b9902f2beb6df88 /Global.gd | |
parent | 7920e8758506cd46c58ea4889c9f4fb704abfd16 (diff) |
Adds a bunch of characters and fixes things
Diffstat (limited to 'Global.gd')
-rw-r--r-- | Global.gd | 47 |
1 files changed, 40 insertions, 7 deletions
@@ -2,6 +2,8 @@ extends Node signal level_map_updated() +signal game_started() +signal game_ended() signal game_won() @@ -21,8 +23,13 @@ var Level_Map = [] func _ready(): - Network.connect("game_ended", self, "_on_game_end") + Network.connect("game_started", self, "_on_Network_game_started") + Network.connect("game_ended", self, "_on_Network_game_ended") + self.init() + + +func init(): for level in self.Levels: self.Level_Map.push_back({ time = 0, @@ -49,12 +56,18 @@ func get_level(idx): return self.Level_Map[idx] -func start_level(idx): +func get_instance_level(idx): var global_level = self.get_level(idx) var Level = load(global_level.meta.path) var instance_level = Level.instance() instance_level.idx = idx + + return instance_level + + +func start_level(idx): + var instance_level = self.get_instance_level(idx) self.change_scene_to_instance(instance_level) @@ -73,11 +86,36 @@ func end_level(instance_level): self.check_win() +func cancel_level(): + get_tree().change_scene("res://UI/LevelSelect.tscn") + + remote func _update_level_map(idx, global_level): self.Level_Map[idx] = global_level emit_signal("level_map_updated") +func start_game(): + emit_signal("game_started") + + +func _on_Network_game_started(): + get_tree().change_scene("res://UI/CharacterSelect.tscn") + + +func end_game(): + emit_signal("game_ended") + + +func _on_Network_game_ended(winning_player): + # TODO: change scene for all to win scene and set winning player id, + # so it can be displayed with self.players + print(winning_player) + get_tree().change_scene("res://Network/Lobby.tscn") + self.Level_Map = [] + self.init() + + func check_win(): var has_won = false @@ -112,8 +150,3 @@ func check_win(): if has_won: emit_signal("game_won", Network.player) - - -func _on_game_end(): - self.Level_Map = [] - self._ready() |