Example #1
0
        public void NextEntry()
        {
            bool entryFound = false;

            if (current != null)
            {
                if (!current.isEnd)
                {
                    Transition selectedTransition = current.transitions.SelectTransition(this);
                    if (selectedTransition != null)
                    {
                        DialogueEntry nextEntry = conversation.FindEntry(selectedTransition.TargetID);
                        if (nextEntry != null)
                        {
                            current = nextEntry;
                            foreach (DialogueEventInstance e in current.OnEnter)
                            {
                                e.Execute(this);
                            }
                            UISystem.SetDialogueEntry(current);
                            entryFound = true;
                        }
                    }
                }
                if (!entryFound)
                {
                    EndConversation();
                }
            }
        }
        private IEnumerator NextEntryRoutine()
        {
            bool entryFound = false;

            acceptingInput = false;
            if (current != null)
            {
                // Do onExit events and routines
                foreach (DialogueEventInstance e in current.OnExit)
                {
                    e.Execute(this);
                    if (e.IsRoutine)
                    {
                        yield return(e.DoRoutine(this));
                    }
                    // Some events force end conversation, if so breaking here
                    if (!m_inConversation)
                    {
                        yield break;
                    }
                }
                if (!current.isEnd)
                {
                    Transition selectedTransition = current.transitions.SelectTransition(this);
                    if (selectedTransition != null)
                    {
                        DialogueEntry nextEntry = conversation.FindEntry(selectedTransition.TargetID);
                        if (nextEntry != null)
                        {
                            current = nextEntry;
                            // Do onEntry events and routines
                            foreach (DialogueEventInstance e in current.OnEnter)
                            {
                                e.Execute(this);
                                if (e.IsRoutine)
                                {
                                    yield return(e.DoRoutine(this));
                                }
                                // Some events force end conversation, if so breaking here
                                if (!m_inConversation)
                                {
                                    yield break;
                                }
                            }
                            UISystem.SetDialogueEntry(current);
                            entryFound = true;
                        }
                    }
                }
            }
            if (!entryFound)
            {
                EndConversation();
            }
            acceptingInput = true;
        }