Beispiel #1
0
 private void MazeGraphCellFromW4Cell(
     MazeGraphCell mgCell,
     W4Cell w4Cell,
     int columNum,
     int rowNum,
     int columnCount
     )
 {
     mgCell.Neighbours = new List <MazeGraphCell>();
     if (!w4Cell.LeftWall)
     {
         mgCell.Neighbours.Add(
             _Cells[(columNum - 1) + rowNum * columnCount]);
     }
     if (!w4Cell.TopWall)
     {
         mgCell.Neighbours.Add(
             _Cells[columNum + (rowNum + 1) * columnCount]);
     }
     if (!w4Cell.RightWall)
     {
         mgCell.Neighbours.Add(
             _Cells[(columNum + 1) + rowNum * columnCount]);
     }
     if (!w4Cell.BotWall)
     {
         mgCell.Neighbours.Add(
             _Cells[columNum + (rowNum - 1) * columnCount]);
     }
 }
Beispiel #2
0
        //Works only on Cells with 2 neighbours
        private void SimplifyCell(
            MazeGraphCell toSimplify)
        {
            var neighbourCell0 = toSimplify.Neighbours[0];
            var neighbourCell1 = toSimplify.Neighbours[1];

            var index = neighbourCell0.Neighbours.IndexOf(toSimplify);

            neighbourCell0.Neighbours[index] = neighbourCell1;

            index = neighbourCell1.Neighbours.IndexOf(toSimplify);
            neighbourCell1.Neighbours[index] = neighbourCell0;
            _Cells.Remove(toSimplify);
        }