Example #1
0
    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;
    }