implemented more code for adding more pegs, but still a lot of work to do on pathfinding, targeting, map etc.

This commit is contained in:
2026-07-02 03:15:15 -04:00
parent 909f466f92
commit cbdca6f3cb
16 changed files with 170 additions and 50 deletions
+11 -4
View File
@@ -1,5 +1,6 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class ShootShortbow : PegAction
@@ -10,16 +11,17 @@ public partial class ShootShortbow : PegAction
_category = "attack";
_priority = 1;
_cost = 2;
_range = 1;
_range = 2;
_usesMax = 1;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
Vector2 target = Target(PEG);
Vector2 target = PEG._pegController._playArea._map.GetCellPositionFromAddress(Target(PEG));
Tween subtween = CreateTween();
subtween.TweenProperty(_image, "visible", true, 0.0f);
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target), 0.0f);
subtween.TweenProperty(_image, "global_position", target, 0.5f);
subtween.TweenCallback(Callable.From(() =>
{
@@ -30,9 +32,14 @@ public partial class ShootShortbow : PegAction
return subtween;
}
public override Vector2 Target(Peg PEG)
public override Vector2I Target(Peg PEG)
{
return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
List<Vector2I> closest = [.. PEG.GetVisibleCells().Where(c => (int)PEG._pegController._playArea._map.GetCellTileData(c).GetCustomData("disposition") == -PEG._disposition).OrderBy(c => (c - PEG._address).Length())];
if (closest.Count == 0)
{
return -Vector2I.One;
}
return closest[0]; // return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
}
}