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

public class ObjectiveText : MonoBehaviour {
	
	public Text objectiveText;
	public Canvas textCanvas;
	public string[] objectives = new string[7]; 
	
	void Awake()
	{
		DontDestroyOnLoad (transform.gameObject);
		DontDestroyOnLoad (textCanvas.transform.gameObject);
		Reset ();
		SetObjectiveText ();	
	}
	
	void Reset()
	{
		PlayerPrefs.SetInt ("Essays on Cosmicism", 0);
		PlayerPrefs.SetInt ("Horror at Red Rook", 0);
		PlayerPrefs.SetInt ("Paranormal Genetics", 0);
		PlayerPrefs.SetInt ("The Price of Sanity", 0);
		PlayerPrefs.SetInt ("August Derleth on Cthulu", 0);
		PlayerPrefs.SetInt ("Anthropocentrism", 0);
		PlayerPrefs.SetInt ("The Necronomicon", 0);
		PlayerPrefs.SetInt ("Speed", 15);
		PlayerPrefs.SetInt ("SanityLevel", 50);
		PlayerPrefs.SetInt ("Score", 0);
		PlayerPrefs.SetInt ("Multiplier", 1);
	}
	
	void Update()
	{
		SetObjectiveText ();
	}
	
	void SetObjectiveCollected(string currentObjective)
	{
		PlayerPrefs.SetInt (currentObjective, 1);
	}
	
	int GetObjectiveCollected(string currentObjective)
	{
		return PlayerPrefs.GetInt (currentObjective);
	}
	
	void SetObjectiveText()
	{
		objectiveText.text = "";
		for(int i = 0; i < 7; i++)
		{
			if(GetObjectiveCollected(objectives[i]) == 0)
			{
				objectiveText.text = objectiveText.text + objectives[i] + " ";
			}
		}
		
	}
}
