﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameController : MonoBehaviour
{
    public GameObject Balls;
    public Vector2 ballValue;
    public int ballCount;
    public float ballWait;
    public float waveWait;

    private IEnumerator BallWaves()
    {
        while (true)
        {
            for (int i = 0; i < ballCount; ++i)
            {
                Vector2 spawnPosition = new Vector2(Random.Range(-ballValue.x, ballValue.x), ballValue.y);
                Quaternion spawnRotion = Quaternion.identity;
                Instantiate(Balls, spawnPosition, spawnRotion);
                yield return new WaitForSeconds(ballWait);
            }
            yield return new WaitForSeconds(waveWait);

        }
    }

    private void Start()
    {
        StartCoroutine(BallWaves());
    }
}
