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

public class vittusaatana : MonoBehaviour {
    public GameObject objectSpawn;
    public int amount = 0;
    public float seconds = 1.0f;
    public bool continuous = false;

    private float timeCounter = 0.0f;
    private float counter = 0;

    // Use this for initialization
    void Start() {

    }

    // Update is called once per frame
    void Update() {
        if (continuous)
        {
            if (counter >= amount)
            {
                counter = 0 ;
            }
            timeCounter += Time.deltaTime;
            if (timeCounter >= seconds && counter <= amount)
            {
                Instantiate(objectSpawn, this.transform.position, this.transform.rotation);
                counter++;
                timeCounter = 0;
            }
        }
        else {
            if (counter >= amount)
            {
                return;
            }
            timeCounter += Time.deltaTime;
            if (timeCounter >= seconds && counter <= amount)
            {
                Instantiate(objectSpawn, this.transform.position, this.transform.rotation);
                counter++;
                timeCounter = 0;
            }
        }
    }
}
