32 lines
548 B
C#
32 lines
548 B
C#
|
using Godot;
|
||
|
|
||
|
namespace AceField.Scripts;
|
||
|
|
||
|
public partial class Bullet : Area2D
|
||
|
{
|
||
|
[Export] public int PlayerId = 1;
|
||
|
|
||
|
[Export] public float Speed = 1500;
|
||
|
[Export] public double Damage = 8;
|
||
|
|
||
|
[Export] public Timer FreeTimer;
|
||
|
|
||
|
public override void _Ready()
|
||
|
{
|
||
|
FreeTimer.Timeout += QueueFree;
|
||
|
|
||
|
BodyEntered += body =>
|
||
|
{
|
||
|
if (body is Player player && player.PlayerId != PlayerId)
|
||
|
{
|
||
|
player.TakeDamage(Damage);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public override void _PhysicsProcess(double delta)
|
||
|
{
|
||
|
Position += -Transform.Y * Speed * (float)delta;
|
||
|
}
|
||
|
}
|