Esempio n. 1
0
    private void PlaceExitDoor()
    {
        while (true)
        {
            MazeCell rcell = cells[Random.Range(0, size.x), Random.Range(0, size.z)];
            for (int i = 0; i < MazeDirections.Count; i++)
            {
                MazeDirection dir  = MazeDirection.North + i;
                MazeCellEdge  edge = rcell.GetEdge(dir);
                if (edge is MazeWall)
                {
                    rcell.DestroyEdge(dir);
                    Vector2i coordinates = rcell.coordinates + dir.ToVector2i();
                    if (ContainsCoordinates(coordinates))
                    {
                        exitDoor = CreateChangeStageDoor(rcell, GetCell(coordinates), dir, 1);
                    }
                    else
                    {
                        exitDoor = CreateChangeStageDoor(rcell, null, dir, 1);
                    }

                    return;
                }
            }
        }
    }