using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class timer : MonoBehaviour {

	// Use this for initialization
	public int score= 10000;
	public float tiempo = 3f;
	public int SceneChange = 2;
	public int actual = 0;

	void Start () {
		actual = SceneManager.GetActiveScene().buildIndex;
		//PlayerPrefs.SetInt ("Level2", 1);
		PlayerPrefs.SetInt ("Level"+(SceneChange-1).ToString()+"_stars",numstars(score));
		StartCoroutine (Time ());
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	IEnumerator Time(){
		yield return new WaitForSeconds (tiempo);
		//LevelMenu
		SceneManager.LoadScene(2);
		//Application.LoadLevel(1);
	}
	int numstars(int score){
		if (score > 0 && score < 9999) {
			PlayerPrefs.SetInt ("Level"+SceneChange.ToString(), 1);
			return 1;
		}
		
		if (score >= 10000 && score < 20000) {
			PlayerPrefs.SetInt ("Level"+SceneChange.ToString(), 1);
			return 2;
		}

		if (score >= 20000) {
			PlayerPrefs.SetInt ("Level"+SceneChange.ToString(), 1);
			return 3;
		}
		return 0;
	}
}
