public void Connect(WayPoint NewWayPoint) { PathFinderNode currentNode = Path; while (currentNode != null) { currentNode.RemoveFromLayer(); currentNode = currentNode.NextNode; } if (NextWayPoint != null && NextWayPoint.PreviousWayPoint == this) { NextWayPoint.PreviousWayPoint = null; } Path = Map.PathFinder.FindPath(Point, NewWayPoint.Point); if (Path != null) { Path.PathLayer = PathLayer; NextWayPoint = NewWayPoint; NewWayPoint.PreviousWayPoint = this; currentNode = Path; while (currentNode != null) { PathLayer.AddObject(currentNode); currentNode = currentNode.NextNode; } } }
public void Disconnect() { PathFinderNode currentNode = Path; while (currentNode != null) { currentNode.RemoveFromLayer(); currentNode = currentNode.NextNode; } }