mirror of
https://github.com/Steffo99/nanogolf.git
synced 2024-11-21 23:54:21 +00:00
???????'
This commit is contained in:
parent
b8af4952d7
commit
30b6fe23fe
4 changed files with 18 additions and 7 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -12,7 +12,7 @@
|
||||||
"debug_collisions": false,
|
"debug_collisions": false,
|
||||||
"debug_paths": false,
|
"debug_paths": false,
|
||||||
"debug_navigation": false,
|
"debug_navigation": false,
|
||||||
"additional_options": ""
|
"additional_options": "--verbose",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -21,6 +21,10 @@ var local_player_color: Color
|
||||||
@export var level_manager: LevelManager = null
|
@export var level_manager: LevelManager = null
|
||||||
|
|
||||||
|
|
||||||
|
## Emitted when the player has requested to exit from the game.
|
||||||
|
signal leave_confirmed
|
||||||
|
|
||||||
|
|
||||||
## Initialize some signals needed by this node to function properly.
|
## Initialize some signals needed by this node to function properly.
|
||||||
func init_signals() -> void:
|
func init_signals() -> void:
|
||||||
multiplayer.connected_to_server.connect(_on_multiplayer_connected_to_server)
|
multiplayer.connected_to_server.connect(_on_multiplayer_connected_to_server)
|
||||||
|
@ -38,6 +42,7 @@ func _on_multiplayer_disconnected_from_server() -> void:
|
||||||
|
|
||||||
func _on_multiplayer_connection_failed() -> void:
|
func _on_multiplayer_connection_failed() -> void:
|
||||||
Log.peer(self, "Connection failed...")
|
Log.peer(self, "Connection failed...")
|
||||||
|
leave_confirmed.emit()
|
||||||
|
|
||||||
func _on_multiplayer_peer_connected(peer_id: int) -> void:
|
func _on_multiplayer_peer_connected(peer_id: int) -> void:
|
||||||
Log.peer(self, "Peer connected: %d" % peer_id)
|
Log.peer(self, "Peer connected: %d" % peer_id)
|
||||||
|
|
|
@ -44,11 +44,12 @@ func init_server_game(server_port: int) -> void:
|
||||||
|
|
||||||
scene_tree.set_multiplayer(smp, ^"/root/Main/Server")
|
scene_tree.set_multiplayer(smp, ^"/root/Main/Server")
|
||||||
server_game_instance.init_signals()
|
server_game_instance.init_signals()
|
||||||
|
server_game_instance.leave_confirmed.connect(_on_leave_confirmed)
|
||||||
smp.set_multiplayer_peer(peer)
|
smp.set_multiplayer_peer(peer)
|
||||||
|
|
||||||
func deinit_server_game() -> void:
|
func deinit_server_game() -> void:
|
||||||
server_game_instance.multiplayer.multiplayer_peer = null
|
server_game_instance.multiplayer.multiplayer_peer = null
|
||||||
scene_tree.set_multiplayer(multiplayer, ^"/root/Main/Server")
|
scene_tree.set_multiplayer(null, ^"/root/Main/Server")
|
||||||
server_game_instance.queue_free()
|
server_game_instance.queue_free()
|
||||||
server_game_instance = null
|
server_game_instance = null
|
||||||
|
|
||||||
|
@ -70,12 +71,12 @@ func init_client_game(player_name: String, player_color: Color, server_address:
|
||||||
client_game_instance.local_player_name = player_name
|
client_game_instance.local_player_name = player_name
|
||||||
client_game_instance.local_player_color = player_color
|
client_game_instance.local_player_color = player_color
|
||||||
client_game_instance.phase_tracker.phase_changed.connect(_on_phase_changed)
|
client_game_instance.phase_tracker.phase_changed.connect(_on_phase_changed)
|
||||||
|
client_game_instance.leave_confirmed.connect(_on_leave_confirmed)
|
||||||
smp.set_multiplayer_peer(peer)
|
smp.set_multiplayer_peer(peer)
|
||||||
|
|
||||||
func deinit_client_game() -> void:
|
func deinit_client_game() -> void:
|
||||||
client_game_instance.phase_tracker.phase_changed.disconnect(_on_phase_changed)
|
|
||||||
client_game_instance.multiplayer.multiplayer_peer = null
|
client_game_instance.multiplayer.multiplayer_peer = null
|
||||||
scene_tree.set_multiplayer(multiplayer, ^"/root/Main/Client")
|
scene_tree.set_multiplayer(null, ^"/root/Main/Client")
|
||||||
client_game_instance.queue_free()
|
client_game_instance.queue_free()
|
||||||
client_game_instance = null
|
client_game_instance = null
|
||||||
|
|
||||||
|
@ -144,9 +145,11 @@ func _on_connecting_confirmed(player_name: String, player_color: Color, server_a
|
||||||
init_lobby_menu()
|
init_lobby_menu()
|
||||||
|
|
||||||
func _on_leave_confirmed() -> void:
|
func _on_leave_confirmed() -> void:
|
||||||
if lobby_menu_scene:
|
if lobby_menu_instance != null:
|
||||||
deinit_lobby_menu()
|
deinit_lobby_menu()
|
||||||
if client_game_instance:
|
if game_hud_instance != null:
|
||||||
|
deinit_game_hud()
|
||||||
|
if client_game_instance != null:
|
||||||
deinit_client_game()
|
deinit_client_game()
|
||||||
if server_game_instance != null:
|
if server_game_instance != null:
|
||||||
deinit_server_game()
|
deinit_server_game()
|
||||||
|
|
|
@ -3,4 +3,7 @@ class_name Log
|
||||||
|
|
||||||
|
|
||||||
static func peer(this: Node, string: String):
|
static func peer(this: Node, string: String):
|
||||||
|
if this.multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
|
||||||
print("{", this.multiplayer.multiplayer_peer.get_unique_id(), "} [", str(this), "] ", string)
|
print("{", this.multiplayer.multiplayer_peer.get_unique_id(), "} [", str(this), "] ", string)
|
||||||
|
else:
|
||||||
|
print("{---} [", str(this), "] ", string)
|
||||||
|
|
Loading…
Reference in a new issue