private void GenerateChunks(int offX, int offY) { _perlinGenerator.RandomIsland(offX, offY); offX += 4; offY += 4; _player.transform.position = new Vector3(offX * ChunkSize + ChunkSize + ChunkSize / 2, offY * ChunkSize + ChunkSize + ChunkSize / 2); var mover = _player.GetComponent <ChunkMover>(); mover.ChunkOffsets = new Vec2(offX + 1, offY + 1); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { GenerateChunk(x, y, offX + x, offY + y); } } _perlinGenerator.PlaceBase(_chunks[1, 1]); // base vasta kun on generoitu tiilet SpriteController.transform.position = GetTileGameObject(0, 0).transform.position; SpriteController.SetTileSprites(TotalWidth - 2, TotalHeight - 2, this, 1, 1); running = true; }
public override void OnInspectorGUI() { Perlin myPerlin = (Perlin)target; TileMap myTileMap = (TileMap)myPerlin.GetComponent <TileMap>(); if (GUILayout.Button("Generate island")) { myPerlin.RandomIsland(Random.Range(0, 1500), Random.Range(0, 1500)); myPerlin.InitalizeRenderTarget(); } if (DrawDefaultInspector()) { // arvoja muutettu myPerlin.InitalizeRenderTarget(); if (_update) { myPerlin.GenerateTileMap(myTileMap); } } if (GUILayout.Button("Generate")) { myPerlin.InitalizeRenderTarget(); } else if (GUILayout.Button("Generate ITileMap") && myTileMap != null) { myPerlin.GenerateTileMap(myTileMap); } else if (GUILayout.Button("toggle update")) { _update = !_update; } else if (GUILayout.Button("Generate Big Map!")) { //myPerlin.GenerateWorldTextureMap(myPerlin.BigMapWidth, myPerlin.BigMapWidth, 0f, -2f); } }