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

public class RayoManager : MonoBehaviour {

	// prefabs that are going to be instantiated, each one has a different animation
	public GameObject[] raysPrefabs;

	// this array contains the instantiated rays in the scene so we can keep it under control
//	public GameObject[] instantiatedRays;

	public bool awaken;

	public float timerForLevel;

	void Awake(){
		awaken = true;
	}

	void Update () {
		
		if (awaken) {
			CreateWave ();
			awaken = false;
		}
	}

	public void CreateWave(){
		int attacktype = SelectAttack ();
		if (raysPrefabs [attacktype] != null) {
			Instantiate (raysPrefabs [attacktype], transform);
			TheAudioManager.instance.PlayElectricity ();
		}
//		instantiatedRays[i] = Instantiate (raysPrefabs [attacktype]) as GameObject;
	}

	// This function selects the kind of attack randomly (based on the different animation in the prefabs array)
	public int SelectAttack(){
		int attackVariety = raysPrefabs.Length;
		return(Random.Range (0, attackVariety));
	}
}
