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

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

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

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

            return(false);
        }