public int GetCellInDirection(DirectionsEnum direction, short step) { Point ThatCell; switch (direction) { case DirectionsEnum.DIRECTION_EAST: { ThatCell = new Point(Location.X + step, Location.Y + step); break; } case DirectionsEnum.DIRECTION_SOUTH_EAST: { ThatCell = new Point(Location.X + step, Location.Y); break; } case DirectionsEnum.DIRECTION_SOUTH: { ThatCell = new Point(Location.X + step, Location.Y - step); break; } case DirectionsEnum.DIRECTION_SOUTH_WEST: { ThatCell = new Point(Location.X, Location.Y - step); break; } case DirectionsEnum.DIRECTION_WEST: { ThatCell = new Point(Location.X - step, Location.Y - step); break; } case DirectionsEnum.DIRECTION_NORTH_WEST: { ThatCell = new Point(Location.X - step, Location.Y); break; } case DirectionsEnum.DIRECTION_NORTH: { ThatCell = new Point(Location.X - step, Location.Y + step); break; } case DirectionsEnum.DIRECTION_NORTH_EAST: { ThatCell = new Point(Location.X, Location.Y + step); break; } default: throw new Exception("Unknown direction : " + direction); } return(PathingUtils.CoordToCellId(ThatCell.X, ThatCell.Y)); }
public List <int> GetConnectedCells() { List <int> list = new List <int>(); list.Add(PathingUtils.CoordToCellId(Location.X - 1, Location.Y)); list.Add(PathingUtils.CoordToCellId(Location.X, Location.Y - 1)); list.Add(PathingUtils.CoordToCellId(Location.X + 1, Location.Y)); list.Add(PathingUtils.CoordToCellId(Location.X, Location.Y + 1)); return(list); }
private double PointWeight(Point point) { double result = 1; int cellId = PathingUtils.CoordToCellId(point.X, point.Y); int speed = currentMap.Data.Cells[cellId].speed; if (speed >= 0) { result = result + (5 - speed); } else { result = result + (11 + Math.Abs(speed)); } return(result); }