Example #1
0
    private void stepSearch(Point start, Point end)
    {
        //找出F值最小的点
        var tempPoint = OpenList.PopMinPoint();

        CloseList.Add(tempPoint);
        var neighbors = GetNeighbors(tempPoint);
        int count     = neighbors.Count;

        for (int i = 0; i < count; i++)
        {
            Point neighbor      = neighbors[i];
            var   neighborPoint = GetNeighborNode(tempPoint, neighbor, end);
            if (neighborPoint != null)
            {
                if (CloseList.Contains(neighborPoint))
                {
                    continue;
                }
                neighborPoint.ParentPoint = tempPoint;
                neighborPoint.G           = CalcG(tempPoint, neighborPoint);
                neighborPoint.H           = CalcH(end, neighborPoint);
                neighborPoint.CalcF();
                OpenList.Add(neighborPoint);
                var G = CalcG(tempPoint, neighborPoint);
                if (G < neighborPoint.G)
                {
                    neighborPoint.ParentPoint = tempPoint;
                    neighborPoint.F           = neighborPoint.H + G;
                }
                PointCallBack?.Invoke(neighborPoint);
            }
        }
    }
Example #2
0
 protected void NotFoundPoint(Point tempStart, Point end, Point point)
 {
     point.ParentPoint = tempStart;
     point.G           = CalcG(tempStart, point);
     point.H           = CalcH(end, point);
     point.CalcF();
     OpenList.Add(point);
     SearchCallBack?.Invoke(point);
     PointCallBack?.Invoke(point);
 }
Example #3
0
    protected void FoundPoint(Point tempStart, Point point)
    {
        var G = CalcG(tempStart, point);

        if (G < point.G)
        {
            point.ParentPoint = tempStart;
            //point.G = G;
            point.F = point.H + G;
            PointCallBack?.Invoke(point);
        }
    }