using UnityEngine;
using System.Collections;

public class FlashScript : MonoBehaviour {
	
	public int level;
	public bool whiteout = false;
	public bool playerwon = false;

	public void BeginFlash () {
		renderer.material.color = new Color(1F,1F,1F,1F);
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		if (whiteout) {
			if (renderer.material.color.a < 1F) {
				renderer.material.color = new Color(1F,1F,1F,renderer.material.color.a + 0.005F);
				if (renderer.material.color.a >= 1F) {
					if (playerwon) {
						switch(level) {
						case 1:
							Application.LoadLevel ("level2");
							break;
						case 2:
							Application.LoadLevel ("title");
							break;
						}
					} else {
						Application.LoadLevel ("title");
					}
				}
			}
		} else {
			if (renderer.material.color.a > 0) {
				renderer.material.color = new Color(1F,1F,1F,renderer.material.color.a - 0.02F);
			}
		}
	}
}
