public void GenerateTerrain(Vector3 spawnPos) { grid.ClearGrid(); TerrainChunk tc = GameObject.Instantiate(terrainChunk, spawnPos, Quaternion.identity) as TerrainChunk; // Generate ground // Experimental: Generate ground separately for Nback // groundGen.GenerateGrounds(grid, tc); // Generate For Pattern if (gameMngr.Modes().Contains(GameModes.Pattern)) { //Platforms should also be spawned in cloud format! /*if(genPlatforms) * { * platformGen.GeneratePlatforms (grid, tc); * * } * if(genPlants) * { * collectibleGen.GenerateCollectibles (grid, tc); * }*/ } // Generate For Nback if (gameMngr.Modes().Contains(GameModes.Nback)) { nbackGen.GenerateNbackInGrid(grid, tc, groundGen); } else { groundGen.GenerateGrounds(grid, tc); } }
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; //int y = 1; Transform h = GenerateNbackObjectInGrid(x, y, grid, tc); } ggen.GenerateGrounds(grid, tc, 0, false, 60); ggen.GenerateGrounds(grid, tc, 7, true); lastGridOffset = x - grid.numCellsX; }
public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen) { //Called from Terrainen 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 on floor,ceiling, and random int x = lastGridOffset; int y = 3; for ( ; x < grid.numCellsX; x += rate) { int rand = Random.Range(0, 2); //int y = rand == 0 ? 1 : 6; if(timer >= 0f && timer < 40f){ y = 3; } else if (timer >= 40f && timer < 80f) { y = 5; } else if (timer >= 80f && timer < 120f) { y = 6; } else if (timer >= 120f && timer < 240f) { y = 1; } else if (timer >= 240f && timer < 280) { y = rand == 0 ? 1 : 5; } else if ((timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) { y = rand == 0 ? 1 : 6; } else if ((timer >= 320f && timer < 360f) || timer >= 480f) { y = rand == 0 ? 1 : 4; } // Used to create empty space between levels and updates current level int emptyspace = 0; if(timer >= 120 && timer < 125){ currentLevel = 2; emptyspace = 1; }else if(timer >= 240 && timer < 245){ currentLevel = 3; emptyspace = 1; }else if(timer >= 360 && timer < 365){ currentLevel = 4; emptyspace = 1; }else if(timer >= 480 && timer < 485){ currentLevel = 5; emptyspace = 1; }else if(timer >= 0 && timer < 120){ currentLevel = 1; emptyspace = 0; }else{ emptyspace = 0; } if(emptyspace == 0){ Transform h = GenerateNbackObjectInGrid(x, y, grid, tc); } } //GenerateGround ggen.GenerateGrounds (grid, tc, 0, false); //Generate Ceilings depending on timer if ((timer >= 0 && timer < 40) || (timer >= 200f && timer < 240f) || (timer >= 320f && timer < 360f) || timer >= 480f) { ggen.GenerateGrounds (grid, tc, 5, true); } else if ((timer >= 40f && timer < 80f) || (timer >= 160f && timer < 200f) || (timer >= 240f && timer < 280f)) { ggen.GenerateGrounds (grid, tc, 6, true); } else if ((timer >= 80f && timer < 160f) || (timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) { ggen.GenerateGrounds (grid, tc, 7, true); } lastGridOffset = x - grid.numCellsX; }
public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen) { //Called from Terrainen 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 on floor,ceiling, and random int x = lastGridOffset; int y = 3; for ( ; x < grid.numCellsX; x += rate) { int rand = Random.Range(0, 2); //int y = rand == 0 ? 1 : 6; if (timer >= 0f && timer < 40f) { y = 3; } else if (timer >= 40f && timer < 80f) { y = 5; } else if (timer >= 80f && timer < 120f) { y = 6; } else if (timer >= 120f && timer < 240f) { y = 1; } else if (timer >= 240f && timer < 280) { y = rand == 0 ? 1 : 5; } else if ((timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) { y = rand == 0 ? 1 : 6; } else if ((timer >= 320f && timer < 360f) || timer >= 480f) { y = rand == 0 ? 1 : 4; } // Used to create empty space between levels and updates current level int emptyspace = 0; if (timer >= 120 && timer < 125) { currentLevel = 2; emptyspace = 1; } else if (timer >= 240 && timer < 245) { currentLevel = 3; emptyspace = 1; } else if (timer >= 360 && timer < 365) { currentLevel = 4; emptyspace = 1; } else if (timer >= 480 && timer < 485) { currentLevel = 5; emptyspace = 1; } else if (timer >= 0 && timer < 120) { currentLevel = 1; emptyspace = 0; } else { emptyspace = 0; } if (emptyspace == 0) { Transform h = GenerateNbackObjectInGrid(x, y, grid, tc); } } //GenerateGround ggen.GenerateGrounds(grid, tc, 0, false); //Generate Ceilings depending on timer if ((timer >= 0 && timer < 40) || (timer >= 200f && timer < 240f) || (timer >= 320f && timer < 360f) || timer >= 480f) { ggen.GenerateGrounds(grid, tc, 5, true); } else if ((timer >= 40f && timer < 80f) || (timer >= 160f && timer < 200f) || (timer >= 240f && timer < 280f)) { ggen.GenerateGrounds(grid, tc, 6, true); } else if ((timer >= 80f && timer < 160f) || (timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) { ggen.GenerateGrounds(grid, tc, 7, true); } lastGridOffset = x - grid.numCellsX; }