Working prototype

This commit is contained in:
Sch1nken 2024-03-16 19:56:22 +01:00
parent 3de181134d
commit 1ed0ec226d
24 changed files with 682 additions and 31 deletions

View file

@ -4,6 +4,8 @@ var has_opponent: bool = false
@onready var start_game_button = $LobbyInfo/PanelContainer/VBoxContainer/StartGameButton
@onready var game = $Game
var game_in_progress: bool = false
func _ready():
multiplayer.connected_to_server.connect(_mp_server_connected)
multiplayer.connection_failed.connect(_mp_server_disconnect)
@ -15,7 +17,9 @@ func _mp_peer_disconnected(id: int) -> void:
has_opponent = false
start_game_button.disabled = true
if id == 1:
if game_in_progress or id == 1:
GameData.disconnect_reason = "Other peer terminated the connection"
# Display message that other end terminated the connection
# 1 is always the server
# So we better get going back to the main menu?
WSClient.close()
@ -32,7 +36,7 @@ func _mp_server_connected():
func _mp_server_disconnect():
_log("[Multiplayer] Server disconnected (I am %d)" % WSClient.rtc_mp.get_unique_id())
get_tree().change_scene_to_file("res://main_menu.tscn")
#get_tree().change_scene_to_file("res://main_menu.tscn")
func _mp_peer_connected(id: int):
_log("[Multiplayer] Peer %d connected" % id)
@ -50,6 +54,7 @@ func _process(delta):
func load_game() -> void:
# Hide menu
# load game scene
game_in_progress = true
lobby_info.visible = false
var game_scene = preload("res://Game.tscn").instantiate()
game.add_child(game_scene)