This commit is contained in:
2026-05-14 13:17:23 +02:00
parent 37f4ea3b4e
commit 70bba45b8a
18 changed files with 293 additions and 71 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Godot;
using NodeWar.scripts;
namespace NodeWar.Scripts;
@@ -9,7 +10,7 @@ public partial class Pip : Area2D
public Faction Faction;
[Export]
public Base Target;
public Vector2 Target;
[Export]
public float Speed { get; set; } = 100;
@@ -33,16 +34,13 @@ public partial class Pip : Area2D
public override void _Process(double delta)
{
if (Target == null)
return;
var direction = Target.Position - GlobalPosition;
var direction = Target - GlobalPosition;
Position += direction.Normalized() * Speed * delta.ToFloat();
}
private void OnAreaEntered(Node2D body)
{
if (body is Base { Faction: Faction.Computer } enteredBase)
if (body is Base enteredBase && enteredBase.Faction != Faction)
{
enteredBase.HealthComponent.TakeDamage(1);
QueueFree();