コード例 #1
0
ファイル: GameController.cs プロジェクト: arima133/MiraMaze
    public void DeleteItem(MazeObjectType eType)
    {
        switch (eType)
        {
        case MazeObjectType.Item1:
            if (null != this.itemObject1)
            {
                this.m_nPoint += 100;
                Destroy(this.itemObject1);
                GetComponent <AudioSource>().PlayOneShot(this.pickUpItem);
            }
            break;

        case MazeObjectType.Item2:
            if (null != this.itemObject2)
            {
                this.m_nPoint += 150;
                Destroy(this.itemObject2);
                GetComponent <AudioSource>().PlayOneShot(this.pickUpItem);
            }
            break;

        case MazeObjectType.Item3:
            if (null != this.itemObject3)
            {
                this.m_nPoint += 200;
                Destroy(this.itemObject3);
                GetComponent <AudioSource>().PlayOneShot(this.pickUpItem);
            }
            break;

        default:
            break;
        }
    }
コード例 #2
0
    //棒倒し法による迷路生成
    public MazeObjectType[,] GenerateMaze(int width, int height)
    {
        //5未満のサイズでは生成できない
        ///if (height < 5 || width <5) throw new ArgumentOutOfRangeException();
        if (width % 2 == 0)
        {
            width++;
        }
        if (height % 2 == 0)
        {
            height++;
        }

        //指定サイズで生成し外周を壁にする
        var maze = new MazeObjectType[width, height];

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < height; z++)
            {
                if (x == 0 || z == 0 || x == width - 1 || z == height - 1)
                {
                    maze[x, z] = MazeObjectType.Wall;//外周はすべて壁
                }
                else
                {
                    maze[x, z] = MazeObjectType.Path;//外周以外は通路
                }
            }
        }
        //棒を立て、倒す
        //var rnd = GameStaticParameters.Random;
        for (int x = 2; x < width - 1; x += 2)
        {
            for (int z = 2; z < height - 1; z += 2)
            {
                maze[x, z] = MazeObjectType.Wall;//棒を立てる

                //倒せるまで繰り返す
                while (true)
                {
                    //1行目のみ上に倒せる
                    int direction;
                    if (z == 2)
                    {
                        direction = Mathf.RoundToInt(Random.Range(1, 4)); //rnd.Next(4);
                    }
                    else
                    {
                        direction = Mathf.RoundToInt(Random.Range(1, 3));// rnd.Next(3);
                    }
                    //棒を倒す方向を決める
                    int wallX = x;
                    int wallZ = z;
                    switch (direction)
                    {
                    case 0:    //右
                        wallX++;
                        break;

                    case 1:    //下
                        wallZ++;
                        break;

                    case 2:    //左
                        wallX--;
                        break;
                    }
                    //壁じゃない場合のみ倒して終了
                    if (maze[wallX, wallZ] != MazeObjectType.Wall)
                    {
                        maze[wallX, wallZ] = MazeObjectType.Wall;
                        break;
                    }
                }
            }
        }

        //  スタート位置
        maze[1, 0] = MazeObjectType.Path;

        //  ゴール
        maze[1, height - 1] = MazeObjectType.Goal;

        return(maze);
    }
コード例 #3
0
 public MazeObject(MazeObjectType type)
     : this(type, 0)
 {
 }
コード例 #4
0
 public MazeObject(MazeObjectType type, int points)
 {
     this.type   = type;
     this.points = points;
 }
コード例 #5
0
 public MazeObject(MazeObjectType type)
     : this(type, 0)
 {
 }
コード例 #6
0
 public MazeObject(MazeObjectType type, int points)
 {
     this.type = type;
     this.points = points;
 }