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

public class Quoter : MonoBehaviour {

	private string[] quotes;
	public bool finished = false;
	Text text;
	public int count;
	int numResource; // MAGIC NUM of how many resources;

	// Use this for initialization
	void Start () {
		print ("finished = " + finished);
		//finished = false;
		count = 0;
		text = GetComponent <Text> ();
		numResource = GameObject.Find("Resources").transform.childCount;
		print("num children: " + numResource);

		quotes = new string[] {"\"If we’re honest, most of us would accept that a bad boss is a little bit like a bad father or a bad husband\"",
			"Climate change is absolute crap.\"",
			"\"If you want to put a price on carbon why not just do it with a simple tax.\"",
			"\"And it seems that notwithstanding the dramatic increases in man made CO2 emissions over the last decade, the world’s warming has stopped.\"",
			"\"I am confident, based on the science we have, that mankind does make a difference to climate, almost certainly the impact of humans on the planet extends to climate\"",
			"\"Coal is good for humanity, coal is good for prosperity, coal is an essential part of our economic future, here in Australia, and right around the world.\"",
			"\"Coal is essential for the prosperity of the world.\"",
			"\"Energy is what sustains our prosperity, and coal is the world's  principal energy source and it will be for many decades to come.\"",
			"\"I also think that if you want to put a price on carbon, why not just do it with a simple tax?\"",
			"\"This Emissions Trading Scheme is almost impossible to understand. It involves some enormous offsets.\""
		};
	}

	public bool Finished()
	{
		if (finished){
			return true;
		} else {
			return false;
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (numResource == 0)
		{
			text.text = "...what do we do now?";
			finished = true;
		}
		/*print("count is: " + count);
		if ((GameObject.Find("ScoreGUIText").GetComponent <Scorer>().score) > 0 )
		{
			text.text = quotes[count];
			if (count < quotes.Length)
			{
				count++;
			}
		}*/
	}

	public void ShouldUpdateQuote(){ 

		numResource--;
		count++;

		if (numResource < 0)
		{
			text.text = "What do we do now?";
			finished = true;
		}
		else {

			/* random quoting */
			int randomCount = Random.Range (0,quotes.Length);
			text.text = quotes[randomCount];

			//text.text = quotes[count]; //sequential quoting
		}
		if (count < quotes.Length)
		{
			count++;
		}

		/*
		if ((GameObject.Find("ScoreGUIText").GetComponent <Scorer>().score) > 0 ){
		}
		*/
	}
}
