public override IEnumerable <TileCaseStruct> Generate(int seed) { //Setting seed Random.InitState(seed); // Building Final tileset float totalDistribution = 0; List <TileDistribStruct> finalSet = new List <TileDistribStruct>(); TileDistribStruct[][] tmpSets = GetInputValues <TileDistribStruct[]>("allTileset", null); if (tmpSets != null) { // Does it keep same order ? foreach (TileDistribStruct[] set in tmpSets) { foreach (TileDistribStruct t in set) { finalSet.Add(t); totalDistribution += t.distrib; } } } else { Debug.LogWarning("Missing Entry node DistributedTileset"); yield break; } int size = finalSet.Count; TileCaseStruct tcs; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { tcs = new TileCaseStruct(); tcs.position = new Vector3Int(j, i, 0); tcs.tile = GetDistributedTile(Random.Range(0f, totalDistribution), finalSet); yield return(tcs); } } }
public override IEnumerable <TileCaseStruct> Generate(int seed) { List <Tile> finalSet = new List <Tile>(); Tile[][] tmpSets = GetInputValues <Tile[]>("allTileset", null); if (tmpSets != null) { foreach (Tile[] set in tmpSets) { foreach (Tile t in set) { finalSet.Add(t); } } } else { Debug.LogWarning("Missing Entry node Tileset"); yield break; } Random.InitState(seed); int size = finalSet.Count; TileCaseStruct tcs; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { tcs = new TileCaseStruct(); tcs.position = new Vector3Int(j, i, 0); tcs.tile = finalSet[Random.Range(0, size)]; yield return(tcs); } } }
public override IEnumerable <TileCaseStruct> Generate(int seed) { //Setting seed Random.InitState(seed); // Checking and init noise NoiseNode noise = GetInputValue("noiseNode", noiseNode); if (noise != null) { noise.SetUpNoise(seed); } else { Debug.LogWarning("Missing Entry node Noise"); yield break; } // Building Final tileset List <TileRangeStruct> finalSet = new List <TileRangeStruct>(); TileRangeStruct[][] tmpSets = GetInputValues <TileRangeStruct[]>("allTileset", null); if (tmpSets != null) { foreach (TileRangeStruct[] set in tmpSets) { foreach (TileRangeStruct t in set) { finalSet.Add(t); } } } else { Debug.LogWarning("Missing Entry node RangeTileset"); yield break; } float [,] noiseSample = new float[width, height]; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { noiseSample[j, i] = noise.GetNoiseAt(j, i, width, height); } } NormalizeArray(noiseSample); int size = finalSet.Count; TileCaseStruct tcs; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { tcs = new TileCaseStruct(); tcs.position = new Vector3Int(j, i, 0); tcs.tile = CheckInsideRange(noiseSample[j, i], finalSet); yield return(tcs); } } }