Esempio n. 1
0
    public PathFinderResult FindPath()
    {
        if (from == null || to == null)
        {
            return(new PathFinderResult());
        }

        //D(map);
        //D("from:", from);
        //D("to:", to);

        var pathItems = new AStar(map, from, to, directionOffest, WeightFunction).Find();

        if (!pathItems.Any())
        {
            D("NO_PATH");
            return(PathFinderResult.NO_PATH);
        }

        var p = new PathFinderResult
        {
            Path           = pathItems.Select(x => x.Pos).ToArray(),
            WeightedLength = pathItems.Last().CumulativeLength
        };

        //D("found path:", p.WeightedLength);

        return(p);
    }