コード例 #1
0
        public List <MapCell> JPSPlus(MapCell cell1, MapCell cell2)
        {
            List <MapCell> path  = new List <MapCell>();
            List <GridPos> lpath = new List <GridPos>();

            if (cell1.MapId != cell2.MapId)
            {
                return(path);
            }
            JumpPointParameters.Reset(new GridPos(cell1.X, cell1.Y), new GridPos(cell2.X, cell2.Y));
            List <GridPos> resultPathList = JumpPointFinder.FindPath(JumpPointParameters);

            lpath = JumpPointFinder.GetFullPath(resultPathList);
            Debug.WriteLine($"From X: {cell1.X} Y: {cell1.Y}, To X: {cell2.X} Y: {cell2.Y}, Paths: {resultPathList.Count}, LPath: {lpath.Count}");
            if (lpath.Count > 0)
            {
                foreach (GridPos item in lpath)
                {
                    path.Add(new MapCell {
                        X = Convert.ToInt16(item.x), Y = Convert.ToInt16(item.y), MapId = cell1.MapId
                    });
                }
            }
            return(path);
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: Peterlamb/OpenNos
        public List <GridPos> JPSPlus(GridPos cell1, GridPos cell2)
        {
            List <GridPos> lpath = new List <GridPos>();

            JumpPointParameters.Reset(cell1, cell2);
            List <GridPos> resultPathList = JumpPointFinder.FindPath(JumpPointParameters);

            lpath = JumpPointFinder.GetFullPath(resultPathList);
            Debug.WriteLine($"From X: {cell1.x} Y: {cell1.y}, To X: {cell2.x} Y: {cell2.y}, Paths: {resultPathList.Count}, LPath: {lpath.Count}");
            return(lpath);
        }