예제 #1
0
    /// <summary>
    /// 壁を掘る
    /// </summary>
    /// <param name="DigDir">掘る向き</param>
    /// <param name="x">迷路のx座標</param>
    /// <param name="y">迷路のy座標</param>
    void Dig(int DigDir, int x, int y)
    {
        PreLocationX.Push(x);
        PreLocationY.Push(y);

        switch (DigDir)
        {
        case (int)Dir.Up:
            Maze[x, y - 1] = 1;
            Maze[x, y - 2] = 1;
            SetCurrentLocation(x, y - 2);
            break;

        case (int)Dir.Down:
            Maze[x, y + 1] = 1;
            Maze[x, y + 2] = 1;
            SetCurrentLocation(x, y + 2);
            break;

        case (int)Dir.Right:
            Maze[x + 1, y] = 1;
            Maze[x + 2, y] = 1;
            SetCurrentLocation(x + 2, y);
            break;

        case (int)Dir.Left:
            Maze[x - 1, y] = 1;
            Maze[x - 2, y] = 1;
            SetCurrentLocation(x - 2, y);
            break;
        }

        CreatedPassageCount++;
    }
예제 #2
0
    /// <summary>
    /// 壁を掘って通路にしていく
    /// </summary>
    /// <param name="x">迷路のx座標</param>
    /// <param name="y">迷路のy座標</param>
    void DigWall(int x, int y)
    {
        if (CreateLimit == CreatedPassageCount)
        {
            return;
        }

        int DigDir = ChoiceDigDir(x, y);

        //どの方向も掘れない場合前回の場所に戻ってやり直し
        if (DigDir == FailVal)
        {
            DigWall(PreLocationX.Pop(), PreLocationY.Pop());
            return;
        }

        Dig(DigDir, x, y);
        DigWall(CurrentX, CurrentY);
    }