//we need to order it our next tile to drive to is the end off the list //as we want to pull them off the end public List <DrivingNode> GetDrivingNodeList(Reusables reusables, bool reversed, Point startPoint, Point endPoint, bool keepDestination) { List <DrivingNode> drivingNodeList = new List <DrivingNode>(); AStarNode currentNode = reusables.checkedNodeList[GetOneD(endPoint)]; Point currentPoint = currentNode.GetCurrent2D(); while (currentPoint != startPoint) { currentPoint = currentNode.GetCurrent2D(); drivingNodeList.Add(new DrivingNode(currentPoint.X, currentPoint.Y)); currentPoint = currentNode.GetPrevious2D(); currentNode = reusables.checkedNodeList[GetOneD(currentPoint)]; } drivingNodeList.Add(new DrivingNode(currentPoint.X, currentPoint.Y)); if (drivingNodeList.Count > 0) { if (reversed) { //We need to pop the first from the list drivingNodeList.RemoveAt(0); } else { drivingNodeList.RemoveAt(drivingNodeList.Count - 1); } } if (keepDestination) { drivingNodeList.Add(new DrivingNode(startPoint.X, startPoint.Y)); } return(AddDirectionTurns(drivingNodeList, startPoint)); }
//we need to order it our next tile to drive to is the end off the list //as we want to pull them off the end public List <DrivingNode> GetDrivingNodeList(Reusables reusables, Point startPoint) { List <DrivingNode> drivingNodeList = new List <DrivingNode>(); AStarNode currentNode = reusables.checkedNodeList[GetOneD(endPoint)]; Point currentPoint = currentNode.GetCurrent2D(); while (currentPoint != startPoint) { currentPoint = currentNode.GetCurrent2D(); Point reachPoint = currentNode.GetPrevious2D(); int direction = currentNode.GetMirrorDirection(); do { drivingNodeList.Add(new DrivingNode(currentPoint.X, currentPoint.Y)); currentPoint = AngleStuff.AddPointToDirection(currentPoint, direction); }while (currentPoint != reachPoint); //probably a better way to do this, but if we reached our reach point we do need to add it one more // drivingNodeList.Add(new DrivingNode(currentPoint.X, currentPoint.Y)); currentNode = reusables.checkedNodeList[GetOneD(currentPoint)]; } if (drivingNodeList.Count > 0) { //We need to pop the last from the list // drivingNodeList.RemoveAt(drivingNodeList.Count - 1); } return(AddDirectionTurns(drivingNodeList, startPoint)); }