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

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