Usable multiplayer

This commit is contained in:
2024-08-05 19:08:28 +08:00
parent c5387d7784
commit 3788e640a9
7 changed files with 189 additions and 43 deletions

View File

@ -1,13 +1,32 @@
[gd_scene load_steps=4 format=3 uid="uid://b3gx0bl43lku3"]
[gd_scene load_steps=7 format=3 uid="uid://b3gx0bl43lku3"]
[ext_resource type="Script" path="res://Scripts/Player.cs" id="1_0btyt"]
[ext_resource type="Texture2D" uid="uid://c4als6t3k4myc" path="res://Sprites/Player.png" id="1_cqpqa"]
[ext_resource type="Script" path="res://Scripts/Logic/PlayerInput.cs" id="3_tvoua"]
[sub_resource type="CircleShape2D" id="CircleShape2D_68yf8"]
radius = 26.0768
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("PlayerDashCountdown")]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_bekoo"]
properties/0/path = NodePath(".:position")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath(".:PlayerId")
properties/1/spawn = true
properties/1/replication_mode = 1
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_hojn2"]
properties/0/path = NodePath("InputSynchronizer:IsDashing")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath("InputSynchronizer:MovementDirection")
properties/1/spawn = true
properties/1/replication_mode = 1
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("PlayerCamera", "PlayerInput", "PlayerDashCountdown")]
script = ExtResource("1_0btyt")
PlayerCamera = NodePath("Camera2D")
PlayerInput = NodePath("InputSynchronizer")
PlayerDashCountdown = NodePath("DashCountdown")
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -18,5 +37,18 @@ texture = ExtResource("1_cqpqa")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_68yf8")
[node name="Camera2D" type="Camera2D" parent="."]
enabled = false
process_callback = 0
position_smoothing_enabled = true
rotation_smoothing_enabled = true
[node name="DashCountdown" type="Timer" parent="."]
one_shot = true
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_bekoo")
[node name="InputSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_hojn2")
script = ExtResource("3_tvoua")

View File

@ -1,26 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://bjhmjrldq4lkt"]
[gd_scene load_steps=5 format=3 uid="uid://bjhmjrldq4lkt"]
[ext_resource type="Script" path="res://Scripts/Multiplayer.cs" id="1_fym13"]
[ext_resource type="PackedScene" uid="uid://b3gx0bl43lku3" path="res://Scenes/Player.tscn" id="1_vby0g"]
[ext_resource type="PackedScene" uid="uid://bvll23f5ibd4v" path="res://Scenes/UI/MultiplayerUI.tscn" id="2_7o53i"]
[ext_resource type="Script" path="res://Scripts/Logic/World.cs" id="3_xwguj"]
[node name="Node" type="Node"]
[node name="MultiplayerNode" type="Node" parent="." node_paths=PackedStringArray("Playground")]
[node name="MultiplayerNode" type="Node" parent="." node_paths=PackedStringArray("World")]
script = ExtResource("1_fym13")
Playground = NodePath("../Playground")
World = NodePath("../World")
[node name="MultiplayerUi" parent="." node_paths=PackedStringArray("MultiplayerController") instance=ExtResource("2_7o53i")]
MultiplayerController = NodePath("../MultiplayerNode")
[node name="Playground" type="Node2D" parent="."]
[node name="World" type="Node2D" parent="."]
script = ExtResource("3_xwguj")
PlayerScene = ExtResource("1_vby0g")
[node name="Camera2D" type="Camera2D" parent="Playground"]
enabled = false
process_callback = 0
position_smoothing_enabled = true
rotation_smoothing_enabled = true
[node name="Player" parent="Playground" node_paths=PackedStringArray("PlayerCamera") instance=ExtResource("1_vby0g")]
position = Vector2(0, 2)
PlayerCamera = NodePath("../Camera2D")
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
_spawnable_scenes = PackedStringArray("res://Scenes/Player.tscn")
spawn_path = NodePath("../World")