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

public class FadeAudio : MonoBehaviour {

	private Reactor reactor;

	// Use this for initialization
	void Start ()
	{
		reactor = FindObjectOfType<Reactor> ();
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (reactor.meltdown == true)
		{

			AudioSource[] audioSources = FindObjectsOfType<AudioSource> ();

			foreach (var item in audioSources)
			{
				if (item.gameObject.name != "meltdown beep")
					item.volume -= Time.deltaTime * 0.5f;

				else if(item.gameObject.name == "meltdown beep")
					item.volume += Time.deltaTime * 0.4f;
				
			}


		}
	}
}
