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

public class text_logic : MonoBehaviour {

	// Use this for initialization
	
	private global_variables variable_script;
	
	private GameObject gameManager;



	private string[]Dialogue = {
		"Chosen One: Foul beast! I shall vanquish you with my mighty power!",
		"Sidekick: I'm here! I can help now! I'm not too late, am I?",
		"Chosen One: Kind of in the middle of something here.",
		"Sidekick: Oh dear...",
		"Slime King: Scrub.",
		"Sidekick: Well, what the hell do I do now?...",
	};



	bool Invoking=false;

	// Use this for initialization
	void Start () {
		gameManager = GameObject.FindGameObjectWithTag ("GameController").gameObject;
		variable_script = gameManager.GetComponent<global_variables> ();
		variable_script.dialoguePosition = 0;
	}
	
	// Update is called once per frame
	void Update () {

		if (variable_script.InCutscene == true&&!Invoking) {
			Invoking=true;
			InvokeRepeating ("updateText",0,3f);
				}
	}

	void updateText(){

		this.GetComponent<Text> ().text = Dialogue[variable_script.dialoguePosition];
			variable_script.dialoguePosition++;
		 }
}
