void createBlock(Vector3 blockPos) { int y = (int)blockPos.y; if (y < -128) { return; } // plain 2 int heightScale = 20; // 40+ float detailScale = 70.0f; int p_y = (int)(Mathf.PerlinNoise((blockPos.x + this.seed) / detailScale, (blockPos.z + this.seed) / detailScale) * heightScale); Block block; if (y > p_y /*42*/) { return; // air } else if (y > 38) { block = new Snow(); } else if (y > 5 && y == p_y) { block = new Grass(); /* * if (UnityEngine.Random.Range (0, 10) <= 2) { * addBlock (blockPos + new Vector3 (0, 1, 0), new Fern ()); * } else if (UnityEngine.Random.Range (0, 50) <= 2) { * addBlock (blockPos + new Vector3 (0, 1, 0), new Rose ()); * } */ } else if (y > 5) { block = new Dirt(); } else if (y == -128) { block = new BedRock(); } else { block = new Sand(); } addBlock(blockPos, block); }
void createBlock(Vector3 blockPos) { int y = (int)blockPos.y; if (y < -128) return; // plain 2 int heightScale = 20; // 40+ float detailScale = 70.0f; int p_y = (int)(Mathf.PerlinNoise ((blockPos.x + this.seed)/detailScale, (blockPos.z + this.seed)/detailScale) * heightScale); Block block; if (y > p_y /*42*/) { return; // air } else if (y > 38) { block = new Snow (); } else if (y > 5 && y == p_y) { block = new Grass (); /* if (UnityEngine.Random.Range (0, 10) <= 2) { addBlock (blockPos + new Vector3 (0, 1, 0), new Fern ()); } else if (UnityEngine.Random.Range (0, 50) <= 2) { addBlock (blockPos + new Vector3 (0, 1, 0), new Rose ()); } */ } else if (y > 5) { block = new Dirt (); } else if (y == -128) { block = new BedRock (); } else { block = new Sand (); } addBlock(blockPos, block); }