コード例 #1
0
ファイル: NbackGenerator.cs プロジェクト: nchou001/Popz
    public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int difficulty = navigationDifficulty;
        int scale = 10;

        // Generate beginning so character doesnt fall
        if (generateCount == 0) {
            for (int i = 0; i < 5; ++i) {
                ggen.GenerateGround (i, 0, grid, tc);
                ggen.GenerateGround (i, 7, grid, tc);
            }
        }
        ++generateCount;

        // Entry for prototype platforms generation
        if (platforms) {
            GenerateNbackInGridPlatforms(grid, tc, ggen);
            return;
        }

        // Generate Nback collectibles
        int x = lastGridOffset;
        for ( ; x < grid.numCellsX; x += rate) {
            int rand = Random.Range(0, 2);
            int y = rand == 0 ? 1 : 6;
            Transform h = GenerateNbackObjectInGrid(x, y, grid, tc);
        }

        // Generate ground and potholes
        for (int i = 0; i < grid.numCellsX; ++i) {
            // For floor
            // Generate ground (NOT pothole) by scale and difficulty
            if (grid.containsObject(i, 0)) {
                Debug.Log ("Grid Contains at: " + i);
                continue;
            }
            int cap = Mathf.Min (4, grid.numCellsX - i + 1);
            int roll = Random.Range (1, cap);

            while (!ggen.GenerateWideGround(i, 0, roll, grid, tc)) {
                roll = Random.Range (1, 4);
            }

        //			int rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				ggen.GenerateGround (i, 0, grid, tc);
        //			}
        //
        //			// For Ceiling
        //			rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				//ggen.GenerateGround (i, 7, grid, tc);
        //			}
        }
        lastGridOffset = x - grid.numCellsX;
    }