Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProceduralTerrainGenerator : MonoBehaviour
- {
- public bool regenerateMap = true;
- public Hextile[] hexTiles;
- void Update()
- {
- CreateMap();
- }
- private void CreateMap()
- {
- // Some code for Perlin Noise generation inside perlinMap[,]
- for (int i = 0; i < mapLength; i++)
- {
- for (int j = 0; j < mapHeight; j++)
- {
- // Setting up position from i and j index
- foreach (HexTile hexTile in hexTiles)
- {
- if (ValueInRange(perlinMap[i,j], hexTile.LowLimit, hexTile.HighLimit)
- {
- Instantiate<HexTile>(hexTile.tile, position, Quaternion.Euler(0f, 0f, 0f), this.transform);
- }
- }
- }
- }
- }
- }
- [System.Serializable]
- public class HexTile
- {
- public GameObject tile;
- public HexMetrics.HexType hexType;
- public float perlinNoiseLowLimit;
- public float perlinNoiseHighLimit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement