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:
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class SwingShortsword : PegAction
|
||||
@@ -10,17 +11,18 @@ public partial class SwingShortsword : PegAction
|
||||
_category = "attack";
|
||||
_priority = 1;
|
||||
_cost = 2;
|
||||
_range = 0;
|
||||
_range = 1;
|
||||
_usesMax = 1;
|
||||
_usesRemaining = _usesMax;
|
||||
}
|
||||
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
Vector2 target = PEG._disposition * Vector2.Down * PEG._pegController._playArea._map._cellSize;
|
||||
Vector2 target = PEG._pegController._playArea._map.GetCellPositionFromAddress(Target(PEG));
|
||||
// GD.Print(target);
|
||||
Tween subtween = CreateTween();
|
||||
subtween.TweenProperty(_image, "visible", true, 0.0f);
|
||||
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target), 0.0f);
|
||||
subtween.TweenProperty(_image, "position", target, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
@@ -30,4 +32,15 @@ public partial class SwingShortsword : PegAction
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
public override Vector2I Target(Peg PEG)
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user