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

            return(firstCell.Id != (secondCell.Id - 1));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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;
     }
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 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;
            }
        }