| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.Tilemaps; |
| | | |
| | |
| | | Tilemap tilemap; |
| | | public RuleTile ruleTile; |
| | | //public List<TileBase> tiles; |
| | | // Start is called before the first frame update |
| | | void Start() |
| | | |
| | | private void Awake() |
| | | { |
| | | tilemap = GetComponent<Tilemap>(); |
| | | GenerateTiles(); |
| | | } |
| | | |
| | | |
| | | public void GenerateTiles() |
| | | public IEnumerator GenerateTiles(Action finishedCallback) |
| | | { |
| | | for (int x = 0; x < width; x++) |
| | | { |
| | |
| | | |
| | | if (perlinNoise >= 0.3f) |
| | | { |
| | | if (!tilemap.HasTile(new Vector3Int(x,y+1))) { |
| | | tilemap.SetTile(new Vector3Int(x, y), ruleTile); |
| | | } |
| | | else |
| | | { |
| | | tilemap.SetTile(new Vector3Int(x, y), ruleTile); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // Update UI every 8 lines |
| | | if ((x % 8) == 0) |
| | | { |
| | | yield return null; |
| | | } |
| | | } |
| | | finishedCallback(); |
| | | } |
| | | } |