summaryrefslogtreecommitdiff
path: root/UI/CharacterSelect.gd
blob: fc84a3544de5fa417b8c32d0be070c22236cbe50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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")