Internet/Local/Hotseat working (still need to test for bugs). ALso get an RPC error because we switch scene...

This commit is contained in:
Sch1nken 2024-03-24 03:30:54 +01:00
parent c95b8186ab
commit c4909db2a5
654 changed files with 18133 additions and 39 deletions

54
UI/Lobby/WebRTCHost.gd Normal file
View file

@ -0,0 +1,54 @@
extends VBoxContainer
@onready var lobby_label = $VBoxContainer/HBoxContainer/LobbyLabel
@onready var session_info = $VBoxContainer/SessionInfo
@onready var start_game_button = $VBoxContainer/StartGameButton
func start_hosting() -> void:
Networking.start_webrtc_lobby()
func stop_hosting() -> void:
Networking.stop_webrtc()
lobby_label.text = ""
session_info.text = ""
func show_panel() -> void:
lobby_label.text = ""
start_hosting()
visible = true
func hide_panel() -> void:
stop_hosting()
start_game_button.disabled = true
visible = false
# Called when the node enters the scene tree for the first time.
func _ready():
Networking.ws_client.lobby_joined.connect(_on_lobby_joined)
lobby_label.text = ""
multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
func _on_peer_connected(id: int) -> void:
GameData.peer_id = id
session_info.text = "Opponent connected"
start_game_button.disabled = false
func _on_peer_disconnected(id: int) -> void:
GameData.peer_id = 1
session_info.text = "Opponent disconnected"
start_game_button.disabled = true
func _on_lobby_joined(lobby_id: String) -> void:
lobby_label.text = lobby_id
session_info.text = "Waiting for opponent..."
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_back_button_pressed():
pass # Replace with function body.