think i finally solved movement going into enemy territory
This commit is contained in:
@@ -29,16 +29,7 @@ public partial class Peg : MapCellOccupant
|
||||
}
|
||||
public virtual PegAction SelectAction()
|
||||
{
|
||||
PegAction action = null;
|
||||
for (int i = 0; i < _actions.Count; i++)
|
||||
{
|
||||
if (_actions[i].MeetsCriteria(this))
|
||||
{
|
||||
action = _actions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return action;
|
||||
return _actions.FirstOrDefault(a => a.MeetsCriteria(this), null);
|
||||
}
|
||||
|
||||
public virtual void CounterAct(Commander COMMANDER)
|
||||
@@ -73,14 +64,8 @@ public partial class Peg : MapCellOccupant
|
||||
|
||||
public virtual MapCell Goal()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
Dictionary<Vector2I, MapCell> visible = GetVisibleCells();
|
||||
Dictionary<Vector2I, MapCell> unoccupied = visible.Where(c => !map._astar.IsPointSolid(c.Key)).ToDictionary();
|
||||
Dictionary<Vector2I, MapCell> enemyTerritory = map._cells.Where(c => _map.GetCellDisposition(c.Value._address) == -(int)_disposition).ToDictionary();
|
||||
Dictionary<Vector2I, MapCell> closest = enemyTerritory.OrderByDescending(c => c.Value._address.Y).ThenByDescending(c => Math.Abs(c.Value._address.X - _address.X)).ToDictionary();
|
||||
|
||||
// Dictionary<Vector2I, MapCell> closest = unoccupied.OrderByDescending(c => c.Value._address.Y * -(int)_disposition).ThenByDescending(c => Math.Abs(c.Value._address.X - _address.X)).ToDictionary();
|
||||
// Dictionary<Vector2I, MapCell> closest = furthest.Where(c => _map.GetCellDisposition(c.Value._address) == -(int)_disposition).ToDictionary();
|
||||
Dictionary<Vector2I, MapCell> enemyTerritory = _map._cells.Where(c => _map.GetCellDisposition(c.Value._address) == (_disposition == Disposition.FRIENDLY ? -1 : 1)).ToDictionary();
|
||||
Dictionary<Vector2I, MapCell> closest = enemyTerritory.OrderByDescending(c => c.Value._address.Y).ThenBy(c => Math.Abs(c.Value._address.X - _address.X)).ToDictionary();
|
||||
return closest.ElementAt(0).Value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user