using UnityEngine;
using System.Collections;

public class AudioHandler : MonoBehaviour {


	public AudioClip[] Clips;
	private static AudioSource[] audioSources;


	// Use this for initialization
	void Start () {
		

	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void Awake()

	{
		audioSources = new AudioSource[Clips.Length];

		int i = 0;

		while (i < Clips.Length)

		{

			GameObject child = new GameObject("SoundPlayer");

			child.transform.parent = gameObject.transform;

			audioSources [i] = child.AddComponent<AudioSource> ();

			audioSources[i].clip = Clips[i];

			i++;

		}

	}

	public static void playSound(int i)
	{
		audioSources[i].Play();

	}
	public static void playSoundRandom(int i,int J)
	{
		audioSources[Random.Range(i, J)].Play();

	}
}
