예제 #1
0
        private bool ClusterCell(int row, int col, int index)
        {
            bool processed = false;

            if (maze.IsCellExists(row, col))
            {
                if (clusters.IsNonclustered(row, col))
                {
                    clusters.SetClusterIndex(row, col, index);
                    processed = true;
                }
            }

            return(processed);
        }
예제 #2
0
        void WalkCluster(int row, int col, int cluster)
        {
            if (processedMaze.IsCellExists(row, col))
            {
                if (clusters.IsNonclustered(row, col))
                {
                    MazeSide currentCell = processedMaze.GetCell(row, col);
                    clusters.SetClusterIndex(row, col, cluster);

                    if (processedMaze.IsCellExists(row - 1, col))
                    {
                        if (!currentCell.HasFlag(MazeSide.Top))
                        {
                            WalkCluster(row - 1, col, cluster);
                        }
                    }

                    if (processedMaze.IsCellExists(row + 1, col))
                    {
                        if (!currentCell.HasFlag(MazeSide.Bottom))
                        {
                            WalkCluster(row + 1, col, cluster);
                        }
                    }

                    if (processedMaze.IsCellExists(row, col - 1))
                    {
                        if (!currentCell.HasFlag(MazeSide.Left))
                        {
                            WalkCluster(row, col - 1, cluster);
                        }
                    }

                    if (processedMaze.IsCellExists(row, col + 1))
                    {
                        if (!currentCell.HasFlag(MazeSide.Right))
                        {
                            WalkCluster(row, col + 1, cluster);
                        }
                    }
                }
            }
        }