/// <summary>
 /// Define the dialog this interpreter will interpret when you will use the <see cref="InterpretNextNode"/>
 /// function. It then loads the dialog in order to be able to read it.
 /// </summary>
 /// <param name="dialog"></param>
 public void SetWireDialog(WireDialog dialog)
 {
     Dialog = dialog;
     Dialog.Load();
     atBeginning = true;
     EndOfDialog = false;
 }
Esempio n. 2
0
        public void LoadDialog(WireDialog dialog)
        {
            Debug.Log("Loading a new dialog...");

            try
            {
                GraphEditor.NodeDisplayers.Clear(); // Clear the displayer UI
            }
            catch (Exception)
            {
                Debug.Log("An error occurred. Please reload the Dialog Editor. If this bug always happens, please contact me.");
                Close();
            }

            if (!dialog.Initialized)
            {
                EditingDialog = dialog; // Needed to create the displayer
                DialogBeginningNodeDisplayer beginningDisplayer = DialogBeginningNodeDisplayer.CreateDialogBeginningDisplayer(new Vector2(100, 150));
                DialogBeginningWireNode      beginningNode      = beginningDisplayer.GetRenderedNodeAs <DialogBeginningWireNode>();
                dialog.Initialize(ref beginningNode);
            }

            dialog.Load();
            EditingDialog = dialog; // Set the new dialog to edit

            foreach (WireNode node in dialog.NodesDictionary.Values)
            {
                if (node is EqualityWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as EqualityWireNode).CreateDisplayer());
                }
                else if (node is GreaterWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as GreaterWireNode).CreateDisplayer());
                }
                else if (node is InequalityWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as InequalityWireNode).CreateDisplayer());
                }
                else if (node is LesserWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as LesserWireNode).CreateDisplayer());
                }
                else if (node is ConstantWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as ConstantWireNode).CreateDisplayer());
                }
                else if (node is SayReplyWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as SayReplyWireNode).CreateDisplayer());
                }
                else if (node is BranchWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as BranchWireNode).CreateDisplayer());
                }
                else if (node is SetAnimatorVariableWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as SetAnimatorVariableWireNode).CreateDisplayer());
                }
                else if (node is GetAnimatorVariableWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as GetAnimatorVariableWireNode).CreateDisplayer());
                }
                else if (node is ChooseReplyWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as ChooseReplyWireNode).CreateDisplayer());
                }
                else if (node is ReunionWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as ReunionWireNode).CreateDisplayer());
                }
                else if (node is GetVariableWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as GetVariableWireNode).CreateDisplayer());
                }
                else if (node is SetVariableValWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as SetVariableValWireNode).CreateDisplayer());
                }
                else if (node is DialogBeginningWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as DialogBeginningWireNode).CreateDisplayer());
                }
                else if (node is TriggerScriptWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as TriggerScriptWireNode).CreateDisplayer());
                }
                else if (node is SetTriggerParamValueWireNode)
                {
                    GraphEditor.NodeDisplayers.Add((node as SetTriggerParamValueWireNode).CreateDisplayer());
                }
            }
            Debug.Log("Loaded");
        }