using UnityEngine;
using System.Collections;

public class Goal : MonoBehaviour {

	bool levelWon = false;
	bool didGoOn = false;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		if(Input.GetKeyDown(KeyCode.B)){
			levelWon = true;
		}

		if(gameObject.GetComponent<FadeToTrans>().beingObserved >= 2){
			levelWon = true;
		}
		if(levelWon && !didGoOn)
		{
			didGoOn = true;
			Debug.Log("LEVEL WAS WON!");
			GameObject.Find("Splash").GetComponent<SplashScreen>().GoToNextLevel();
		}
	}
}
