✨ Better bullet
This commit is contained in:
parent
3fa89145b4
commit
cf6b4b0273
@ -6,16 +6,16 @@
|
|||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5wmf4"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5wmf4"]
|
||||||
size = Vector2(51.2, 51.2)
|
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/path = NodePath(".:position")
|
||||||
properties/0/spawn = true
|
properties/0/spawn = true
|
||||||
properties/0/replication_mode = 0
|
properties/0/replication_mode = 1
|
||||||
properties/1/path = NodePath(".:DecayProgress")
|
properties/1/path = NodePath(".:PlayerId")
|
||||||
properties/1/spawn = true
|
properties/1/spawn = true
|
||||||
properties/1/replication_mode = 0
|
properties/1/replication_mode = 1
|
||||||
properties/2/path = NodePath(".:MaxDecayProgress")
|
properties/2/path = NodePath(".:DecayProgress")
|
||||||
properties/2/spawn = true
|
properties/2/spawn = true
|
||||||
properties/2/replication_mode = 0
|
properties/2/replication_mode = 1
|
||||||
|
|
||||||
[node name="Brick" type="StaticBody2D"]
|
[node name="Brick" type="StaticBody2D"]
|
||||||
script = ExtResource("1_u0jqj")
|
script = ExtResource("1_u0jqj")
|
||||||
@ -33,4 +33,4 @@ wait_time = 0.1
|
|||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
replication_config = SubResource("SceneReplicationConfig_r3565")
|
replication_config = SubResource("SceneReplicationConfig_ccaja")
|
||||||
|
@ -115,6 +115,10 @@ one_shot = true
|
|||||||
wait_time = 0.05
|
wait_time = 0.05
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="WeaponCountdown" type="Timer" parent="."]
|
||||||
|
wait_time = 0.1
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
replication_config = SubResource("SceneReplicationConfig_bekoo")
|
replication_config = SubResource("SceneReplicationConfig_bekoo")
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ text = "Health 100/100"
|
|||||||
custom_minimum_size = Vector2(2.08165e-12, 16)
|
custom_minimum_size = Vector2(2.08165e-12, 16)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
max_value = 1.0
|
||||||
rounded = true
|
rounded = true
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
allow_lesser = true
|
allow_lesser = true
|
||||||
@ -56,6 +57,7 @@ horizontal_alignment = 1
|
|||||||
custom_minimum_size = Vector2(2.08165e-12, 16)
|
custom_minimum_size = Vector2(2.08165e-12, 16)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
max_value = 1.0
|
||||||
rounded = true
|
rounded = true
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
allow_lesser = true
|
allow_lesser = true
|
||||||
|
@ -7,6 +7,8 @@ public partial class Brick : StaticBody2D
|
|||||||
[Export] public int MaxDecayProgress = 50;
|
[Export] public int MaxDecayProgress = 50;
|
||||||
[Export] public int DecayProgress;
|
[Export] public int DecayProgress;
|
||||||
|
|
||||||
|
[Export] public int PlayerId;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
DecayProgress = MaxDecayProgress;
|
DecayProgress = MaxDecayProgress;
|
||||||
@ -15,14 +17,14 @@ public partial class Brick : StaticBody2D
|
|||||||
{
|
{
|
||||||
DecayProgress--;
|
DecayProgress--;
|
||||||
if (DecayProgress > 0) return;
|
if (DecayProgress > 0) return;
|
||||||
|
|
||||||
GetNode<Timer>("DecayTimer").Stop();
|
GetNode<Timer>("DecayTimer").Stop();
|
||||||
QueueFree();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
if(DecayProgress <= 0) QueueFree();
|
||||||
|
|
||||||
var sprite = GetNode<Sprite2D>("Sprite2D");
|
var sprite = GetNode<Sprite2D>("Sprite2D");
|
||||||
sprite.SelfModulate = new Color(sprite.SelfModulate, (float)DecayProgress / MaxDecayProgress);
|
sprite.SelfModulate = new Color(sprite.SelfModulate, (float)DecayProgress / MaxDecayProgress);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,12 @@ public partial class Bullet : Area2D
|
|||||||
player.TakeDamage(Damage);
|
player.TakeDamage(Damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (body is Brick brick)
|
||||||
|
{
|
||||||
|
if (brick.PlayerId == PlayerId) return;
|
||||||
|
brick.DecayProgress--;
|
||||||
|
}
|
||||||
|
|
||||||
QueueFree();
|
QueueFree();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public partial class PlayerInput : MultiplayerSynchronizer
|
|||||||
|
|
||||||
if (Input.IsActionJustPressed("move_dash"))
|
if (Input.IsActionJustPressed("move_dash"))
|
||||||
Rpc(nameof(Dash));
|
Rpc(nameof(Dash));
|
||||||
if (Input.IsActionJustPressed("weapon_shoot"))
|
if (Input.IsActionPressed("weapon_shoot"))
|
||||||
Rpc(nameof(Shoot));
|
Rpc(nameof(Shoot));
|
||||||
if (Input.IsActionJustPressed("weapon_reload"))
|
if (Input.IsActionJustPressed("weapon_reload"))
|
||||||
Rpc(nameof(Reload));
|
Rpc(nameof(Reload));
|
||||||
|
@ -79,8 +79,14 @@ public partial class Player : CharacterBody2D
|
|||||||
{
|
{
|
||||||
PlayerInput.IsShooting = false;
|
PlayerInput.IsShooting = false;
|
||||||
|
|
||||||
|
var timer = GetNode<Timer>("WeaponCountdown");
|
||||||
|
|
||||||
|
if (timer.IsStopped())
|
||||||
|
{
|
||||||
var name = GD.Randi();
|
var name = GD.Randi();
|
||||||
Rpc(nameof(Shoot), name.ToString());
|
Shoot(name.ToString());
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerInput.IsReloading)
|
if (PlayerInput.IsReloading)
|
||||||
@ -142,6 +148,11 @@ public partial class Player : CharacterBody2D
|
|||||||
dashCountdown.Start();
|
dashCountdown.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsReloading)
|
||||||
|
{
|
||||||
|
Velocity *= 0.8f;
|
||||||
|
}
|
||||||
|
|
||||||
Position += Velocity * (float)delta;
|
Position += Velocity * (float)delta;
|
||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
}
|
}
|
||||||
@ -151,7 +162,6 @@ public partial class Player : CharacterBody2D
|
|||||||
Rpc(nameof(GotDamage), damage);
|
Rpc(nameof(GotDamage), damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true)]
|
|
||||||
private void Shoot(string name)
|
private void Shoot(string name)
|
||||||
{
|
{
|
||||||
if (AmmoAmount <= 0) return;
|
if (AmmoAmount <= 0) return;
|
||||||
@ -171,10 +181,10 @@ public partial class Player : CharacterBody2D
|
|||||||
{
|
{
|
||||||
var tiles = GetParent<World>();
|
var tiles = GetParent<World>();
|
||||||
var tileVec = new Vector2(50, 50);
|
var tileVec = new Vector2(50, 50);
|
||||||
var instance = TileScene.Instantiate<Node2D>();
|
var instance = TileScene.Instantiate<Brick>();
|
||||||
instance.SetMultiplayerAuthority(playerId);
|
|
||||||
instance.Name = $"Brick@{name}";
|
instance.Name = $"Brick@{name}";
|
||||||
instance.Position = pos.Snapped(tileVec);
|
instance.Position = pos.Snapped(tileVec);
|
||||||
|
instance.PlayerId = playerId;
|
||||||
tiles.AddChild(instance);
|
tiles.AddChild(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,9 @@ public partial class HUD : Control
|
|||||||
|
|
||||||
var ammoBar = GetNode<ProgressBar>("TopBox/AmmoBox/Bar");
|
var ammoBar = GetNode<ProgressBar>("TopBox/AmmoBox/Bar");
|
||||||
var ammoLabel = GetNode<Label>("TopBox/AmmoBox/Label");
|
var ammoLabel = GetNode<Label>("TopBox/AmmoBox/Label");
|
||||||
ammoBar.Value = player.AmmoAmount / player.MaxAmmoAmount * 100;
|
ammoBar.Value = (float)player.AmmoAmount / player.MaxAmmoAmount * 100;
|
||||||
if (player.IsReloading) ammoLabel.Text = $"Reloading... {player.TimeRemainingOfReload:F2}";
|
ammoLabel.Text = player.IsReloading
|
||||||
else ammoLabel.Text = $"Ammo {player.AmmoAmount}/{player.MaxAmmoAmount}";
|
? $"Reloading... {player.TimeRemainingOfReload:F2}"
|
||||||
|
: $"Ammo {player.AmmoAmount}/{player.MaxAmmoAmount}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user