using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DialogueManager : MonoBehaviour {

	#region variables
	private DialogueController[] _dialogues;

	private int _sequence = 0;
	#endregion


	#region events
	void Awake () {

		_dialogues = transform.GetComponentsInChildren <DialogueController> ();
		
		foreach (DialogueController d in _dialogues) {
			d.enabled = false;
		}

		Play ();
		
	}
	#endregion


	#region methods
	public void Play () {

		if (_sequence > 0)
			_dialogues[_sequence - 1].enabled = false;

		if (_sequence >= _dialogues.Length) return;
		
		_dialogues[_sequence].enabled = true;
		_dialogues[_sequence].SetManager (this);

		_sequence++;

	}

    public void PlaySequence(DialoguerDialogues dialogue)
    {
        if((int) dialogue > _dialogues.Length)
        {
            _dialogues[(int)dialogue].enabled = true;
            _dialogues[(int)dialogue].SetManager(this);
        }
    }
	#endregion


	#region actions
	public Action NextEvent;
	#endregion

}
