Round system
This commit is contained in:
parent
bcb42f8d16
commit
3df8247a84
32 changed files with 573 additions and 123 deletions
|
|
@ -9,10 +9,15 @@ signal lobby_joined
|
|||
signal lobby_closed
|
||||
signal update_teams_state
|
||||
|
||||
var in_lobby: bool = false
|
||||
|
||||
var attack_team: Array[int] = []
|
||||
var defence_team: Array[int] = []
|
||||
var specators_team: Array[int] = []
|
||||
|
||||
var win_score = 13
|
||||
var half_rounds = 12
|
||||
|
||||
func _ready() -> void:
|
||||
multiplayer.peer_disconnected.connect(player_left)
|
||||
multiplayer.server_disconnected.connect(server_disconnected)
|
||||
|
|
@ -36,6 +41,7 @@ func host() -> void:
|
|||
multiplayer.multiplayer_peer = peer
|
||||
lobby_created.emit()
|
||||
specators_team.append(multiplayer.get_unique_id())
|
||||
in_lobby = true
|
||||
|
||||
func join(ip: String) -> Error:
|
||||
var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
||||
|
|
@ -44,6 +50,7 @@ func join(ip: String) -> Error:
|
|||
return res
|
||||
multiplayer.multiplayer_peer = peer
|
||||
lobby_joined.emit()
|
||||
in_lobby = true
|
||||
return Error.OK
|
||||
|
||||
func leave() -> void:
|
||||
|
|
@ -52,6 +59,7 @@ func leave() -> void:
|
|||
defence_team.clear()
|
||||
specators_team.clear()
|
||||
lobby_closed.emit()
|
||||
in_lobby = false
|
||||
|
||||
func add_and_sync_peer(id: int) -> void:
|
||||
if multiplayer.is_server() == false:
|
||||
|
|
@ -100,3 +108,16 @@ func team_switch_notification(id: int, team: int) -> void:
|
|||
@rpc("authority","call_local","reliable")
|
||||
func start_game() -> void:
|
||||
get_tree().change_scene_to_file("res://levels/prototype_scene.tscn")
|
||||
if multiplayer.is_server():
|
||||
await get_tree().scene_changed
|
||||
Session.start_session()
|
||||
|
||||
func get_team() -> Session.TEAMS:
|
||||
var id = multiplayer.get_unique_id()
|
||||
if attack_team.has(id):
|
||||
return Session.TEAMS.ATTACK
|
||||
if defence_team.has(id):
|
||||
return Session.TEAMS.DEFENCE
|
||||
if specators_team.has(id):
|
||||
return Session.TEAMS.SPECTATE
|
||||
return Session.TEAMS.UNASSIGNED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue