Exemplo n.º 1
0
    private static bool NextWaveIteration(ref List <Node> openSet, ref Subregion subregion)
    {
        for (int i = openSet.Count - 1; i >= 0; i--)
        {
            if (openSet[i].subregion != null)
            {
                openSet.RemoveAt(i);
            }
        }

        if (openSet.Count == 0)
        {
            return(false);
        }

        foreach (Node neighbour in openSet[0].GetNeighbours())
        {
            if (!neighbour.IsTraversable || neighbour.subregion != null ||
                !IsInsideArea(neighbour.X, neighbour.Y, ((int)(openSet[0].X / _subregionSize)) * _subregionSize, ((int)(openSet[0].Y / _subregionSize)) * _subregionSize))
            {
                continue;
            }
            openSet.Add(neighbour);
        }

        subregion.AddNode(openSet[0]);
        openSet.RemoveAt(0);

        return(true);
    }