コード例 #1
0
ファイル: DownBar.cs プロジェクト: toyukan6/GenerateMaze
        void MakeWall(Mass m, Direction4 d)
        {
            int newI = m.I, newJ = m.J;
            switch (d)
            {
                case Direction4.Up: newI = m.I - 1; break;
                case Direction4.Right: newJ = m.J + 1; break;
                case Direction4.Down: newI = m.I + 1; break;
                case Direction4.Left: newJ = m.J - 1; break;
            }

            maze[newI, newJ].MassState = State.Wall;
        }
コード例 #2
0
ファイル: Clustering.cs プロジェクト: toyukan6/GenerateMaze
        protected override List<Direction4> SurveyDirection(Mass m)
        {
            int i = m.I, j = m.J;
            List<Direction4> directions = new List<Direction4>();
            if (i > 1 && m.Label != maze[i - 2, j].Label)
                directions.Add(Direction4.Up);
            if (i < mazeHeight - 2 && m.Label != maze[i + 2, j].Label)
                directions.Add(Direction4.Down);
            if (j > 1 && m.Label != maze[i, j - 2].Label)
                directions.Add(Direction4.Left);
            if (j < mazeWidth - 2 && m.Label != maze[i, j + 2].Label)
                directions.Add(Direction4.Right);

            return directions;
        }
コード例 #3
0
ファイル: ExtendWall.cs プロジェクト: toyukan6/GenerateMaze
        protected override List<Direction4> SurveyDirection(Mass m)
        {
            int i = m.I, j = m.J;
            List<Direction4> directions = new List<Direction4>();
            if (i > 1 && (maze[i - 2, j].MassState == State.Empty || maze[i - 2, j].MassState == State.Wall))
                directions.Add(Direction4.Up);
            if (i < mazeHeight - 2 && (maze[i + 2, j].MassState == State.Empty || maze[i + 2, j].MassState == State.Wall))
                directions.Add(Direction4.Down);
            if (j > 1 && (maze[i, j - 2].MassState == State.Empty || maze[i, j - 2].MassState == State.Wall))
                directions.Add(Direction4.Left);
            if (j < mazeWidth - 2 && (maze[i, j + 2].MassState == State.Empty || maze[i, j + 2].MassState == State.Wall))
                directions.Add(Direction4.Right);

            return directions;
        }
コード例 #4
0
ファイル: DownBar.cs プロジェクト: toyukan6/GenerateMaze
        protected override List<Direction4> SurveyDirection(Mass m)
        {
            int i = m.I, j = m.J;
            List<Direction4> directions = new List<Direction4>();
            if (i == 2 && maze[i - 1, j].MassState == State.Empty)
                directions.Add(Direction4.Up);
            if (i < mazeHeight - 1 && maze[i + 1, j].MassState == State.Empty)
                directions.Add(Direction4.Down);
            if (j > 0 && maze[i, j - 1].MassState == State.Empty)
                directions.Add(Direction4.Left);
            if (j < mazeWidth - 1 && maze[i, j + 1].MassState == State.Empty)
                directions.Add(Direction4.Right);

            return directions;
        }
コード例 #5
0
ファイル: DiggingAHole.cs プロジェクト: toyukan6/GenerateMaze
        Mass MakeNewRoad(Mass m, Direction4 d)
        {
            int i = m.I, j = m.J;
            int newI = i, newJ = j;
            switch (d)
            {
                case Direction4.Up: newI = i - 2; break;
                case Direction4.Right: newJ = j + 2; break;
                case Direction4.Down: newI = i + 2; break;
                case Direction4.Left: newJ = j - 2; break;
            }

            maze[newI, newJ].MassState = State.Empty;

            return maze[newI, newJ];
        }
コード例 #6
0
ファイル: Clustering.cs プロジェクト: toyukan6/GenerateMaze
        int BreakWall(Mass m, Direction4 d, Dictionary<int, List<Mass>> clustering)
        {
            int i = m.I, j = m.J;
            int newI = i, newJ = j;
            Mass newMass = null;
            switch (d)
            {
                case Direction4.Up: newI = i - 1; newMass = maze[i - 2, j]; break;
                case Direction4.Right: newJ = j + 1; newMass = maze[i, j + 2]; break;
                case Direction4.Down: newI = i + 1; newMass = maze[i + 2, j]; break;
                case Direction4.Left: newJ = j - 1; newMass = maze[i, j - 2]; break;
            }

            int minLabel = Math.Min(m.Label, newMass.Label),
                maxLabel = Math.Max(m.Label, newMass.Label);

            maze[newI, newJ].MassState = State.Empty;

            if (clustering.ContainsKey(maxLabel))
                clustering[maxLabel].ForEach(c => c.Label = minLabel);

            return maxLabel;
        }
コード例 #7
0
ファイル: ExtendWall.cs プロジェクト: toyukan6/GenerateMaze
        Mass MakeNewWall(Mass m, Direction4 direction)
        {
            int i = m.I, j = m.J;
            int newI = i, newJ = j;
            switch (direction)
            {
                case Direction4.Up: newI = i - 2; break;
                case Direction4.Right: newJ = j + 2; break;
                case Direction4.Down: newI = i + 2; break;
                case Direction4.Left: newJ = j - 2; break;
            }

            if (maze[newI, newJ].MassState != State.Wall)
                maze[newI, newJ].MassState = State.NewWall;

            return maze[newI, newJ];
        }