using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;

public class Day : MonoBehaviour {

	public Image i;
	public Text t;
	public string nextScene;

	Timer wait;

	void Start () {
		wait = new Timer(2);
	}
	
	// Update is called once per frame
	void Update () {
		if (wait.Check()) {
			FadeOut();
		}
	}

	void FadeOut() {
		Color temp = i.color;
		temp.a = Mathf.Lerp(i.color.a, 0, Time.deltaTime * 1);
		i.color = temp;
		Color tTemp = t.color;
		temp.a = Mathf.Lerp(t.color.a, 0, Time.deltaTime * 1);
		t.color = temp;
	}

	void FadeIn() {
		Color temp = i.color;
		temp.a = Mathf.Lerp(i.color.a, 1.0f, Time.deltaTime * 1);
		i.color = temp;
		if (i.color.a > .9f) {
			LoadScene("Day1");
		}
	}

	public void LoadScene(string s) {
		SceneManager.LoadScene(nextScene);
	}
}
