示例#1
0
        private void NextWaypointApdate(BFSearch.Cell nextCell, BFSearch.Cell currentCell, double addOn)
        {
            if (nextCell.X > currentCell.X)
            {
                right = addOn;
            }

            if (nextCell.X < currentCell.X)
            {
                left = -addOn;
            }

            if (nextCell.Y < currentCell.Y)
            {
                top = -addOn;
            }

            if (nextCell.Y > currentCell.Y)
            {
                bottom = addOn;
            }
        }
示例#2
0
        public static IList <BFSearch.Cell> CreateRouteOf(this Vehicle vehicle, int pointCount, Point startPoint, BFSearch.Cell excludeCell = null)
        {
            var startCell = vehicle.GetCurrentCell(startPoint);

            var terminateIndex = vehicle.Self.NextWaypointIndex;
            var terminateCell  = vehicle.GetCellByIndex(terminateIndex);

            var route = (List <BFSearch.Cell>) new BFSearch(vehicle, startCell, terminateCell).Search(excludeCell: excludeCell);

            while (route.Count < pointCount)
            {
                startCell = terminateCell;
                terminateIndex++;

                terminateCell = vehicle.GetCellByIndex(terminateIndex);

                var nextRoute = new BFSearch(vehicle, startCell, terminateCell).Search(excludeCell: excludeCell);

                route.AddRange(nextRoute);
            }

            return(route);
        }
 public static bool IsOnLine(BFSearch.Cell startCell, BFSearch.Cell cell)
 {
     return(Math.Abs(startCell.X - cell.X) - Math.Abs(startCell.Y - cell.Y) == 0);
 }
 public static bool IsOnLine(BFSearch.Cell startCell, BFSearch.Cell cell, BFSearch.Cell cell1, BFSearch.Cell cell2)
 {
     return(startCell.X - cell.X == cell1.X - cell2.X && startCell.Y - cell.Y == cell1.Y - cell2.Y);
 }