/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="currentCell"></param> /// <param name="radius"></param> /// <returns></returns> public static IEnumerable <int> GetCrossCells(MapInstance map, int currentCell, int radius) { foreach (var cell in GetCircleCells(map, currentCell, radius)) { if (Pathfinding.InLine(map, currentCell, cell)) { yield return(cell); } } }
/// <summary> /// /// </summary> /// <param name="fight"></param> /// <param name="fighter"></param> /// <param name="path"></param> /// <param name="beginCell"></param> /// <param name="direction"></param> /// <param name="endCell"></param> /// <returns></returns> public static int IsValidLine(AbstractFight fight, AbstractFighter fighter, MovementPath path, int beginCell, int direction, int endCell) { var length = -1; var actualCell = beginCell; if (!Pathfinding.InLine(fight.Map, beginCell, endCell)) { return(length); } length = (int)GoalDistance(fight.Map, beginCell, endCell); path.AddCell(actualCell, direction); for (int i = 0; i < length; i++) { actualCell = Pathfinding.NextCell(fight.Map, actualCell, direction); if (!fight.Map.IsWalkable(actualCell)) { return(-2); } if (fight.GetFighterOnCell(actualCell) != null) { return(-2); } path.AddCell(actualCell, direction); path.MovementLength++; if (Pathfinding.IsStopCell(fighter.Fight, fighter.Team, actualCell)) { return(-2); } } return(length); }