Example #1
0
    // Use this for initialization
    void Start()
    {
        this.sizeOfMaze = 24 + 8 * level;
        int center = sizeOfMaze / 2;

        var creater = new MazeCreater(sizeOfMaze);

        creater.CreateMap();
        var map = creater.ChangeSomeLeavesForstep(rateOfEnemy * 2.5f, sizeOfMaze / 2, 'e');

        for (int x = 0; x < map.GetLength(0); ++x)
        {
            for (int y = 0; y < map.GetLength(1); ++y)
            {
                GameObject gameObject = null;
                if (map[x, y] == 'r')
                {
                    gameObject = GameObject.Instantiate(road);
                }
                else if (map[x, y] == 'h')
                {
                    GameObject.Instantiate(road, new Vector2(x, y), new Quaternion());
                    gameObject = GameObject.Instantiate(food);
                    ++targetGold;
                }
                else if (map[x, y] == 'e')
                {
                    GameObject.Instantiate(road, new Vector2(x, y), new Quaternion());
                    gameObject = GameObject.Instantiate(enemy);
                    ++sizeOfEnemys;
                }
                else
                {
                    gameObject = GameObject.Instantiate(wall);
                }

                gameObject.transform.position = new Vector2(x, y);
            }
        }

        player.transform.position = new Vector2(center, center);

        if (rateOfEnemy == 0)
        {
            BGMManager.SetOneHot(0);
        }
        else
        {
            BGMManager.SetOneHot(1);
        }
    }
Example #2
0
        static void Main(string[] args)
        {
            MazeObject mazeObject;

            int           iXSize;
            int           iYSize;
            int           iSeed;
            string        strErrorMessaege;
            MazeErrorType?errorType;

            Console.WriteLine("------------------------------------");
            Console.WriteLine("迷路作成テストプログラム");
            Console.WriteLine("------------------------------------");
            while (true)
            {
                iXSize = Program.InputNumber("Xサイズを入力", "Xサイズ");
                iYSize = Program.InputNumber("Yサイズを入力", "Yサイズ");
                iSeed  = Program.InputNumber("シード値を入力(指定しないときは-1にする)", "シード値");

                if (!MazeCreater.CheckMazeSetting(iXSize, iYSize, out strErrorMessaege, out errorType))
                {
                    Console.WriteLine(strErrorMessaege);
                    continue;
                }

                mazeObject = MazeCreater.CreateMaze(iXSize, iYSize, iSeed);
                Program.Show(mazeObject);
                if (Program.InputYesNo("迷路を自動で解きますか?"))
                {
                    if (mazeObject.Solve())
                    {
                        Program.Show(mazeObject);
                    }
                    else
                    {
                        Console.WriteLine("迷路が解けなかったようです…");
                    }
                }
                if (!Program.InputYesNo("続けますか?"))
                {
                    break;
                }
            }
        }