using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;


public class rectangleroomgen : MonoBehaviour
{
    public RuleTile Rule;
    public Tilemap map;
    public TileBase empty;
    public GameObject player;
    public GameObject Camera;
    public Vector2Int size;
    public float wait;
    public GameObject frog;
    void Start()
    {
        System.Random ran = new System.Random();
        size = new Vector2Int(ran.Next(25, 50), ran.Next(10, 25));
        for (int x = 0; x < size.x+22; x++)
        {
            for (int y = 0; y < size.y+22; y++)
            {
                map.SetTile(new Vector3Int(x, y, 0), Rule);
            }
        }
        for (int x = 11; x < size.x+11; x++)
        {
            for (int y = 11; y < size.y+11; y++)
            {
                map.SetTile(new Vector3Int(x, y, 0), empty);
            }
        }
        player.transform.position = new Vector3((size.x)*8, (size.y)*8+11, 0);
        Camera.transform.position = new Vector3((size.x)*8, (size.y)*8, -10);
    }
    void Update()
    {
        wait -= Time.deltaTime;
        if(wait <= 0)
        {
            GameObject.Instantiate(frog, new Vector3(Random.Range(0, 12*8+size.x*8), 15*8, 0), new Quaternion());
            wait = Random.Range(1, 10);
        }
    }
}
