using UnityEngine;
using System.Collections;
using UnityStandardAssets.ImageEffects;


public class WallsManager : MonoBehaviour {
	public float WallsHeight;
	static public float AllWallsHeight;
	public bool heaven;
	static public bool allHeaven = true;

	public Bloom blum;
	void Start()
	{
		allHeaven = heaven;
	}

	void Update () {
		if (heaven != allHeaven) {
			AudioSource snd = GetComponent<AudioSource> ();
			snd.Play ();
		}
		heaven = allHeaven;
		if (heaven == true) {
			WallsHeight = WallsHeight - 0.005f;
		} else {
			WallsHeight = WallsHeight + 0.005f;
		}
		if (WallsHeight > .5f) {
			WallsHeight = .5f;
		}
		if (WallsHeight < -.5f) {
			WallsHeight = -.5f;
		}
		if (heaven == false) {
			if (WallsHeight >= -0.1f && WallsHeight <= 0.1f) {
				blum.bloomIntensity = 1.71f;
				blum.bloomThreshold = 0.64f;
			} else {
				blum.bloomIntensity = 1.1f;
				blum.bloomThreshold = 0.84f;
			}
		}
		AllWallsHeight = WallsHeight;
	}
}
