public TerrainCell(CellLocation location, TerrainGenerator terrainGenerator) { isVisible = false; isOccupied = false; this.location = location; cellResources = new ResourceHolder(); RegolithAmount = terrainGenerator.GetRegolithHeight(location.GetAbsX(), location.GetAbsZ()); containsRock = terrainGenerator.GetRegolithHeight(location.GetAbsX(), location.GetAbsZ()) > 0.9 ? true : false; iron = terrainGenerator.GetIronHeight(location.GetAbsX(), location.GetAbsZ()); ice = terrainGenerator.GetIceHeight(location.GetAbsX(), location.GetAbsZ()); helium = terrainGenerator.GetHeliumHeight(location.GetAbsX(), location.GetAbsZ()); }
public TerrainChunk Initialize(TerrainManager terrainManager, int cellsPerChunk, ChunkLocation location, TerrainGenerator terrainGenerator, Material chunkMaterial) { this.terrainManager = terrainManager; transform.position = new Vector3(location.GetX() * cellsPerChunk, 0, location.GetZ() * cellsPerChunk); transform.name = "Chunk"; gameObject.layer = 8; this.location = location; this.cellsPerChunk = cellsPerChunk; cellHeights = new float[cellsPerChunk + 1, cellsPerChunk + 1]; for (int i = 0; i < cellsPerChunk + 1; i++) { for (int j = 0; j < cellsPerChunk + 1; j++) { cellHeights[i, j] = terrainGenerator.GetTerrainHeight(i + location.GetAbsX(), j + location.GetAbsZ()); } } chunkCells = new TerrainCell[cellsPerChunk, cellsPerChunk]; for (int i = 0; i < cellsPerChunk; i++) { for (int j = 0; j < cellsPerChunk; j++) { CellLocation loc = new CellLocation(i, j, location); chunkCells[i, j] = new TerrainCell(loc, terrainGenerator); } } m_material = chunkMaterial; GetComponent <MeshRenderer>().material = m_material; return(this); }