private void OffRoadToOffRoad(Point startPoint, Point endPoint, Reusables reusables) { SearchResult searchResult; Point midPointOne; Point midPointTwo; AStarOffRoad AStarOffRoad = new AStarOffRoad(); drivingNodeList = AStarOffRoad.Go(startPoint, endPoint, false, out searchResult, out midPointOne, vehicle, false, reusables); if (searchResult == SearchResult.RoadFound) { //We found a road, lets re optomise our search looking for that specific point drivingNodeList = AStarOffRoad.Go(startPoint, midPointOne, false, out searchResult, out midPointOne, vehicle, false, reusables); List <DrivingNode> drivingNodeListThree = AStarOffRoad.Go(endPoint, startPoint, false, out searchResult, out midPointTwo, vehicle, true, reusables); if (searchResult == SearchResult.RoadFound) { //We found a road, lets re optomise our search looking for that specific point drivingNodeListThree = AStarOffRoad.Go(endPoint, midPointTwo, false, out searchResult, out midPointTwo, vehicle, true, reusables); AStarOnRoad AStarOnRoad = new AStarOnRoad(); List <DrivingNode> drivingNodeListTwo = AStarOnRoad.Go(midPointOne, midPointTwo, reusables); if (drivingNodeListTwo.Count > 0) { drivingNodeList.RemoveAt(0); //Need to remove the first one so theres no double up } drivingNodeListThree.Reverse(); drivingNodeListThree.AddRange(drivingNodeListTwo); drivingNodeListThree.AddRange(drivingNodeList); drivingNodeList = drivingNodeListThree; } else if (searchResult == SearchResult.EndFound) { //We found it in list three drivingNodeListThree.Reverse(); drivingNodeListThree.RemoveAt(drivingNodeListThree.Count - 1); drivingNodeList = drivingNodeListThree; } } // AddDebug(drivingNodeList); }
private void OnRoadToOffRoad(Point startPoint, Point endPoint, Reusables reusables) { SearchResult searchResult; Point midPoint; AStarOffRoad AStarOffRoad = new AStarOffRoad(); //We do this backwards drivingNodeList = AStarOffRoad.Go(endPoint, startPoint, false, out searchResult, out midPoint, vehicle, true, reusables); if (searchResult == SearchResult.RoadFound) { //Lets redo our offroad to onroad search as our path is not optimal at all as we were trying to head to a different point drivingNodeList = AStarOffRoad.Go(endPoint, midPoint, false, out searchResult, out midPoint, vehicle, true, reusables); drivingNodeList.Reverse(); AStarOnRoad AStarOnRoad = new AStarOnRoad(); List <DrivingNode> drivingNodeListTwo = AStarOnRoad.Go(startPoint, midPoint, reusables); drivingNodeList.AddRange(drivingNodeListTwo); } }
private void OffRoadToOnRoad(Point startPoint, Point endPoint, Reusables reusables) { SearchResult searchResult; Point midPoint; AStarOffRoad AStarOffRoad = new AStarOffRoad(); drivingNodeList = AStarOffRoad.Go(startPoint, endPoint, false, out searchResult, out midPoint, vehicle, false, reusables); if (searchResult == SearchResult.RoadFound) { AStarOnRoad AStarOnRoad = new AStarOnRoad(); List <DrivingNode> drivingNodeListTwo = AStarOnRoad.Go(midPoint, endPoint, reusables); drivingNodeListTwo.AddRange(drivingNodeList); drivingNodeList = drivingNodeListTwo; } }