示例#1
0
        public override void BuildResult(PathFinding search)
        {
            // 当没有达到目标点时, 已经建立过结果
            if (search.result.Count > 0)
            {
                return;
            }

            search.BuildPath(search.endCell, true);
        }
示例#2
0
        public override bool IsFinishedOnChose(PathFinding search)
        {
            // 如果开放集中已经空了, 则说明没有达到目标点
            if (search.currentCell == null)
            {
                // 使用 H 最小值建立结果
                CellData minCell = search.explored.First(cell => System.Math.Abs(cell.H - search.explored.Min(c => c.H)) < 1e-6);
                search.BuildPath(minCell, true);
                return(true);
            }

            // 找到了目标点
            if (search.currentCell == search.endCell)
            {
                return(true);
            }

            if (!search.IsCellInExplored(search.currentCell))
            {
                search.explored.Add(search.currentCell);
            }

            return(false);
        }