Exemple #1
0
        public void FindPath()
        {
            Stopwatch watch = Stopwatch.StartNew();

            bool[,] boolMap = SearchHelpers.GetSearchBoolMap(theGameStatus.TheMap);
            Point            startLocation        = new Point(100, 100);
            Point            endLocation          = new Point(300, 300);
            SearchParameters tempSearchParameters = new SearchParameters(startLocation, endLocation,
                                                                         boolMap);

            AStarPathFinder tempAStarPathFinder = new AStarPathFinder(tempSearchParameters);
            List <Point>    tempPath            = tempAStarPathFinder.FindPath();

            if (tempPath.Count == 0)
            {
                TheGameCore.RaiseMessage("No path found: " + startLocation + "-" + endLocation);
            }
            else
            {
                tempPath.Insert(0, startLocation);
                Vector3[] tempVect3 = SearchHelpers.PathToVector3Array(theGameStatus.TheMap, tempPath, 0.1f);
                RenderLayerBase.TheSceneManager.TheRenderLayerGame.AddPath(tempVect3);
            }
            watch.Stop();
            TheGameCore.RaiseMessage("FindPath() took " + watch.ElapsedMilliseconds + "ms,: " + startLocation + "-" + endLocation);
        }