#is there someone who could help me with

1 messages · Page 1 of 1 (latest)

wild linden
#

,

#

this is the maze

#

its randomly generated

#

but the top corners are broken

#

i think

#

or i mean they are

#
 public Path Walk()
    {
        // getting the grid so i can get the cells
        Grid grid = generator.getGrid();
        Cell cell;


        //asking for the unvisited neighbours
        List<Vector2> neighbours;
        try
        {
            neighbours = grid.cells[x, y].hasUnvisitedNeighbours(grid);
        }
        catch
        {
            neighbours = new List<Vector2>();
        }


        //testing if their are unvisited neighbours in the list
        //and if it issnt null it will randomly choose a neighbour
        //Debug.Log(neighbours.Count);
        if (neighbours.Count != 0)
        {
            int random = Random.Range(0, neighbours.Count);

            cell = grid.cells[(int)neighbours[random].x, (int)neighbours[random].y];

            //if there is another neighbour in the list there will be a chance it will mutate and make another path
            chance++;
            if(Random.Range(chance, 7) == 7)
            {
                chance = 0;
                int second = Random.Range(0, neighbours.Count);
                if (grid.cells[(int)neighbours[second].x, (int)neighbours[second].y] != cell)
                {
                    Path path = new Path(generator, cell.x, cell.y, stack);
                    walking(cell);
                    return path;
                }
            }
            walking(cell);
        }
#

this is the first script

#
public List<Vector2> hasUnvisitedNeighbours(Grid grid)
    {
        List<Vector2> neighbours = new List<Vector2>();

        if (grid.width >= x)
        {
            if (grid.cells[(x + 1), y].visited == false)
            {
                neighbours.Add(new Vector2(x + 1, y));
            }
        }
        if (grid.height >= y)
        {
            if (grid.cells[x, (y + 1)].visited == false)
            {
                neighbours.Add(new Vector2(x, y + 1));
            }
        }

        if (x > 0)
        {
            if (grid.cells[(x - 1), y].visited == false)
            {
                neighbours.Add(new Vector2(x - 1, y));
            }
        }

        if (y > 0)
        {
            if (grid.cells[x, (y - 1)].visited == false)
            {
                neighbours.Add(new Vector2(x, y - 1));
            }
        }
        return neighbours;
    }

and this is the second one