Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public class ProceduralTerrainGenerator : MonoBehaviour
  2. {
  3. public bool regenerateMap = true;
  4.  
  5. public Hextile[] hexTiles;
  6.  
  7. void Update()
  8. {
  9. CreateMap();
  10. }
  11.  
  12. private void CreateMap()
  13. {
  14. // Some code for Perlin Noise generation inside perlinMap[,]
  15. for (int i = 0; i < mapLength; i++)
  16. {
  17. for (int j = 0; j < mapHeight; j++)
  18. {
  19. // Setting up position from i and j index
  20. foreach (HexTile hexTile in hexTiles)
  21. {
  22. if (ValueInRange(perlinMap[i,j], hexTile.LowLimit, hexTile.HighLimit)
  23. {
  24. Instantiate<HexTile>(hexTile.tile, position, Quaternion.Euler(0f, 0f, 0f), this.transform);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31.  
  32. [System.Serializable]
  33. public class HexTile
  34. {
  35. public GameObject tile;
  36. public HexMetrics.HexType hexType;
  37. public float perlinNoiseLowLimit;
  38. public float perlinNoiseHighLimit;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement