Example #1
0
 protected void AddButtresses(MazeCell cell)
 {
     for (int i = 0; i < MazeDirections.Count; i++)
     {
         GameObject buttress = Instantiate(buttressPrefab, cell.transform, false);
         buttress.transform.GetChild(0).localPosition =
             new Vector3(sizeCells * 0.5f - 0.16666f, 0, sizeCells * 0.5f - 0.16666f);
         buttress.transform.localRotation = MazeDirections.ToRotation((MazeDirection)i);
         cell.buttresses.Add(buttress);
     }
 }
Example #2
0
        /**
         * chooses random direction to connect cell to and removes walls
         */
        private static void ConnectCell(MazeCell cell)
        {
            MazeDirection randomDirection = MazeDirections.RandomValue;
            MazeCell      chosenCell      = GetNeighborCellInDirection(cell, randomDirection);

            while (chosenCell == null)
            {
                randomDirection = MazeDirections.GetNext(randomDirection);
                chosenCell      = GetNeighborCellInDirection(cell, randomDirection);
            }

            DestroyWall(cell.GetEdge(randomDirection));
            DestroyWall(chosenCell.GetEdge(randomDirection.GetOpposite()));

            cell.SetVisited(true);
            WalkFromCell(cell);
        }
Example #3
0
 private static MazeCell GetNeighborCellInDirection(MazeCell cell, MazeDirection direction)
 {
     return(GetCell(cell.GetX() + MazeDirections.ToIntVector2(direction).x,
                    cell.GetY() + MazeDirections.ToIntVector2(direction).y));
 }