using UnityEngine;
using System.Collections;

public class AudioPlayer : MonoBehaviour {
	

	public AudioSource song;
	public AudioClip songClip;
	public AudioSource song1;
	public AudioClip songClip1;
	public AudioSource song2;
	public AudioClip songClip2;
	public AudioSource song3;
	public AudioClip songClip3;
	public AudioSource song4;
	public AudioClip songClip4;
	public AudioSource song5;
	public AudioClip songClip5;

	public float pitch;
	public float height;
	// Use this for initialization
	void Start () {
		song = gameObject.AddComponent<AudioSource>();
		song.clip = songClip;
		song.Play();
		song1 = gameObject.AddComponent<AudioSource>();
		song1.clip = songClip1;
		song1.Play();
		song2 = gameObject.AddComponent<AudioSource>();
		song2.clip = songClip2;
		song2.Play();
		song3 = gameObject.AddComponent<AudioSource>();
		song3.clip = songClip3;
		song3.Play();
		song4 = gameObject.AddComponent<AudioSource>();
		song4.clip = songClip4;
		song4.Play();
		song5 = gameObject.AddComponent<AudioSource>();
		song5.clip = songClip5;


		song.loop = true;
		song1.loop = true;
		song2.loop = true;
		song3.loop = true;
		song4.loop = true;
	
	}
	
	// Update is called once per frame
	void Update () {


		height = Mathf.Lerp(height,1-gameObject.GetComponent<HungryWolfes>().Hunger,0.1f);

		if(height<0.25){
			song.volume = (float)(1-height*4);
			song1.volume = (float)(height*4);
			song2.volume = 0;
			song3.volume = 0;
			song4.volume = 0;
		}else if(height<0.5){
			song.volume = 0;
			song1.volume = (float)(1-(height-0.25)*4);
			song2.volume = (float)(height-0.25)*4;
			song3.volume = 0;
			song4.volume = 0;

		}else if(height<0.75){
			song.volume = 0;
			song1.volume = 0;
			song2.volume = (float)(1-(height-0.5)*4);
			song3.volume = (float)(height-0.5)*4;
			song4.volume = 0;

		}else {
			song.volume = 0;
			song1.volume = 0;
			song2.volume = 0;
			song3.volume = (float)(1-(height-0.75)*4);
			song4.volume = (float)(height-0.75)*4;

		}


	}
}
