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:
@@ -46,19 +46,24 @@ public partial class Peg : HoverableNode
|
||||
|
||||
public virtual List<Vector2I> GetBestPath(bool PARTIAL = false)
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
List<Vector2I> goals = Target();
|
||||
// Map map = _pegController._playArea._map;
|
||||
// List<Vector2I> goals = Target();
|
||||
|
||||
for (int i = 0; i < goals.Count; i++)
|
||||
{
|
||||
List<Vector2I> path = map.GetPath(_address, goals[i], false, PARTIAL);
|
||||
if (path.Count > 0)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
// for (int i = 0; i < goals.Count; i++)
|
||||
// {
|
||||
// List<Vector2I> path = map.GetPath(_address, goals[i], false, PARTIAL);
|
||||
// if (path.Count > 0)
|
||||
// {
|
||||
// return path;
|
||||
// }
|
||||
|
||||
}
|
||||
return [];
|
||||
// }
|
||||
return _pegController._playArea._map.GetPath(_address, Goal(), false, PARTIAL);
|
||||
}
|
||||
|
||||
public virtual List<Peg> GetEnemies()
|
||||
{
|
||||
return [.. _pegController._pegs.Where(p => p._disposition == -_disposition).OrderBy(p => (p._address - _address).Length())];
|
||||
}
|
||||
|
||||
public virtual List<Vector2I> GetVisibleCells()
|
||||
@@ -67,13 +72,10 @@ public partial class Peg : HoverableNode
|
||||
return [.. map._cells.Where(c => (c - _address).Length() <= _visibility)];
|
||||
}
|
||||
|
||||
public virtual List<Vector2I> Target()
|
||||
public virtual List<Peg> GetVisibleEnemies()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
List<Vector2I> visible = GetVisibleCells();
|
||||
List<Vector2I> unoccupied = [.. visible.Where(c => !map._astar.IsPointSolid(c))];
|
||||
List<Vector2I> closest = [.. unoccupied.OrderByDescending(c => c.Y * _disposition).ThenByDescending(c => Math.Abs(c.X - _address.X))];
|
||||
return closest;
|
||||
List<Vector2I> visible = GetVisibleCells();
|
||||
return [.. GetEnemies().Where(e => visible.Contains(e._address))];
|
||||
}
|
||||
|
||||
public Vector2 GetPositionFromAddress()
|
||||
@@ -81,16 +83,24 @@ public partial class Peg : HoverableNode
|
||||
return _pegController._playArea._map.GetCellPositionFromAddress(_address);
|
||||
}
|
||||
|
||||
public virtual Vector2I Goal()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
List<Vector2I> visible = GetVisibleCells();
|
||||
List<Vector2I> unoccupied = [.. visible.Where(c => !map._astar.IsPointSolid(c))];
|
||||
List<Vector2I> closest = [.. unoccupied.OrderByDescending(c => c.Y * _disposition).ThenByDescending(c => Math.Abs(c.X - _address.X))];
|
||||
return closest[0];
|
||||
}
|
||||
|
||||
public virtual void StartTurn()
|
||||
{
|
||||
_staminaRemaining = _stamina;
|
||||
_actions.ForEach(a => a.Reset());
|
||||
}
|
||||
|
||||
public virtual void ChangeHealth(int DELTA, Commander COMMANDER)
|
||||
public virtual void ChangeHealth(int DELTA)
|
||||
{
|
||||
_health += DELTA;
|
||||
CounterAct(COMMANDER);
|
||||
if (_health <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.Death, this);
|
||||
|
||||
Reference in New Issue
Block a user