/// <summary>
 /// Executes a conversation action.
 /// </summary>
 public void DoAction(ConversationAction action, Transform actor)
 {
     if (action != null)
     {
         Transform speaker  = Tools.Select(action.speaker, this.transform);
         Transform listener = Tools.Select(action.listener, actor);
         bool      skip     = action.skipIfNoValidEntries && !DialogueManager.ConversationHasValidEntry(action.conversation, speaker, listener);
         if (!skip)
         {
             DialogueManager.StartConversation(action.conversation, speaker, listener);
         }
     }
 }
Example #2
0
        protected virtual void DoConversationAction(Transform actor)
        {
            if (string.IsNullOrEmpty(conversation))
            {
                return;
            }
            if (exclusive && DialogueManager.isConversationActive)
            {
                if (DialogueDebug.logInfo)
                {
                    Debug.Log("Dialogue System: Conversation triggered on " + name + " but skipping because another conversation is active.", this);
                }
            }
            else
            {
                var actorTransform      = Tools.Select(conversationActor, actor);
                var conversantTransform = conversationConversant;
                if (conversantTransform == null)
                {
                    var conversationAsset           = DialogueManager.MasterDatabase.GetConversation(conversation);
                    var conversationConversantActor = (conversationAsset != null) ? DialogueManager.MasterDatabase.GetActor(conversationAsset.ConversantID) : null;
                    var registeredTransform         = (conversationConversantActor != null) ? CharacterInfo.GetRegisteredActorTransform(conversationConversantActor.Name) : null;
                    conversantTransform = (registeredTransform != null) ? registeredTransform : this.transform;
                }
                if (skipIfNoValidEntries && !DialogueManager.ConversationHasValidEntry(conversation, actorTransform, conversantTransform))
                {
                    if (DialogueDebug.logInfo)
                    {
                        Debug.Log("Dialogue System: Conversation triggered on " + name + " but skipping because no entries are currently valid.", this);
                    }
                }
                else
                {
                    if (stopConversationIfTooFar || showCursorDuringConversation || pauseGameDuringConversation)
                    { // Trigger may not be on actor or conversant, so we need to hook into these events:
                        DialogueManager.instance.conversationStarted += OnConversationStartAnywhere;
                        DialogueManager.instance.conversationEnded   += OnConversationEndAnywhere;
                    }

                    DialogueManager.StartConversation(conversation, actorTransform, conversantTransform, startConversationEntryID);
                    earliestTimeToAllowTriggerExit = Time.time + MarginToAllowTriggerExit;
                    if (stopConversationIfTooFar)
                    {
                        monitorDistanceCoroutine = StartCoroutine(MonitorDistance(DialogueManager.currentActor));
                    }
                }
            }
        }
        private void StartConversation(Transform actor)
        {
            Transform actualConversant = Tools.Select(conversant, this.transform);
            bool      skip             = skipIfNoValidEntries && !DialogueManager.ConversationHasValidEntry(conversation, actor, actualConversant);

            if (skip)
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log(string.Format("{0}: Conversation triggered on {1}, but skipping because no entries are currently valid.", new System.Object[] { DialogueDebug.Prefix, name }));
                }
            }
            else
            {
                DialogueManager.StartConversation(conversation, actor, actualConversant);
            }
        }
Example #4
0
 protected virtual void DoConversationAction(Transform actor)
 {
     if (string.IsNullOrEmpty(conversation))
     {
         return;
     }
     if (skipIfNoValidEntries && !DialogueManager.ConversationHasValidEntry(conversation, Tools.Select(conversationActor, actor), Tools.Select(conversationConversant, this.transform)))
     {
         if (DialogueDebug.logInfo)
         {
             Debug.Log("Dialogue System: Conversation triggered on " + name + " but skipping because no entries are currently valid.", this);
         }
     }
     else if (exclusive && DialogueManager.isConversationActive)
     {
         if (DialogueDebug.logInfo)
         {
             Debug.Log("Dialogue System: Conversation triggered on " + name + " but skipping because another conversation is active.", this);
         }
     }
     else
     {
         var actorTransform      = Tools.Select(conversationActor, actor);
         var conversantTransform = conversationConversant;
         if (conversantTransform == null)
         {
             var conversationAsset           = DialogueManager.MasterDatabase.GetConversation(conversation);
             var conversationConversantActor = DialogueManager.MasterDatabase.GetActor(conversationAsset.ConversantID);
             var registeredTransform         = (conversationConversantActor != null) ? CharacterInfo.GetRegisteredActorTransform(conversationConversantActor.Name) : null;
             conversantTransform = (registeredTransform != null) ? registeredTransform : this.transform;
         }
         DialogueManager.StartConversation(conversation, actorTransform, conversantTransform);
         earliestTimeToAllowTriggerExit = Time.time + MarginToAllowTriggerExit;
         if (stopConversationIfTooFar)
         {
             monitorDistanceCoroutine = StartCoroutine(MonitorDistance(actor));
         }
     }
 }