using UnityEngine;
using System.Collections;

public class MusicController : MonoBehaviour
{
    public AudioSource[] musicASs;

	public static MusicController instance;

	void Awake(){
		instance = this;
	}

    virtual protected void Start()
    {
		PlayMurmur ();
    }

	virtual protected void PlayTrack(int index)
	{
		int otherIndex = index + 1;
		if (otherIndex == 2)
			otherIndex = 0;

		if (index == 0)
			musicASs [index].time = Random.value * musicASs [index].clip.length;
		else
			musicASs [index].time = 4.5f;

		musicASs [otherIndex].Stop ();
		musicASs[index].Play();
    }


    virtual public void Mute()
    {
		foreach(var ass in musicASs)
			ass.mute = true;
    }
    virtual public void Unmute()
	{
		foreach(var ass in musicASs)
			ass.mute = false;
    }

	public void PlayTribal(){
		PlayTrack (1);
	}
	public void PlayMurmur(){
		PlayTrack (0);
	}
}
