using UnityEngine;
using UnityEngine.UI;

public class SleepingOwnerScript : ReactOnNoise
{
	public Slider noiseSlider;
	
	private int delay = 0;
	
	private bool awoken = false;
	
	public override void tooMuchNoise()
	{
		if(!awoken)
		{
			Debug.Log("I'm awake!!");
			if(delay == 0)
				Application.LoadLevel(4);
			awoken = true;
		}
	}
	
	void Start()
	{
		noiseSlider.maxValue = tolerance;
	}
	
	void Update()
	{
		if(awoken)
			noiseSlider.value = tolerance;
		else
			noiseSlider.value = noise;
		
		if(awoken)
		{
			delay--;
			if(delay <= 0)
				Application.LoadLevel(4);
		}
	}
	
	public void SetDelay(int d)
	{
		delay = d;
	}
}