continuing to switch to MapCell orientation
This commit is contained in:
@@ -41,14 +41,14 @@ public partial class BasicMovement : PegAction
|
||||
}
|
||||
Vector2I cell = path[0];
|
||||
|
||||
map.SetCellPeg(cell, PEG);
|
||||
map.SetCellPeg(map._cells[cell], PEG);
|
||||
PEG._path.Add(cell);
|
||||
}
|
||||
|
||||
public override bool MeetsCriteria(Peg PEG)
|
||||
{
|
||||
List<Vector2I> bestPath = PEG.GetBestPath(true);
|
||||
return base.MeetsCriteria(PEG) && bestPath.Count > 0 && (int)PEG._pegController._playArea._map.GetCellTileData(bestPath[0]).GetCustomData("disposition") != -PEG._disposition;
|
||||
return base.MeetsCriteria(PEG) && bestPath.Count > 0 && (int)PEG._pegController._playArea._map.GetCellTileData(bestPath[0]).GetCustomData("disposition") != -(int)PEG._disposition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,28 +18,23 @@ public partial class ShootShortbow : PegAction
|
||||
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
Vector2 target = PEG._pegController._playArea._map.GetCellPositionFromAddress(Target(PEG));
|
||||
MapCell target = 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.TweenProperty(_image, "rotation", PEG.GetAngleTo(target.GlobalPosition), 0.0f);
|
||||
subtween.TweenProperty(_image, "global_position", target.GlobalPosition, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
PEG._pegController._playerController.ChangeHealth(-1, this);
|
||||
((Peg)target._occupant)._pegController._playerController.ChangeHealth(-2, this);
|
||||
Position = Vector2.Zero;
|
||||
Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
public override Vector2I Target(Peg PEG)
|
||||
public override MapCell 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]; // return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
|
||||
return PEG.Goal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,29 +18,24 @@ public partial class SwingShortsword : PegAction
|
||||
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
Vector2 target = PEG._pegController._playArea._map.GetCellPositionFromAddress(Target(PEG));
|
||||
MapCell target = 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, "global_position", target, 0.5f);
|
||||
subtween.TweenProperty(_image, "rotation", PEG.GetAngleTo(target.GlobalPosition), 0.0f);
|
||||
subtween.TweenProperty(_image, "global_position", target.GlobalPosition, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
PEG._pegController._playerController.ChangeHealth(-2, this);
|
||||
((Peg)target._occupant)._pegController._playerController.ChangeHealth(-2, this);
|
||||
_image.Position = Vector2.Zero;
|
||||
_image.Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
public override Vector2I Target(Peg PEG)
|
||||
public override MapCell 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];
|
||||
return PEG.Goal();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,25 +16,22 @@ public partial class ThrustSpear : PegAction
|
||||
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
GD.Print(Name);
|
||||
Map map = PEG._pegController._playArea._map;
|
||||
Peg pegTarget = map._addressOccupants[Target(PEG)];
|
||||
Vector2 target = pegTarget.GlobalPosition;
|
||||
MapCell target = 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.TweenProperty(_image, "rotation", PEG.GetAngleTo(target.GlobalPosition), 0.0f);
|
||||
subtween.TweenProperty(_image, "global_position", target.GlobalPosition, 0.5f);
|
||||
subtween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
pegTarget.ChangeHealth(-1);
|
||||
((Peg)target._occupant).ChangeHealth(-1);
|
||||
_image.Position = Vector2.Zero;
|
||||
_image.Visible = false;
|
||||
}));
|
||||
return subtween;
|
||||
}
|
||||
|
||||
public override Vector2I Target(Peg PEG)
|
||||
public override MapCell Target(Peg PEG)
|
||||
{
|
||||
return PEG.Goal();
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ public partial class Spearman : FriendlyPeg
|
||||
_visibility = 4;
|
||||
}
|
||||
|
||||
public override Vector2I Goal()
|
||||
public override MapCell Goal()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
List<Peg> enemies = [.. _pegController._pegs.Where(p => p._disposition == -_disposition)];
|
||||
Dictionary<Vector2I, MapCell> enemies = GetVisibleEnemies();
|
||||
if (enemies.Count == 0)
|
||||
{
|
||||
return _address;
|
||||
return _map._cells[_address];
|
||||
}
|
||||
List<Vector2I> closest = [.. enemies.OrderBy(e => (e._address - _address).Length()).Select(e => e._address)];
|
||||
return closest[0];
|
||||
Dictionary<Vector2I, MapCell> closest = enemies.OrderBy(e => (e.Value._occupant._address - _address).Length()).ToDictionary();
|
||||
return closest.ElementAt(0).Value;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ public partial class PegAction : Node2D
|
||||
{
|
||||
return PEG._staminaRemaining >= _cost
|
||||
&& _usesRemaining > 0
|
||||
&& (PEG._address - Target(PEG)).Length() <= _range;
|
||||
&& (PEG._address - Target(PEG)._address).Length() <= _range;
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
@@ -35,8 +35,8 @@ public partial class PegAction : Node2D
|
||||
_usesRemaining = _usesMax;
|
||||
}
|
||||
|
||||
public virtual Vector2I Target(Peg PEG)
|
||||
public virtual MapCell Target(Peg PEG)
|
||||
{
|
||||
return PEG._address;
|
||||
return PEG._cell;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user