public void BuildPlates() { this.Plates = new TectonicPlate[this.PlateCount]; this.HexplanetTiles = new Dictionary <int, Tile>(); List <Tile> tiles = this.HexPlanet.GetTiles(); for (int i = 0; i < this.Plates.Length; i++) { int randomIndex = Random.Range(0, tiles.Count); Tile randomTile = tiles[randomIndex]; GameObject go = new GameObject("Plate" + i); go.transform.position = randomTile.center; go.transform.rotation = randomTile.transform.rotation; go.transform.SetParent(this.HexPlanet.transform); this.Plates[i] = go.AddComponent <TectonicPlate>(); bool isWater = TerrainGenerator.EvalPercentChance(this.ChanceOfWaterPlate); float extrusion = isWater ? (this.SeaLevel / 2.0f) : Random.Range(this.GetMinLandExtude(), this.MaxPlateExtrusion); TerrainElevation elevation = this.GetElevation(extrusion); Color color = (elevation != null) ? elevation.TerrainColor : Color.black; this.Plates[i].PlateSetup(this.HexPlanet, tiles[randomIndex], isWater, extrusion * this.ExtrusionMultiplier, color, this.HexplanetTiles); } int maxLoop = 100; for (int i = 0; i < maxLoop; i++) { bool addedAny = false; for (int j = 0; j < this.Plates.Length; j++) { bool added = this.Plates[j].Fill(this.HexplanetTiles, this.ChanceOfFillRequeue); if (added) { addedAny = true; } } if (!addedAny) { Debug.Log("Stopped adding at i=" + i); break; } } for (int j = 0; j < this.Plates.Length; j++) { this.Plates[j].SetupTileInfo(); } Debug.Log("Stopped HexplanetUsedTiles " + this.HexplanetTiles.Count + " / " + tiles.Count); }
public void AdjustTerrainHeights() { for (int i = 0; i < this.Plates.Length; i++) { TectonicPlate plate = this.Plates[i]; float extrusion = plate.extrusion; bool isWater = plate.isWater; for (int j = 0; j < plate.PressureEdgeTiles.Count; j++) { Tile tile = plate.PressureEdgeTiles[j]; float tileExtrusion = extrusion; for (int k = 0; k < tile.neighborTiles.Count; k++) { Tile otherTile = tile.neighborTiles[k]; TectonicPlate otherPlate = TectonicPlate.GetTilePlate(otherTile); if ((otherTile != null) && (otherPlate != null)) { bool isOtherWater = otherPlate.isWater; bool isOtherPressureTile = otherPlate.IsPressureEdgeTile(otherTile); float otherExtrusion = otherPlate.extrusion; if (isWater) { if (isOtherWater) { if (isOtherPressureTile) { float chanceOfOceanFaultIsland = 0.2f; if (TerrainGenerator.EvalPercentChance(chanceOfOceanFaultIsland)) { tileExtrusion = this.GetMinLandExtude(); //Mathf.Max(this.SeaLevel + tileExtrusion, this.GetMinLandExtude()); } } } else { } } else { } } } this.ExtrudeTile(tileExtrusion, tile); } if (isWater) { for (int j = 0; j < plate.EdgeTiles.Count; j++) { Tile edgeTile = plate.EdgeTiles[j]; if (plate.IsShorelineTile(edgeTile, this.SeaLevel)) { this.ExtrudeTile(this.GetMaxWaterExtude(), edgeTile, plate); } } } } }