Ejemplo n.º 1
0
 private Pathfinder(INavigatable <T, J> assistant, T start, J target, PathAccuracy accuracy)
 {
     this.start    = start;
     this.target   = target;
     this.accuracy = accuracy;
     pathAccuracy  = AccuracyFactor(accuracy);
     nav           = assistant;
 }
        private MarchingCubesPathfinder(PathTriangle start, PathTriangle target, PathAccuracy accuracy, float estimatedStepProgress = 0.5f)
        {
            this.start   = start;
            this.target  = target;
            pathAccuracy = AccuracyFactor(accuracy);
            float estimatedLength    = start.DistanceToTarget(target);
            int   estimatedQueueSize = (int)Mathf.Clamp(estimatedStepProgress * estimatedLength * (1 - (pathAccuracy / 2)), 10, 10000);

            pathTails      = new BinaryHeap <float, PathTriangle>(float.MinValue, float.MaxValue, estimatedQueueSize / 2);
            backwardsTails = new BinaryHeap <float, PathTriangle>(float.MinValue, float.MaxValue, estimatedQueueSize / 2);
        }
Ejemplo n.º 3
0
    private float AccuracyFactor(PathAccuracy acc)
    {
        float result;

        switch (acc)
        {
        case PathAccuracy.Perfect:
        {
            result = 1f;
            break;
        }

        case PathAccuracy.VeryGood:
        {
            result = 0.95f;
            break;
        }

        case PathAccuracy.Good:
        {
            result = 0.8f;
            break;
        }

        case PathAccuracy.Decent:
        {
            result = 0.5f;
            break;
        }

        case PathAccuracy.NotSoGoodAnymore:
        {
            result = 0.25f;
            break;
        }

        case PathAccuracy.ITakeAnyThing:
        {
            result = 0.05f;
            break;
        }

        default:
        {
            throw new System.ArgumentException("Unexpected Accuracy: " + acc);
        }
        }
        return(result);
    }
Ejemplo n.º 4
0
 public static IList <T> FindPath(INavigatable <T, J> assistant, T start, J target, PathAccuracy accuracy)
 {
     return(new Pathfinder <T, J>(assistant, start, target, accuracy).GetPath());
 }
 public static IList <PathTriangle> FindPath(PathTriangle start, PathTriangle target, PathAccuracy accuracy)
 {
     return(new MarchingCubesPathfinder(start, target, accuracy).GetPath());
 }