/// <summary>
        /// <para>Inicia la secuencia de la conversacion</para>
        /// </summary>
        /// <param name="data">Data de la conversacion</param>
        /// <returns></returns>
        public IEnumerator Secuencia(ConversacionData data)        // Inicia la secuencia de la conversacion
        {
            // Recorrer la secuencia de conversacion
            for (int n = 0; n < data.list.Count; n++)
            {
                // Obtener datos
                DialoguerData     sd          = data.list[n];
                PanelConversacion panelActual = (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.MiddleLeft || sd.anchor == TextAnchor.LowerLeft) ? panelIzquierda : panelDerecha;
                IEnumerator       actual      = panelActual.InitDialogo(sd);
                actual.MoveNext();
                string mostrar, ocultar;

                // Comprobar estado
                if (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.UpperCenter || sd.anchor == TextAnchor.UpperRight)
                {
                    mostrar = MostrarArriba;
                    ocultar = OcultarArriba;
                }
                else
                {
                    mostrar = MostrarAbajo;
                    ocultar = OcultarAbajo;
                }

                // Transicion
                panelActual.panel.SetPosicion(ocultar, false);
                MoverPanel(panelActual, mostrar);

                yield return(null);

                while (actual.MoveNext())
                {
                    yield return(null);
                }

                // Transicion
                MoverPanel(panelActual, ocultar);
                transicion.completedEvent += delegate(object sender, EventArgs e)
                {
                    conversacion.MoveNext();
                };

                yield return(null);
            }

            // Desactivar la conversacion
            canvas.gameObject.SetActive(false);

            // Mandar evento completado
            if (EventoCompletado != null)
            {
                EventoCompletado(this, EventArgs.Empty);
            }
        }
        /// <summary>
        /// <para>Iniciar dialogo</para>
        /// </summary>
        /// <param name="dialogo"></param>
        /// <returns></returns>
        public IEnumerator InitDialogo(DialoguerData dialogo)        // Iniciar dialogo
        {
            // Fijar imagen del personaje
            avatar.sprite = dialogo.personaje;
            avatar.SetNativeSize();

            // Iniciar texto
            for (int n = 0; n < dialogo.mensages.Count; n++)
            {
                texto.text = dialogo.mensages[n];
                flecha.SetActive(n + 1 < dialogo.mensages.Count);
                yield return(null);
            }
        }
        public DialoguerData getDialoguerData()
        {
            #region Global Variables
            List <bool>   globalBooleans = new List <bool>();
            List <float>  globalFloats   = new List <float>();
            List <string> globalStrings  = new List <string>();

            for (int i = 0; i < globals.booleans.variables.Count; i += 1)
            {
                bool parsedBoolean;
                bool success = bool.TryParse(globals.booleans.variables[i].variable, out parsedBoolean);
                if (!success)
                {
                    Debug.LogWarning("Global Boolean " + i + " did not parse correctly, defaulting to false");
                }
                globalBooleans.Add(parsedBoolean);
            }

            for (int i = 0; i < globals.floats.variables.Count; i += 1)
            {
                float parsedFloat;
                bool  success = float.TryParse(globals.floats.variables[i].variable, out parsedFloat);
                if (!success)
                {
                    Debug.LogWarning("Global Float " + i + " did not parse correctly, defaulting to 0");
                }
                globalFloats.Add(parsedFloat);
            }

            for (int i = 0; i < globals.strings.variables.Count; i += 1)
            {
                globalStrings.Add(globals.strings.variables[i].variable);
            }

            DialoguerGlobalVariables newGlobalVariables = new DialoguerGlobalVariables(globalBooleans, globalFloats, globalStrings);
            #endregion

            #region Dialogues
            List <DialoguerDialogue> newDialogues = new List <DialoguerDialogue>();

            // Loop through Dialogues
            for (int d = 0; d < this.dialogues.Count; d += 1)
            {
                DialogueEditorDialogueObject dialogue = dialogues[d];

                #region Dialogue Phases
                List <AbstractDialoguePhase> newPhases = new List <AbstractDialoguePhase>();
                // Loop through phases
                for (int p = 0; p < dialogue.phases.Count; p += 1)
                {
                    DialogueEditorPhaseObject phase = dialogue.phases[p];

                    switch (phase.type)
                    {
                    case DialogueEditorPhaseTypes.TextPhase:
                        newPhases.Add(new TextPhase(phase.text, phase.theme, phase.newWindow, phase.name, phase.portrait, phase.metadata, phase.audio, phase.audioDelay, phase.rect, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.BranchedTextPhase:
                        newPhases.Add(new BranchedTextPhase(phase.text, phase.choices, phase.theme, phase.newWindow, phase.name, phase.portrait, phase.metadata, phase.audio, phase.audioDelay, phase.rect, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.WaitPhase:
                        newPhases.Add(new WaitPhase(phase.waitType, phase.waitDuration, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.SetVariablePhase:
                        newPhases.Add(new SetVariablePhase(phase.variableScope, phase.variableType, phase.variableId, phase.variableSetEquation, phase.variableSetValue, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.ConditionalPhase:
                        newPhases.Add(new ConditionalPhase(phase.variableScope, phase.variableType, phase.variableId, phase.variableGetEquation, phase.variableGetValue, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.CustomConditionalPhase:
                        newPhases.Add(new CustomConditionPhase(phase.messageName, phase.metadata, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.SendMessagePhase:
                        newPhases.Add(new SendMessagePhase(phase.messageName, phase.metadata, phase.outs));
                        break;

                    case DialogueEditorPhaseTypes.EndPhase:
                        newPhases.Add(new EndPhase());
                        break;

                    default:
                        newPhases.Add(new EmptyPhase());
                        break;
                    }
                }
                #endregion

                #region Dialogue Variables
                //Booleans
                List <bool> localBooleans = new List <bool>();
                for (int i = 0; i < dialogue.booleans.variables.Count; i += 1)
                {
                    bool newBoolean;
                    bool success = bool.TryParse(dialogue.booleans.variables[i].variable, out newBoolean);
                    if (!success)
                    {
                        Debug.Log("Dialogue " + d + ": Boolean " + i + " not formatted correctly. Defaulting to false");
                    }
                    localBooleans.Add(newBoolean);
                }

                //Floats
                List <float> localFloats = new List <float>();
                for (int i = 0; i < dialogue.floats.variables.Count; i += 1)
                {
                    float newFloat;
                    bool  success = float.TryParse(dialogue.floats.variables[i].variable, out newFloat);
                    if (!success)
                    {
                        Debug.Log("Dialogue " + d + ": Float " + i + " not formatted correctly. Defaulting to 0");
                    }
                    localFloats.Add(newFloat);
                }

                //Strings
                List <string> localStrings = new List <string>();
                for (int i = 0; i < dialogue.strings.variables.Count; i += 1)
                {
                    localStrings.Add(dialogue.strings.variables[i].variable);
                }

                DialoguerVariables localVariables = new DialoguerVariables(localBooleans, localFloats, localStrings);
                #endregion

                DialoguerDialogue newDialogue = new DialoguerDialogue(dialogue.name, dialogue.startPage.Value, localVariables, newPhases);
                //Debug.Log(newDialogue.ToString());
                newDialogues.Add(newDialogue);
            }
            #endregion

            #region Themes
            List <DialoguerTheme> newThemes = new List <DialoguerTheme>();
            for (int i = 0; i < themes.themes.Count; i += 1)
            {
                newThemes.Add(new DialoguerTheme(themes.themes[i].name, themes.themes[i].linkage));
            }
            #endregion

            DialoguerData newData = new DialoguerData(newGlobalVariables, newDialogues, newThemes);
            return(newData);
        }