diff --git a/Scenes/Brick.tscn b/Scenes/Brick.tscn index 5724382..ecee795 100644 --- a/Scenes/Brick.tscn +++ b/Scenes/Brick.tscn @@ -6,16 +6,16 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_5wmf4"] size = Vector2(51.2, 51.2) -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_r3565"] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ccaja"] properties/0/path = NodePath(".:position") properties/0/spawn = true -properties/0/replication_mode = 0 -properties/1/path = NodePath(".:DecayProgress") +properties/0/replication_mode = 1 +properties/1/path = NodePath(".:PlayerId") properties/1/spawn = true -properties/1/replication_mode = 0 -properties/2/path = NodePath(".:MaxDecayProgress") +properties/1/replication_mode = 1 +properties/2/path = NodePath(".:DecayProgress") properties/2/spawn = true -properties/2/replication_mode = 0 +properties/2/replication_mode = 1 [node name="Brick" type="StaticBody2D"] script = ExtResource("1_u0jqj") @@ -33,4 +33,4 @@ wait_time = 0.1 autostart = true [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] -replication_config = SubResource("SceneReplicationConfig_r3565") +replication_config = SubResource("SceneReplicationConfig_ccaja") diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index 7e443ab..b6220dc 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -115,6 +115,10 @@ one_shot = true wait_time = 0.05 one_shot = true +[node name="WeaponCountdown" type="Timer" parent="."] +wait_time = 0.1 +one_shot = true + [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] replication_config = SubResource("SceneReplicationConfig_bekoo") diff --git a/Scenes/UI/HUD.tscn b/Scenes/UI/HUD.tscn index 6310bb4..f899fab 100644 --- a/Scenes/UI/HUD.tscn +++ b/Scenes/UI/HUD.tscn @@ -38,6 +38,7 @@ text = "Health 100/100" custom_minimum_size = Vector2(2.08165e-12, 16) layout_mode = 2 size_flags_horizontal = 3 +max_value = 1.0 rounded = true allow_greater = true allow_lesser = true @@ -56,6 +57,7 @@ horizontal_alignment = 1 custom_minimum_size = Vector2(2.08165e-12, 16) layout_mode = 2 size_flags_horizontal = 3 +max_value = 1.0 rounded = true allow_greater = true allow_lesser = true diff --git a/Scripts/Brick.cs b/Scripts/Brick.cs index 9122b8f..8eed4cb 100644 --- a/Scripts/Brick.cs +++ b/Scripts/Brick.cs @@ -7,6 +7,8 @@ public partial class Brick : StaticBody2D [Export] public int MaxDecayProgress = 50; [Export] public int DecayProgress; + [Export] public int PlayerId; + public override void _Ready() { DecayProgress = MaxDecayProgress; @@ -15,14 +17,14 @@ public partial class Brick : StaticBody2D { DecayProgress--; if (DecayProgress > 0) return; - GetNode("DecayTimer").Stop(); - QueueFree(); }; } public override void _Process(double delta) { + if(DecayProgress <= 0) QueueFree(); + var sprite = GetNode("Sprite2D"); sprite.SelfModulate = new Color(sprite.SelfModulate, (float)DecayProgress / MaxDecayProgress); } diff --git a/Scripts/Bullet.cs b/Scripts/Bullet.cs index d99a4dd..8f8ad0e 100644 --- a/Scripts/Bullet.cs +++ b/Scripts/Bullet.cs @@ -23,6 +23,12 @@ public partial class Bullet : Area2D player.TakeDamage(Damage); } + if (body is Brick brick) + { + if (brick.PlayerId == PlayerId) return; + brick.DecayProgress--; + } + QueueFree(); }; } diff --git a/Scripts/Logic/PlayerInput.cs b/Scripts/Logic/PlayerInput.cs index 92c82e4..77bd8d4 100644 --- a/Scripts/Logic/PlayerInput.cs +++ b/Scripts/Logic/PlayerInput.cs @@ -42,7 +42,7 @@ public partial class PlayerInput : MultiplayerSynchronizer if (Input.IsActionJustPressed("move_dash")) Rpc(nameof(Dash)); - if (Input.IsActionJustPressed("weapon_shoot")) + if (Input.IsActionPressed("weapon_shoot")) Rpc(nameof(Shoot)); if (Input.IsActionJustPressed("weapon_reload")) Rpc(nameof(Reload)); diff --git a/Scripts/Player.cs b/Scripts/Player.cs index 2d03108..abd28cf 100644 --- a/Scripts/Player.cs +++ b/Scripts/Player.cs @@ -6,195 +6,205 @@ namespace AceField.Scripts; public partial class Player : CharacterBody2D { - private int _currentPlayerId = 1; + private int _currentPlayerId = 1; - [Export] public float MaxSpeed = 400f; - [Export] public float Acceleration = 500f; - [Export] public float Deceleration = 500f; - [Export] public float RotationSpeed = 5f; + [Export] public float MaxSpeed = 400f; + [Export] public float Acceleration = 500f; + [Export] public float Deceleration = 500f; + [Export] public float RotationSpeed = 5f; - [Export] public int Reach = 5; + [Export] public int Reach = 5; - [Export] public double Health = 100; - [Export] public double MaxHealth = 100; - [Export] public double ActionPoints = 20; - [Export] public double MaxActionPoints = 20; - [Export] public int AmmoAmount = 30; - [Export] public int MaxAmmoAmount = 30; + [Export] public double Health = 100; + [Export] public double MaxHealth = 100; + [Export] public double ActionPoints = 20; + [Export] public double MaxActionPoints = 20; + [Export] public int AmmoAmount = 30; + [Export] public int MaxAmmoAmount = 30; - [Export] public Camera2D PlayerCamera; - [Export] public PlayerInput PlayerInput; + [Export] public Camera2D PlayerCamera; + [Export] public PlayerInput PlayerInput; - [Export] public float PlayerDashAcceleration = 2f; + [Export] public float PlayerDashAcceleration = 2f; - [Export] public PackedScene BulletScene; - [Export] public PackedScene TileScene; + [Export] public PackedScene BulletScene; + [Export] public PackedScene TileScene; - [Export] public float TileSize; + [Export] public float TileSize; - [Export] public string PlayerName; + [Export] public string PlayerName; - [Export] - public int PlayerId - { - get => _currentPlayerId; - set - { - _currentPlayerId = value; - PlayerInput.SetMultiplayerAuthority(value); - } - } + [Export] + public int PlayerId + { + get => _currentPlayerId; + set + { + _currentPlayerId = value; + PlayerInput.SetMultiplayerAuthority(value); + } + } - public bool IsCurrentPlayer => _currentPlayerId == Multiplayer.GetUniqueId(); + public bool IsCurrentPlayer => _currentPlayerId == Multiplayer.GetUniqueId(); - public bool IsReloading - => !GetNode("ReloadTimer").IsStopped(); + public bool IsReloading + => !GetNode("ReloadTimer").IsStopped(); - public double TimeRemainingOfReload - => GetNode("ReloadTimer").TimeLeft; + public double TimeRemainingOfReload + => GetNode("ReloadTimer").TimeLeft; - public override void _Ready() - { - Health = MaxHealth; - ActionPoints = MaxActionPoints; + public override void _Ready() + { + Health = MaxHealth; + ActionPoints = MaxActionPoints; - if (PlayerId == Multiplayer.GetUniqueId()) - PlayerCamera.Enabled = true; + if (PlayerId == Multiplayer.GetUniqueId()) + PlayerCamera.Enabled = true; - PlayerName ??= $"Player#{PlayerId}"; - GetNode