private void CreateVerticalConnections(
            W4Maze maze,
            int rowNum)
        {
            bool removeVertical  = false;
            bool isAddedVertical = false;

            for (int i = 0; i < maze.ColumnCount - 1; i++)
            {
                W4Cell cell     = maze.GetCell(i, rowNum);
                W4Cell nextCell = maze.GetCell(i + 1, rowNum);
                W4Cell topCell  = maze.GetCell(i, rowNum + 1);
                if (cell.Set != nextCell.Set)
                {
                    if (!isAddedVertical)
                    {
                        RemoveVerticalWall(cell, topCell);
                    }
                    isAddedVertical = false;
                }
                else
                {
                    removeVertical = Random.Range(0, 2) > 0;
                    if (removeVertical)
                    {
                        RemoveVerticalWall(cell, topCell);
                        isAddedVertical = true;
                    }
                }
            }
            CheckLastVertical(maze, rowNum, isAddedVertical);
        }
 private void RemoveHorizonWallBetweenCells(
     W4Maze maze,
     W4Cell leftCell,
     W4Cell rightCell,
     int rowNum)
 {
     leftCell.RightWall = false;
     rightCell.LeftWall = false;
     if (leftCell.Set < rightCell.Set)
     {
         maze.ReplaceSetInRow(rightCell.Set, leftCell.Set, rowNum);
     }
     else
     {
         maze.ReplaceSetInRow(leftCell.Set, rightCell.Set, rowNum);
     }
 }
        private void CheckLastVertical(W4Maze maze, int rowNum, bool isAddedVertical)
        {
            W4Cell lastCell    = maze.GetCell(maze.ColumnCount - 1, rowNum);
            W4Cell preLastCell = maze.GetCell(maze.ColumnCount - 2, rowNum);
            W4Cell topCell     = maze.GetCell(maze.ColumnCount - 1, rowNum + 1);

            if (lastCell.Set != preLastCell.Set)
            {
                RemoveVerticalWall(lastCell, topCell);
            }
            else
            {
                if (isAddedVertical ? Random.Range(0, 2) > 0 : true)
                {
                    RemoveVerticalWall(lastCell, topCell);
                }
            }
        }
 private void RemoveVerticalWall(W4Cell bot, W4Cell top)
 {
     bot.TopWall = false;
     top.BotWall = false;
     top.Set     = bot.Set;
 }