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

public class WaveSpawner : MonoBehaviour {


    public int Direction;
    public List<GameObject> spawnPoints;
    public float SpawnRate;
    public float SpawnDiviation;

    public Quaternion directionAngle;
    


    float spawnTimer;
    float diviation;
    public GameObject spawnObj;


    public float hazardLevel;
	// Use this for initialization
	void Start () {
        diviation = Random.Range(0, SpawnDiviation);
        spawnTimer = 500;
    }
	
	// Update is called once per frame
	void Update () {
        spawnTimer += Time.deltaTime;

        if (spawnTimer > SpawnRate + diviation) {
            spawnTimer = 0.0f;
            diviation = Random.Range(0.0f, SpawnDiviation);

            Vector3 spawnposition = spawnPoints[Random.Range(0, spawnPoints.Count)].transform.position;

            GameObject newCat = Instantiate(spawnObj, spawnposition, directionAngle);
            //newCat.GetComponent<CatBasicAIBehaviour>().currentState = AIState.moveing;
            SpawnRate -= hazardLevel;
        }


    }
}
