Ejemplo n.º 1
0
        /// <summary>
        /// Continues the dialogue and chooses the next node.  If no next node is found, the Dialogue closes and a new one is chosen if applicable.
        /// </summary>
        public void Next()
        {
            int numPlayerResponses = currentDialogue.GetPlayerChildren(currentNode).Count();

            if (numPlayerResponses > 0)
            {
                playerAnimator.SetBool("IsTalking", true);
                currentConversant.TalkAnimation(false);
                isChoosing = true;
                TriggerExtiAction();
                onConversationUpdated();
                return;
            }

            DialogueNode[] children = currentDialogue.GetAIChildren(currentNode).ToArray();
            if (children.Length > 0)
            {
                int randomNode = UnityEngine.Random.Range(0, children.Count());
                TriggerExtiAction();
                currentNode = children[randomNode];
                TriggerEnterAction();
                playerAnimator.SetBool("IsTalking", false);
                currentConversant.TalkAnimation(true);
                onConversationUpdated();
                return;
            }
            //FinishedCurrentDialogue();
            QuitDialogue();
        }
Ejemplo n.º 2
0
        public void StartDialogue(AIConversant conversant, Dialogue newDialogue)
        {
            currentConversant = conversant;
            currentDialogue   = newDialogue;
            currentNode       = currentDialogue.GetRootNode();

            if (currentNode.IsPlayerSpeaking())
            {
                playerAnimator.SetBool("IsTalking", true);
                currentConversant.TalkAnimation(false);
            }
            else
            {
                playerAnimator.SetBool("IsTalking", false);
                currentConversant.TalkAnimation(true);
            }

            TriggerEnterAction();
            onConversationUpdated();
        }