Beispiel #1
0
 private float Heuristic(IPathfinderNode a, IPathfinderNode b)
 {
     // Use the locations of the node to estimate how close they are by line of sight
     // experiment here with better ways of estimating the distance. This is used  to
     // calculate the global goal and work out the best order to prossess nodes in
     return(Vector3.Distance(a.position, b.position));
 }
Beispiel #2
0
    private float Distance(IPathfinderNode a, IPathfinderNode b)
    {
        // Use the length of the connection between these two nodes to find the distance, this
        // is used to calculate the local goal during the search for a path to a location
        float           result           = float.MaxValue;
        IPathfinderNode directConnection = a.connections.Find(c => c == b);

        if (directConnection != null)
        {
            result = tileSize;
        }
        return(result);
    }