private void InitPrefabsAndScripts() { // Biome/color tuple Tuple <uint, uint, uint, uint, uint> BiomeTuple = new Tuple <uint, uint, uint, uint, uint>(biome_Water, biome_Sand, biome_Grass, biome_Mountain, biome_Snow); Tuple <Color, Color, Color, Color, Color> ColorTuple = new Tuple <Color, Color, Color, Color, Color>(texture_WaterColor, texture_SandColor, texture_GrassColor, texture_MountainColor, texture_SnowColor); // Heightmap tuples Tuple <float, float, float, float, float> heightmapBasesTuple = new Tuple <float, float, float, float, float>(heightmap_WaterBase, heightmap_SandBase, heightmap_GrassBase, heightmap_MountainBase, heightmap_SnowBase); Tuple <float, float, float, float, float> heightmapDispTuple = new Tuple <float, float, float, float, float>(heightmap_WaterDisp, heightmap_SandDisp, heightmap_GrassDisp, heightmap_MountainDisp, heightmap_SnowDisp); // Model placer GameObject ModelPlacerPrefab = (GameObject)Resources.Load("PipelinePrefabs/ModelPlacerPrefab"); ModelPlacerInstance = (GameObject)GameObject.Instantiate(ModelPlacerPrefab, new Vector3(0, 0, 0), Quaternion.identity); ModelPlacerScript = ModelPlacerInstance.GetComponent <ModelPlacer>(); ModelPlacerScript.Init(heightmap_PowerN, block_VertexWidth, biome_HeightmapContentWidth, mp_waterHeight, heightmap_deltaClamp, BiomeTuple, mp_modelsPerBlock, mp_modelPlacementChance); // Biome gen GameObject BiomeGenPrefab = (GameObject)Resources.Load("PipelinePrefabs/BiomeGenPrefab"); BiomeGenInstance = (GameObject)GameObject.Instantiate(BiomeGenPrefab, new Vector3(0, 0, 0), Quaternion.identity); BiomeGenScript = BiomeGenInstance.GetComponent <BiomeGen>(); BiomeGenScript.Init(biome_Dimensions, biome_SeedSpacing, biome_DisplacementDiv, BiomeTuple); // Map database GameObject MapDatabasePrefab = (GameObject)Resources.Load("PipelinePrefabs/MapDatabasePrefab"); MapDatabaseInstance = (GameObject)GameObject.Instantiate(MapDatabasePrefab, new Vector3(0, 0, 0), Quaternion.identity); MapDatabaseScript = MapDatabaseInstance.GetComponent <MapDatabase>(); MapDatabaseScript.Init(heightmap_PowerN, biome_Dimensions, biome_HeightmapContentWidth, block_VertexWidth); // Heightmap gen GameObject HeightmapGenPrefab = (GameObject)Resources.Load("PipelinePrefabs/HeightmapGenPrefab"); HeightmapGenInstance = (GameObject)GameObject.Instantiate(HeightmapGenPrefab, new Vector3(0, 0, 0), Quaternion.identity); HeightmapGenScript = HeightmapGenInstance.GetComponent <HeightmapGen>(); HeightmapGenScript.Init(heightmap_PowerN, BiomeTuple, heightmapBasesTuple, heightmapDispTuple, heightmap_displacementScale, heightmap_deltaScale, heightmap_deltaClamp);; // Material gen GameObject MaterialGenPrefab = (GameObject)Resources.Load("PipelinePrefabs/MaterialGenPrefab"); MaterialGenInstance = (GameObject)GameObject.Instantiate(MaterialGenPrefab, new Vector3(0, 0, 0), Quaternion.identity); MaterialGenScript = MaterialGenInstance.GetComponent <MaterialGen>(); MaterialGenScript.InitTexture(material_Resolution, heightmap_PowerN, BiomeTuple, ColorTuple); // Model gen / master terrain ModelGenPrefab = (GameObject)Resources.Load("PipelinePrefabs/ModelGenPrefab"); GameObject MasterTerrainPrefab = (GameObject)Resources.Load("PipelinePrefabs/MasterTerrainPrefab"); MasterTerrainInstance = (GameObject)GameObject.Instantiate(MasterTerrainPrefab, new Vector3(0, 0, 0), Quaternion.identity); }
public void Init(int heightmapBaseN, int biomeDimensions, int biomeHMContentsWidth, int blockVertexWidth) { HeightmapDatabase = new Dictionary <Tuple <int, int>, float[, ]>(); BiomeDatabase = new Dictionary <Tuple <int, int>, Tuple <uint[, ], Tuple <int, int> > >(); HeightmapProcessed = new HashSet <Tuple <int, int> >(); BiomeProcessed = new HashSet <Tuple <int, int> >(); BiomeGenScript = GameObject.FindObjectOfType(typeof(BiomeGen)) as BiomeGen; BiomeDimensions = biomeDimensions; BiomeHMContentsWidth = biomeHMContentsWidth; BiomePartitionWidth = (int)Mathf.Pow(2, heightmapBaseN) + 1; ModelPlacerScript = GameObject.FindObjectOfType(typeof(ModelPlacer)) as ModelPlacer; BlockVertexWidth = blockVertexWidth; BiomeVertexWidth = BiomeHMContentsWidth * BlockVertexWidth; }
// Start is called before the first frame update private void Start() { Random.InitState(seed); textureWidth = Screen.height; textureHeight = Screen.height; biomeGen = new BiomeGen(); traitGen = new BoardTraitGen(); biomeActions = new BiomeActions(); newWallGen = new NewWallGeneration(); biomeGrown = false; heatmapGenerated = false; traitsMarked = false; ouWallsGenerated = false; inWallsGenerated = false; init(); }