示例#1
0
        private bool CellsOnTopOfEachOther(TwoTuple <Cell> cellPair)
        {
            Cell firstCell  = cellPair.X;
            Cell secondCell = cellPair.Y;

            return(firstCell.Id != (secondCell.Id - 1));
        }
示例#2
0
        private bool CellsInSameTree(TwoTuple <Cell> cellPair)
        {
            Cell        firstCell  = cellPair.X;
            Cell        secondCell = cellPair.Y;
            Tree <Cell> TreeOne    = firstCell.TreeNodePointer;
            Tree <Cell> TreeTwo    = secondCell.TreeNodePointer;

            return(!TreeOne.IsInSameTreeAs(TreeTwo));
        }
示例#3
0
        private void CreateDoor(TwoTuple <Cell> cellPair)
        {
            Cell        firstCell  = cellPair.X;
            Cell        secondCell = cellPair.Y;
            Tree <Cell> treeOne    = firstCell.TreeNodePointer;
            Tree <Cell> treeTwo    = secondCell.TreeNodePointer;

            treeOne.MergeWith(treeTwo);
        }
示例#4
0
 private void RandomizeListOfCellPairs()
 {
     System.Random r = new System.Random();
     for (int i = 0; i < CellPairs.Count; i++)
     {
         int             randomPosition = r.Next(CellPairs.Count);
         TwoTuple <Cell> firstPair      = CellPairs[i];
         TwoTuple <Cell> secondPair     = CellPairs[randomPosition];
         CellPairs[i] = secondPair;
         CellPairs[randomPosition] = firstPair;
     }
 }
示例#5
0
 private void CreateInteriorWallsAndDoors()
 {
     while (CellPairs.Count > 0)
     {
         TwoTuple <Cell> cellPair = CellPairs[0];
         CellPairs.RemoveAt(0);
         if (CellsInSameTree(cellPair))
         {
             CreateDoor(cellPair);
         }
         else
         {
             CreateWall(cellPair);
         }
     }
 }
示例#6
0
        private void CreateWall(TwoTuple <Cell> cellPair)
        {
            Cell firstCell  = cellPair.X;
            Cell secondCell = cellPair.Y;

            if (CellsOnTopOfEachOther(cellPair))
            {
                firstCell.HasBottomWall = true;
                secondCell.HasTopWall   = true;
            }
            else
            {
                firstCell.HasRightWall = true;
                secondCell.HasLeftWall = true;
            }
        }