private bool CellsOnTopOfEachOther(TwoTuple <Cell> cellPair) { Cell firstCell = cellPair.X; Cell secondCell = cellPair.Y; return(firstCell.Id != (secondCell.Id - 1)); }
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)); }
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); }
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; } }
private void CreateInteriorWallsAndDoors() { while (CellPairs.Count > 0) { TwoTuple <Cell> cellPair = CellPairs[0]; CellPairs.RemoveAt(0); if (CellsInSameTree(cellPair)) { CreateDoor(cellPair); } else { CreateWall(cellPair); } } }
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; } }