Exemple #1
0
        public static FindPathProcess <T> FindPath <T>(this iExplorer <T> explorer, FindPathOptions options, T start, params T[] goal)
        {
            // set default options
            if (options == null)
            {
                options = FindPathOptions.c_Default;
            }

            // create result
            var result = new FindPathProcess <T>();

            // common sense check
            if (start == null || goal.Length == 0 || explorer == null)
            {
                result.Complete(FindPathResult.BadArguments);
                return(result);
            }

            // find only reachable goals
            goal = goal
                   .Where(n => explorer.Reachable(start, n))
                   .ToArray();

            // is reachable
            if (goal.Length == 0)
            {
                result.Complete(FindPathResult.NotReachable);
                return(result);
            }

            // init result inner data
            result.Init(options, explorer, start, goal);

            return(result);
        }
Exemple #2
0
        public void FindPath()
        {
            var sw = new Stopwatch();

            sw.Start();
            FindPathProcess = Explorer.FindPath(Options, Grid[From], Grid[To]).Implement();
            sw.Stop();
            var duration = sw.ElapsedMilliseconds;

            // if not found get closest point path
            if (FindPathProcess.IsPathFound == false)
            {
                FindPathProcess.BuildClosestPath();
            }

            _LogFindPathResult($"duration: {duration}");
        }
Exemple #3
0
 public static FindPathProcess <T> FindPath <T>(this iExplorer <T> explorer, out FindPathProcess <T> findPathProcess, FindPathOptions options, T start, params T[] goal)
 {
     findPathProcess = explorer.FindPath(options, start, goal);
     return(findPathProcess);
 }
Exemple #4
0
 public void Clear()
 {
     gameObject.DestroyChildren();
     FindPathProcess = null;
     Grid            = null;
 }