Пример #1
0
        /// <summary>
        /// This function retreive all cells that can be reached from startingCell. You can include specific filter on CellInfo and also order them as you want (default order is by increasing distance from
        /// </summary>
        /// <param name="startingCell"></param>
        /// <param name="inFight">true if you're in fight map</param>
        /// <param name="cautious">true when you exclude all path that are throught actors or close to enemies</param>
        /// <param name="filter">You can set here any filter on CellInfos, like criteria on distance from startingCell</param>
        /// <param name="sorter">You tell here how you want the cells to be sorted</param>
        /// <returns></returns>
        public IEnumerable <Cell> FindConnectedCells(Cell startingCell, bool inFight, bool cautious, FilterCells filter = null, OrderingCells sorter = null, int maxDistance = CellInfo.DEFAULT_DISTANCE)
        {
            _isCautious = cautious;
            _isInFight  = inFight;
            FindPath(new short[] { startingCell.Id }, null, false, true, maxDistance); // Only 1st step
            var set1   = _cells.Where(cell => cell.DistanceSteps <= maxDistance);
            var count1 = set1.Count();
            var set2   = set1.Where(cell => filter == null || filter(cell));
            var count2 = set2.Count();

            // Avoid to come in a trap if we're not in a trap at start. In all cases, favours cells not trapped if possible.
            return(_cells.Where(cell => cell != null && cell.DistanceSteps <= maxDistance && (filter == null || filter(cell)) && /*(_map.IsTrapped(startingCell.Id) || */ !_map.IsTrapped(cell.CellId) /*)*/).OrderBy(cell => (sorter == null ? cell.DistanceSteps : sorter(cell)) /*+ (_map.IsTrapped(cell.CellId)?100:0)*/).Select(cell => cell.Cell));
        }
Пример #2
0
 /// <summary>
 /// This function retreive all cells that can be reached from startingCell. You can include specific filter on CellInfo and also order them as you want (default order is by increasing distance from 
 /// </summary>
 /// <param name="startingCell"></param>
 /// <param name="inFight">true if you're in fight map</param>
 /// <param name="cautious">true when you exclude all path that are throught actors or close to enemies</param>
 /// <param name="filter">You can set here any filter on CellInfos, like criteria on distance from startingCell</param>
 /// <param name="sorter">You tell here how you want the cells to be sorted</param>
 /// <returns></returns>
 public IEnumerable<Cell> FindConnectedCells(Cell startingCell, bool inFight, bool cautious, FilterCells filter = null, OrderingCells sorter = null, int maxDistance = CellInfo.DEFAULT_DISTANCE)
 {
     _isCautious = cautious;
     _isInFight = inFight;
     FindPath(new short[] { startingCell.Id }, null, false, true, maxDistance); // Only 1st step
     var set1 = _cells.Where(cell => cell.DistanceSteps <= maxDistance);
     var count1 = set1.Count();
     var set2 = set1.Where(cell => filter == null || filter(cell));
     var count2 = set2.Count();
     // Avoid to come in a trap if we're not in a trap at start. In all cases, favours cells not trapped if possible.
     return _cells.Where(cell => cell != null && cell.DistanceSteps <= maxDistance && (filter == null || filter(cell)) && /*(_map.IsTrapped(startingCell.Id) || */!_map.IsTrapped(cell.CellId)/*)*/).OrderBy(cell => (sorter == null ? cell.DistanceSteps : sorter(cell)) /*+ (_map.IsTrapped(cell.CellId)?100:0)*/).Select(cell => cell.Cell);
 }