extends Panel var players_selected = {} var bg_color_selected = '#fffba5' var style_selected = StyleBoxFlat.new() var style_deselected = StyleBoxFlat.new() func _ready(): self.style_selected.set_bg_color(self.bg_color_selected) self.style_deselected.set_bg_color(Color(0, 0, 0, 0)) self.set_Wait_text() func set_Wait_text(): $Wait.text = "Waiting for " + str(Network.get_player_count() - self.players_selected.size()) + " players to choose" func set_bg_color_selected(character, previous_character = null): if previous_character: get_node(previous_character + "Panel").set("custom_styles/panel", self.style_deselected) get_node(character + "Panel").set("custom_styles/panel", self.style_selected) func _button_pressed(event, character): if event is InputEventMouseButton or event is InputEventKey: if event.pressed: rpc("_character_selected", character) self.set_bg_color_selected(character, Network.player.character) Network.player.character = character sync func _character_selected(character): var id = get_tree().get_rpc_sender_id() if Network.players.has(id): Network.players[id].character = character self.players_selected[id] = true self.set_Wait_text() if Network.get_player_count() == self.players_selected.size(): get_tree().change_scene("res://UI/LevelSelect.tscn")