Ejemplo n.º 1
0
	void GenerateWorld(Vector3 sizeInChunks)
	{
		// Loop over each dimension's length.
		for (int z = 0; z < sizeInChunks.x; z++)
		{
			for (int y = 0; y < sizeInChunks.y; y++)
			{
				for (int x = 0; x < sizeInChunks.z; x++)
				{
					GameObject newChunkGo = new GameObject("Chunk");
					newChunkGo.transform.parent = this.transform;
					newChunkGo.transform.localPosition = new Vector3(x*16f, y*16f, z*16f);
					ChunkUI chunkUI = newChunkGo.AddComponent<ChunkUI>();
					Chunk newChunk = new Chunk(new Vector3((float)x, (float)y, (float)z));
					chunkUI.chunk = newChunk;
					//if bottom chunk build floor
					if (y == 0) newChunk.BuildFlatFloor();

					chunks.Add(newChunk);
					chunkUI.Set(newChunk);

				}
			}
		}
	}