Ejemplo n.º 1
0
        /// <summary>
        /// Returns the cells that are adjecent to given cell, are not checked yet and are not blocked by a wall
        /// </summary>
        /// <param name="cell"></param>
        /// <returns></returns>
        public List <MazeCell> GetNextCellsInPath(MazeCell cell)
        {
            List <MazeCell> cells = new List <MazeCell>();

            MazeCell top = generationService.GetTopNeighbour(cell);

            if (top != null && !top.IsChecked && cell.HasPassageTowardsCell(top))
            {
                cells.Add(top);
            }

            MazeCell bottom = generationService.GetBottomNeighbour(cell);

            if (bottom != null && !bottom.IsChecked && cell.HasPassageTowardsCell(bottom))
            {
                cells.Add(bottom);
            }

            MazeCell left = generationService.GetLeftNeighbour(cell);

            if (left != null && !left.IsChecked && cell.HasPassageTowardsCell(left))
            {
                cells.Add(left);
            }

            MazeCell right = generationService.GetRightNeighbour(cell);

            if (right != null && !right.IsChecked && cell.HasPassageTowardsCell(right))
            {
                cells.Add(right);
            }

            return(cells);
        }
        /// <summary>
        /// Returns the top and right neighbours of given cell using the maze generation service
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        private List <MazeCell> GetTopAndRightNeighbours(MazeCell cell, MazeGenerationService service)
        {
            List <MazeCell> cells = new List <MazeCell>();

            MazeCell top = service.GetTopNeighbour(cell);

            if (top != null)
            {
                cells.Add(top);
            }

            MazeCell right = service.GetRightNeighbour(cell);

            if (right != null)
            {
                cells.Add(right);
            }

            return(cells);
        }