Added Disconnect screen

This commit is contained in:
Kristofers Solo 2021-10-30 18:11:59 +03:00
parent f265c7236e
commit e113e1d250
3 changed files with 16 additions and 10 deletions

View File

@ -33,9 +33,10 @@ func _process(delta: float) -> void:
func _physics_process(delta): func _physics_process(delta):
if is_network_master(): if get_tree().has_network_peer():
mode_switch(delta) if is_network_master():
screen_wrap() mode_switch(delta)
screen_wrap()
func mode_switch(delta): func mode_switch(delta):
@ -117,10 +118,11 @@ func _network_peer_connected(id) -> void:
func _on_network_tick_rate_timeout(): func _on_network_tick_rate_timeout():
if is_network_master(): if get_tree().has_network_peer():
rset_unreliable("puppet_position", global_position) if is_network_master():
rset_unreliable("puppet_velocity", velocity) rset_unreliable("puppet_position", global_position)
rset_unreliable("puppet_rotation", rotation_degrees) rset_unreliable("puppet_velocity", velocity)
rset_unreliable("puppet_rotation", rotation_degrees)
sync func update_position(pos): sync func update_position(pos):

View File

@ -78,7 +78,7 @@ func _client_connection_timeout():
print("Client has been timed out") print("Client has been timed out")
reset_network_connection() reset_network_connection()
var connection_timeout_prompt = Global.instance_node(load("res://Simple_prompt.tscn"), get_tree().current_scene) var connection_timeout_prompt = Global.instance_node(load("res://scenes/simple_prompt.tscn"), get_tree().current_scene)
connection_timeout_prompt.set_text("Connection timed out") connection_timeout_prompt.set_text("Connection timed out")
@ -89,7 +89,7 @@ func _connection_failed():
reset_network_connection() reset_network_connection()
if Global.ui != null: if Global.ui != null:
var prompt = Global.instance_node(load("res://Simple_prompt.tscn"), Global.ui) var prompt = Global.instance_node(load("res://scenes/simple_prompt.tscn"), Global.ui)
prompt.set_text("Connection failed") prompt.set_text("Connection failed")

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/floor.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/floor.tscn" type="PackedScene" id=1]
[ext_resource path="res://code/game.gd" type="Script" id=2] [ext_resource path="res://code/game.gd" type="Script" id=2]
[ext_resource path="res://code/UI.gd" type="Script" id=3]
[node name="game" type="Node2D"] [node name="game" type="Node2D"]
script = ExtResource( 2 ) script = ExtResource( 2 )
@ -23,3 +24,6 @@ position = Vector2( 512, 270 )
[node name="4" type="Position2D" parent="spawn_locations"] [node name="4" type="Position2D" parent="spawn_locations"]
position = Vector2( 1408, 270 ) position = Vector2( 1408, 270 )
[node name="UI" type="CanvasLayer" parent="."]
script = ExtResource( 3 )