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

using UnityEngine;

public class Trigger : MonoBehaviour {

	public AudioSource audi;
	public bool End;
	public float timer;

	void Start()
	{
		audi = this.GetComponent<AudioSource>();
	}
	void Update()
	{
		if(End)
		{
			timer += Time.deltaTime;
			if(timer >= 10)
			{
				SceneManager.LoadScene(0);

			}
		}
	}
	void OnTriggerEnter(Collider other)
	{
		if(other.gameObject.tag == "Player")
		{
			End = true;
			audi.Play();
		}
	}

	void OnGUI()
	{
		float scrw = Screen.width/16;
		float scrh = Screen.height/9;
		if(End)
		{
			GUI.Box(new Rect(scrw*6,scrh*1.75f,scrw*4,scrh*2),"You Found The Scroll");
			if(GUI.Button(new Rect(scrw*6,scrh*3.75f,scrw*2,scrh*1),"Restart"))
			{
				SceneManager.LoadScene(1);
			}
			if(GUI.Button(new Rect(scrw*8,scrh*3.75f,scrw*2,scrh*1),"End"))
			{
				SceneManager.LoadScene(0);
				
			}
		}

	}
}
