Exemplo n.º 1
0
        public ICanExecuteDialogFlow GetNext(DialogFlowData data)
        {
            // A different output is picked based on what they choose
            var port = GetPort($"onOption{selected}");

            return(port.ConnectedPorts.FirstOrDefault()?.Node as ICanExecuteDialogFlow);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Coroutine to start the conversation
        /// </summary>
        public IEnumerator Execute(DialogUI ui)
        {
            var data = new DialogFlowData
            {
                ui = ui
            };

            var current = GetNode <StartDialog>() as ICanExecuteDialogFlow;

            while (current != null)
            {
                // Check for a breakpoint on the node
                if (current is ICanBreak breakable)
                {
                    if (breakable.HasBreakpoint)
                    {
                        breakable.IsBreakpointPaused = true;
                        breakable.OnBreakpointPause();

                        Debug.LogError("Paused on breakpoint. Right click the paused node to continue.", this);
                        yield return(new WaitUntil(() => !breakable.IsBreakpointPaused));

                        breakable.OnBreakpointContinue();
                    }
                }

                yield return(current.Execute(data));

                current = current.GetNext(data);
            }

            yield return(null);
        }
Exemplo n.º 3
0
        public IEnumerator Execute(DialogFlowData data)
        {
            string[] textConsts    = new string[] { option0, option1, option2 };
            bool[]   enabledConsts = new bool[] { enableOption0, enableOption1, enableOption2 };

            var mapping = new Dictionary <Button, int>(); // Button -> Option index
            int index   = 0;

            // Display a button for each enabled option
            for (int i = 0; i < 3; i++)
            {
                var text    = GetInputValue($"option{i}", textConsts[i]);
                var enabled = GetInputValue($"enableOption{i}", enabledConsts[i]);

                if (text.Length > 0 && enabled)
                {
                    var button = data.ui.ShowChoice(index, text);
                    mapping[button] = i;
                    index++;
                }
            }

            // Wait for one of the buttons to be pressed, and set our selected index
            // to the index mapped to that pressed button
            yield return(new WaitForUIButtons(mapping.Keys.ToArray()).ReplaceCallback((button) =>
            {
                selected = mapping[button];
            }));

            // Cleanup for the next node
            data.ui.ClearChoices();

            yield return(null);
        }
Exemplo n.º 4
0
        public override IEnumerator Execute(DialogFlowData data)
        {
            var left   = GetInputValue("Left", this.left);
            var center = GetInputValue("Center", this.center);
            var right  = GetInputValue("Right", this.right);

            if (left != null || !keepExisting)
            {
                data.ui.SetPortrait(PortraitPosition.Left, left);
            }

            if (center != null || !keepExisting)
            {
                data.ui.SetPortrait(PortraitPosition.Center, center);
            }

            if (right != null || !keepExisting)
            {
                data.ui.SetPortrait(PortraitPosition.Right, right);
            }

            yield return(null);
        }
Exemplo n.º 5
0
        public override IEnumerator Execute(DialogFlowData data)
        {
            // Pull inputs for the node
            var speakerName      = GetInputValue("Name", this.speakerName);
            var portrait         = GetInputValue("Portrait", this.portrait);
            var portraitPosition = GetInputValue("Position", this.portraitPosition);
            var textSpeed        = GetInputValue("Text Speed", this.textSpeed);

            // Update the UI to show our speaker
            if (portrait != null)
            {
                data.ui.SetPortrait(portraitPosition, portrait);
            }

            var btn = data.ui.ContinueButton.gameObject;

            btn.SetActive(false);

            // Dump text, letter-by-letter, into the UI
            int charCount = 0;

            while (charCount++ < text.Length)
            {
                data.ui.ShowMessage(text.Substring(0, charCount), speakerName);
                yield return(new WaitForSeconds(textSpeed));
            }

            // Wait for the user to click continue before leaving this node
            btn.SetActive(true);
            yield return(new WaitForUIButtons(data.ui.ContinueButton));

            // Cleanup for the next node
            data.ui.ClearMessage();

            yield return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get the next node that should be executed along the edge
        /// </summary>
        /// <returns></returns>
        public virtual ICanExecuteDialogFlow GetNext(DialogFlowData data)
        {
            var port = GetPort("DialogFlowOut");

            return(port.ConnectedPorts.FirstOrDefault()?.Node as ICanExecuteDialogFlow);
        }
Exemplo n.º 7
0
 public abstract IEnumerator Execute(DialogFlowData data);
Exemplo n.º 8
0
 public IEnumerator Execute(DialogFlowData data)
 {
     // This node doesn't do anything, it'll just mark the
     // end of the graph and let them return to the game
     yield return(null);
 }
Exemplo n.º 9
0
 public ICanExecuteDialogFlow GetNext(DialogFlowData data)
 {
     // No outputs, this is the end of the graph.
     return(null);
 }
Exemplo n.º 10
0
 public IEnumerator Execute(DialogFlowData data)
 {
     // No-op, this is just an entry point to the graph
     yield return(null);
 }
Exemplo n.º 11
0
 public override IEnumerator Execute(DialogFlowData data)
 {
     yield return(new WaitForSeconds(
                      GetInputValue("Seconds", this.seconds)
                      ));
 }