2024-08-08 04:13:53 +00:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace AceField.Scripts;
|
|
|
|
|
|
|
|
public partial class Bullet : Area2D
|
|
|
|
{
|
|
|
|
[Export] public int PlayerId = 1;
|
2024-08-08 15:23:31 +00:00
|
|
|
|
2024-08-08 04:13:53 +00:00
|
|
|
[Export] public float Speed = 1500;
|
|
|
|
[Export] public double Damage = 8;
|
|
|
|
|
|
|
|
[Export] public Timer FreeTimer;
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
FreeTimer.Timeout += QueueFree;
|
|
|
|
|
|
|
|
BodyEntered += body =>
|
|
|
|
{
|
2024-08-08 16:42:22 +00:00
|
|
|
if (body is Player player)
|
2024-08-08 15:23:31 +00:00
|
|
|
{
|
2024-08-08 16:42:22 +00:00
|
|
|
if (player.PlayerId == PlayerId) return;
|
|
|
|
player.TakeDamage(Damage);
|
2024-08-08 15:23:31 +00:00
|
|
|
}
|
|
|
|
|
2024-08-08 18:20:56 +00:00
|
|
|
if (body is Brick brick)
|
|
|
|
{
|
|
|
|
if (brick.PlayerId == PlayerId) return;
|
|
|
|
brick.DecayProgress--;
|
|
|
|
}
|
|
|
|
|
2024-08-08 09:10:48 +00:00
|
|
|
QueueFree();
|
2024-08-08 04:13:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
|
|
{
|
|
|
|
Position += -Transform.Y * Speed * (float)delta;
|
|
|
|
}
|
|
|
|
}
|