public Cell[] GetCells(Cell centerCell, Map map) { var result = new List<Cell>(); if (Radius == 0) { if (MinRadius == 0 && !DiagonalFree) result.Add(centerCell); return result.ToArray(); } int x = (int)( centerCell.X - Radius ); int y; while (x <= centerCell.X + Radius) { y = (int) (centerCell.Y - Radius); while (y <= centerCell.Y - Radius) { if (MinRadius == 0 || Math.Abs(centerCell.X - x) + Math.Abs(centerCell.Y - y) >= MinRadius) if (!DiagonalFree || Math.Abs(centerCell.X - x) != Math.Abs(centerCell.Y - y)) AddCellIfValid(x, y, map, result); y++; } x++; } return result.ToArray(); }
public LOSMap(MapContext<Fighter> map, bool throughEntities = false) { _losMap = null; _mapF = map; _pivotCell = null; _throughEntities = throughEntities; }
public Cell[] GetCells(Cell centerCell, Map map) { var result = new List<Cell>(); if (MinRadius == 0) result.Add(centerCell); for (int i = 1; i <= Radius; i++) { switch (Direction) { case DirectionsEnum.DIRECTION_NORTH_WEST: AddCellIfValid(centerCell.X + i, centerCell.Y + i, map, result); AddCellIfValid(centerCell.X + i, centerCell.Y - i, map, result); break; case DirectionsEnum.DIRECTION_NORTH_EAST: AddCellIfValid(centerCell.X - i, centerCell.Y - i, map, result); AddCellIfValid(centerCell.X + i, centerCell.Y - i, map, result); break; case DirectionsEnum.DIRECTION_SOUTH_EAST: AddCellIfValid(centerCell.X - i, centerCell.Y + i, map, result); AddCellIfValid(centerCell.X - i, centerCell.Y - i, map, result); break; case DirectionsEnum.DIRECTION_SOUTH_WEST: AddCellIfValid(centerCell.X - i, centerCell.Y + i, map, result); AddCellIfValid(centerCell.X + i, centerCell.Y + i, map, result); break; } } return result.ToArray(); }
public LOSMap(MapContext<RolePlayActor> map, bool throughEntities = false) { _losMap = null; _mapRP = map; _pivotCell = null; _throughEntities = throughEntities; }
public SpellTarget(double efficiency = 0, Cell source = null, Cell target = null, Spell spell = null) { Efficiency = efficiency; FromCell = source; TargetCell = target; Spell = spell; cast = spell == null; }
public ObjectPosition(Map map, Cell cell, DirectionsEnum direction) { if (map == null) throw new ArgumentNullException("map"); if (cell == null) throw new ArgumentNullException("cell"); Map = map; Cell = cell; Direction = direction; }
public TimedPathElement(Cell currentCell, Cell nextCell, DateTime startTime, DateTime endTime, double velocity, DirectionsEnum direction) { CurrentCell = currentCell; NextCell = nextCell; StartTime = startTime; EndTime = endTime; Velocity = velocity; Direction = direction; }
/// <summary> /// Set a new target for the LoSMap. /// If the target and Cell Id are same as previous, and forceUpdate is not set, then nothing is done. /// Otherwise, reset the map for new compute of LOS. /// </summary> /// <param name="target">The Fighter for which you want to check if he can be seen from any cell of the map</param> /// <param name="throughEntities">Set if actors block LoS</param> /// <param name="delayComputed">If set, force immediate compute of the full map. Otherwise, only compute needed cells on demand</param> /// <param name="forceUpdate">Should be used when obstacles (like actors) may have moved</param> /// <returns></returns> public bool UpdateTargetCell(Cell pivotCell, bool delayComputed, bool forceUpdate) { if (pivotCell == null) { _losMap = null; _pivotCell = null; return false; } if (_pivotCell != null && _pivotCell.Id == pivotCell.Id && !forceUpdate) return true; _pivotCell = pivotCell; _losMap = new bool?[cells.Count()]; if (!delayComputed) foreach (Cell testCell in cells) _losMap[testCell.Id] = CanBeSeen(testCell, _throughEntities); return true; }
public Cell[] GetCells(Cell centerCell, Map map) { var result = new List<Cell>(); if (Radius == 0) { if (MinRadius == 0) result.Add(centerCell); return result.ToArray(); } int x = (int) (centerCell.X - Radius); int y = 0; int i = 0; int j = 1; while (x <= centerCell.X + Radius) { y = -i; while (y <= i) { if (MinRadius == 0 || Math.Abs(centerCell.X - x) + Math.Abs(y) >= MinRadius) AddCellIfValid(x, y + centerCell.Y, map, result); y++; } if (i == Radius) { j = -j; } i = i + j; x++; } return result.ToArray(); }
public int GetMapLinkedToCell(Cell cell) { MapNeighbour neighbour = Map.GetDirectionOfTransitionCell(cell); return GetNeighbourId(neighbour); }
public bool Move(Path path, Cell dest, bool cancelMove = true) { if (IsMoving()) if (cancelMove) CancelMove(false); else { if (_actionAfterMove != null) return false; // Can't remember this move _actionAfterMove = () => Move(path, dest, cancelMove); return true; } // DEBUG //SendMessage(String.Format("Move {0} => {1} : {2}", Cell, dest, String.Join<Cell>(",", path.Cells))); //ResetCellsHighlight(); //HighlightCells(path.Cells, Color.YellowGreen); if (path.IsEmpty()) { SendMessage("Empty path skipped", Color.Gray); return false; } else if (path.Start.Id != Cell.Id) { SendMessage(String.Format("Path start with {0} instead of {1}", path.Start, Cell), Color.Red); return false; } Bot.SendToServer(new GameMapMovementRequestMessage(path.GetClientPathKeys(), Map.Id)); return true; }
public bool CellMarked(Cell cell) { return(false); }
void IDisposable.Dispose() { if (_pivotCell != null) _pivotCell = null; if (_mapRP != null) _mapRP = null; if (_mapF != null) _mapF = null; if (_losMap != null) _losMap = null; }
public bool IsCellWalkable(Cell cell, bool throughEntities = false, Cell previousCell = null) { if (!cell.Walkable) return false; if (cell.NonWalkableDuringRP) return false; // compare the floors if (UsingNewMovementSystem && previousCell != null) { var floorDiff = Math.Abs(cell.Floor) - Math.Abs(previousCell.Floor); if (cell.MoveZone != previousCell.MoveZone || cell.MoveZone == previousCell.MoveZone && cell.MoveZone == 0 && floorDiff > Map.ElevationTolerance) return false; } // todo : LoS return true; }
public bool IsChangeZone(Cell cell) { return MoveZone != cell.MoveZone && Math.Abs(Floor) == Math.Abs(cell.Floor); }
public bool IsAdjacentTo(Cell cell) { return ManhattanDistanceTo(cell) == 1; }
public uint DistanceTo(Cell cell) { return (uint)Math.Sqrt(( cell.X - Point.X ) * ( cell.X - Point.X ) + ( cell.Y - Point.Y ) * ( cell.Y - Point.Y )); }
public static bool IsInMap(Cell cell) { return IsInMap(cell.X, cell.Y); }
public Cell[] GetCells(Cell centerCell, Map map) { return m_shape.GetCells(centerCell, map); }
public bool IsCellMarked(Cell cell) { // todo return(false); }
public bool IsActor(Cell cell) { return Actors.Any(entry => entry.Position != null && entry.Position.Cell == cell); }
public bool IsCellMarked(Cell cell) { // todo return false; }
public uint ManhattanDistanceTo(Cell cell) { return (uint)( Math.Abs(Point.X - cell.X) + Math.Abs(Point.Y - cell.Y) ); }
public DirectionsEnum OrientationTo(Cell cell, Boolean diagonal = true) { int dx = cell.X - X; int dy = Y - cell.Y; double distance = Math.Sqrt(dx * dx + dy * dy); double angleInRadians = Math.Acos(dx / distance); double angleInDegrees = angleInRadians * 180 / Math.PI; double transformedAngle = angleInDegrees * ( cell.Y > Y ? ( -1 ) : ( 1 ) ); double orientation = !diagonal ? Math.Round(transformedAngle / 90) * 2 + 1 : Math.Round(transformedAngle / 45) + 1; if (orientation < 0) { orientation = orientation + 8; } return (DirectionsEnum)(uint)orientation; }
public DirectionsEnum OrientationToAdjacent(Cell cell) { var vector = new Point { X = cell.X > Point.X ? ( 1 ) : ( cell.X < Point.X ? ( -1 ) : ( 0 ) ), Y = cell.Y > Point.Y ? ( 1 ) : ( cell.Y < Point.Y ? ( -1 ) : ( 0 ) ) }; if (vector == s_vectorRight) { return DirectionsEnum.DIRECTION_EAST; } if (vector == s_vectorDownRight) { return DirectionsEnum.DIRECTION_SOUTH_EAST; } if (vector == s_vectorDown) { return DirectionsEnum.DIRECTION_SOUTH; } if (vector == s_vectorDownLeft) { return DirectionsEnum.DIRECTION_SOUTH_WEST; } if (vector == s_vectorLeft) { return DirectionsEnum.DIRECTION_WEST; } if (vector == s_vectorUpLeft) { return DirectionsEnum.DIRECTION_NORTH_WEST; } if (vector == s_vectorUp) { return DirectionsEnum.DIRECTION_NORTH; } if (vector == s_vectorUpRight) { return DirectionsEnum.DIRECTION_NORTH_EAST; } return DirectionsEnum.DIRECTION_EAST; }
private bool CanBeSeen(Cell targetCell, bool throughEntities) { if (_mapF == null) return _mapRP.CanBeSeen(_pivotCell, targetCell, throughEntities); return _mapF.CanBeSeen(_pivotCell, targetCell, throughEntities); }
public bool IsActor(Cell cell) { return(Actors.Any(entry => entry.Position != null && entry.Position.Cell == cell)); }
public ContextActor[] GetContextActors(Cell cell) { return(Actors.Where(entry => entry.Position != null && entry.Position.Cell == cell).Select(entry => (ContextActor)entry).ToArray()); }
public bool CellMarked(Cell cell) { return false; }
public bool this[Cell cell] { get { return _losMap[cell.Id] ?? (_losMap[cell.Id] = CanBeSeen(cell, _throughEntities)).Value; } }
public ContextActor[] GetActors(Cell cell) { return Actors.Where(entry => entry.Position != null && entry.Position.Cell == cell).Select(entry => (ContextActor)entry).ToArray(); }
public bool Move(Cell cell, ISimplePathFinder pathFinder = null, int minDistance = 0, bool cautious = false, bool cancelMove = true) { if (cell == null) throw new ArgumentNullException("cell"); if (!CanMove()) return false; if (pathFinder == null) pathFinder = new BiM.Behaviors.Game.World.Pathfinding.FFPathFinding.PathFinder(Map, false); Path path = null; if (pathFinder is IAdvancedPathFinder) path = (pathFinder as IAdvancedPathFinder).FindPath(Cell, cell, true, -1, minDistance, cautious); else path = pathFinder.FindPath(Cell, cell, true, -1); return Move(path, cell); }
public object[] GetMarks(Cell cell) { return new object[0]; }
public void HighlightCell(Cell cell, Color color) { Bot.SendToClient(new DebugHighlightCellsMessage(color.ToArgb(), new[] { cell.Id })); }
public object[] GetMarks(Cell cell) { return(new object[0]); }