diff options
Diffstat (limited to 'UI/CharacterSelect.gd')
-rw-r--r-- | UI/CharacterSelect.gd | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/UI/CharacterSelect.gd b/UI/CharacterSelect.gd new file mode 100644 index 0000000..fc84a35 --- /dev/null +++ b/UI/CharacterSelect.gd @@ -0,0 +1,30 @@ +extends Panel + + +var players_selected = {} + + +func _ready(): + 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 _button_pressed(event, character): + if event is InputEventMouseButton or event is InputEventKey: + if event.pressed: + rpc("_character_selected", 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") |