mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2025-02-04 12:28:35 +00:00
Multiplayer: Add Lobby
This commit is contained in:
@@ -29,22 +29,15 @@ func _ready():
|
||||
get_node("ConfirmationDialog").get_cancel().text = "No"
|
||||
get_node("ConfirmationDialog").get_ok().rect_min_size.x = 100
|
||||
get_node("ConfirmationDialog").get_cancel().rect_min_size.x = 100
|
||||
|
||||
if multiplayer:
|
||||
# TODO: Spawn a lobby where people can either connect to a peer or create a server
|
||||
pass
|
||||
|
||||
game_setup()
|
||||
|
||||
# Function used to keep track of which players are ready
|
||||
# TODO: Change this to keep track of ready states only
|
||||
func player_ready():
|
||||
var who = get_tree().get_rpc_sender_id()
|
||||
if get_tree().is_network_server() and who in Net.peer_info and not who in players_ready:
|
||||
print ("ASSERT SUCCESS")
|
||||
players_ready.append(who)
|
||||
|
||||
if players_ready.size() == Net.peer_info.size():
|
||||
rpc("game_start")
|
||||
pass
|
||||
|
||||
# Member functions:
|
||||
# game_start: starts the game
|
||||
@@ -54,45 +47,39 @@ sync func game_setup():
|
||||
# TODO: Create a fake peer who we can automate, for single-player mode
|
||||
Net.start_host()
|
||||
network_id = Net.get_network_id()
|
||||
# Create players for every player in Net.peer_info
|
||||
for k in Net.peer_info.keys():
|
||||
# Create a new player
|
||||
var player = Player.instance()
|
||||
# Give the player a recognizable name, like "1", instead of "@@97"
|
||||
player.name = str(k)
|
||||
# The player controls themselves
|
||||
player.set_network_master(k)
|
||||
# Add the player to the list of players
|
||||
players.append(player)
|
||||
# Add the player to the scene tree
|
||||
add_child(player)
|
||||
pass
|
||||
|
||||
# game_start:
|
||||
func game_start():
|
||||
# Make sure we're the server
|
||||
pass
|
||||
|
||||
# _on_player_ready: Player Ready signal handler
|
||||
func _on_player_ready():
|
||||
print ("_on_player_ready")
|
||||
rpc_id(1, "player_ready")
|
||||
Net.send(1, ["player_ready", Net.Mail.REPLY])
|
||||
|
||||
# victory_screen: display the victory screen
|
||||
func victory_screen():
|
||||
# TODO: Create the victory screen, fill it with knowledge
|
||||
pass
|
||||
|
||||
# display_turn(): display which turn it is on the screen
|
||||
# display_turn: display which turn it is on the screen
|
||||
func display_turn():
|
||||
# TODO: Update the turn display, if there is one?
|
||||
pass
|
||||
|
||||
# _on_Forfeit_pressed: Handle forfeit button press
|
||||
func _on_Forfeit_pressed():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
get_node("ConfirmationDialog").popup()
|
||||
|
||||
# end: end the Game
|
||||
func end():
|
||||
queue_free()
|
||||
|
||||
# _on_Button_button_down: Handle win button press
|
||||
# TODO: This isn't a thing any more
|
||||
func _on_Button_button_down():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
var victory = Victory.instance()
|
||||
|
||||
Reference in New Issue
Block a user