コード例 #1
0
    public BasicMaze(int R, int C)
    {
        this.R = R;
        this.C = C;

        blocks = new List <List <bool> >();
        // +2 because of the border on both side
        for (int r = 0; r < R + 2; r++)
        {
            blocks.Add(new List <bool>());
            for (int c = 0; c < C + 2; c++)
            {
                blocks[r].Add(false);
            }
        }

        startPoint = new Point();
        endPoint   = new Point();

        string mazeData = MazeData.getRandomMazeData(R, C, GameState.difficulty);

        if (mazeData != null)
        {
            string[] token = mazeData.Split();

            startPoint.r = Convert.ToInt32(token[0]);
            startPoint.c = Convert.ToInt32(token[1]);

            // +2 because of the border on both side
            for (int r = 0; r < R + 2; r++)
            {
                for (int c = 0; c < C + 2; c++)
                {
                    blocks[r][c] = (token[2][r * (C + 2) + c] == '0') ? false : true;
                }
            }
        }
        else
        {
            // Set random value on each block
            for (int r = 1; r <= R; r++)
            {
                for (int c = 1; c <= C; c++)
                {
                    blocks[r][c] = (random.Next(2) == 0) ? false : true;
                }
            }
        }

        setFitness();
    }
コード例 #2
0
    void Start()
    {
        Debug.Log(GameState.difficulty);

        GameState.state = GameState.PLAYING;
        Time.timeScale  = 1;

        for (int h = 0; h < MAZE_H; h++)
        {
            if (MazeData.getRandomMazeData(MAZE_R, MAZE_C, GameState.difficulty) != null)
            {
                // Offline
                basicMazes.Add(new BasicMaze(MAZE_R, MAZE_C));
            }
            else
            {
                // Online
                // Online assume difficuty = 0
                generateBasicMaze();
            }

            if (isDebugging)
            {
                basicMazes[h].log();
            }
        }

        instantiateMaze();

        allocateItem();

        initialRandomEvent();

        generatePlayer();

        generateBoss();

        switch (GameMode.mode)
        {
        case GameMode.ESCAPING:
            EscapingState.state = EscapingState.BEGINNING;
            TargetMenu.addTarget("Find the exit.");
            break;

        case GameMode.INFINITE:
            TargetMenu.addTarget("Try to survive!");
            break;
        }
    }