Esempio n. 1
0
 public MazeMap(int height, int width, MazeMode mode)
     : base(height, width)
 {
     BuildByDivide(0, 0, height, width, ChooseOrientation(height, width), mode);
     Transform();
     PutExit();
 }
Esempio n. 2
0
    public void StartMazeBuilder(MazeMode mazeMode)
    {
        this.mazeMode = mazeMode;

        MazeData mazeData;

        switch (mazeMode)
        {
        case MazeMode.Random:
            mazeData = mazeBuilderRandom.RunMazeBuilder();
            break;

        case MazeMode.Perlin:
            mazeData = mazebuilderPerlin.RunMazeBuilder();
            break;

        case MazeMode.Perlin2:
            mazeData = mazebuilderPerlin2.RunMazeBuilder();
            break;

        case MazeMode.Depth:
            mazeData = mazebuilderDepth.RunMazeBuilder();
            break;

        case MazeMode.Kruskal:
            mazeData = mazeBuilderKruskal.RunMazeBuilder();
            break;

        case MazeMode.Prims:
            mazeData = mazeBuilderPrims.RunMazeBuilder();
            break;

        default:
            mazeData = new MazeData(false, new Vector2Int(0, 0), new Vector2Int(width - 1, height - 1), new List <WallInfo>());
            break;
        }

        visualizationManager.StartVMaze(mazeData);
    }
Esempio n. 3
0
 public void Create(int _height, int _width, MazeMode mode)
 {
     map      = new MazeMap((_height + 1) / 2, (_width + 1) / 2, mode);
     FontSize = -21.7297 * Math.Log(0.01129 * _height) - 1;
     Bold     = FontWeights.Bold;
 }
Esempio n. 4
0
        private void BuildByDivide(int x, int y, int _height, int _width, Orientation or, MazeMode mode)
        {
            if (_width < 2 || _height < 2)
            {
                return;
            }
            if (_width < 3 || _height < 3)
            {
                if (StaticRandom.Next(0, 3) > 1)
                {
                    return;
                }
            }
            bool hor = or == Orientation.HOR;
            int  hy1, hx1, hy2, hx2, hx3, hy3;

            int wy = y + (hor ? 0 : StaticRandom.Next(_width - 2));
            int wx = x + (hor ? StaticRandom.Next(_height - 2) : 0);

            if ((mode == MazeMode.OneWay) || _height < 5 || _width < 5)
            {
                hy1 = hy2 = hy3 = wy + (hor ? StaticRandom.Next(_width) : 0);
                hx1 = hx2 = hx3 = wx + (hor ? 0 : StaticRandom.Next(_height));
            }
            else if (!hor && _width >= 5 && _width <= 15)
            {
                hy1 = hy2 = hy3 = wy;
                hx1 = wx + StaticRandom.Next(_height / 2 - 1);
                hx2 = hx3 = wx + StaticRandom.Next(_height / 2, _height);
            }
            else if (hor && _height >= 5 && _height <= 15)
            {
                hy1 = wy + StaticRandom.Next(_width / 2 - 1);
                hx1 = hx2 = hx3 = wx;
                hy2 = hy3 = wy + StaticRandom.Next(_width / 2, _width);
            }
            else
            {
                hy1 = wy + (hor ? StaticRandom.Next(_width / 3 - 1) : 0);
                hx1 = wx + (hor ? 0 : StaticRandom.Next(_height / 3));
                hy2 = wy + (hor ? StaticRandom.Next(_width / 3 + 1, 2 * _width / 3 - 1) : 0);
                hx2 = wx + (hor ? 0 : StaticRandom.Next(_height / 3 + 1, 2 * _height / 3 - 1));
                hy3 = wy + (hor ? StaticRandom.Next(2 * _width / 3 + 1, _width) : 0);
                hx3 = wx + (hor ? 0 : StaticRandom.Next(2 * _height / 3 + 1, _height));
            }

            for (int i = 0; i < (hor ? _width : _height); i++)
            {
                if (!((wx == hx1 && wy == hy1) || (wx == hx2 && wy == hy2) || (wx == hx3 && wy == hy3)))
                {
                    if (map[wx][wy] != ' ')
                    {
                        map[wx][wy] = 'b';
                    }
                    else
                    {
                        map[wx][wy] = hor ? 'h' : 'v';
                    }
                }
                wy += (hor ? 1 : 0);
                wx += (hor ? 0 : 1);
            }

            int newh = hor ? wx - x + 1 : _height;
            int neww = hor ? _width : wy - y + 1;

            BuildByDivide(x, y, newh, neww, ChooseOrientation(newh, neww), mode);
            newh = hor ? _height - wx + x - 1 : _height;
            neww = hor ? _width : _width - wy + y - 1;
            BuildByDivide(hor ? wx + 1 : x, hor ? y : wy + 1, newh, neww, ChooseOrientation(newh, neww), mode);
        }
Esempio n. 5
0
    public void StartMazeBuilding()
    {
        MazeMode mazeMode = (MazeMode)mazeSelector.value;

        mazeManager.StartMazeBuilder(mazeMode);
    }