Пример #1
0
    static bool addOpen(mapPoint point, mapPoint start, List <mapPoint> open)
    {
        if (point.x == finishx && point.y == finishy)
        {
            return(true);
        }
        if (point.vaule == 1)
        {
            return(false);
        }
        if (close.Find(a => a.x == point.x && a.y == point.y) != null)
        {
            return(false);
        }
        int f, g, h;

        g = start.g + 1;
        h = GameTools.GetH(point.x, point.y, finishx, finishy);
        f = g + h;
        //Debug.LogError("  point.x  " + point.x + "  point.y  " + point.y + "   start.x  " + start.x+ "   start.y    " + start.y + "   g   " + g + "  h    " + h + "   f   " + f);
        if (open.Find(a => a.x == point.x && a.y == point.y) != null)
        {
            if (point.f > f)
            {
                point.f      = f;
                point.g      = g;
                point.parent = start;
            }
        }
        else
        {
            point.f      = f;
            point.g      = g;
            point.parent = start;
            open.Add(point);
        }
        return(false);
    }