Example #1
0
 protected virtual void DoSetActiveActions(Transform actor)
 {
     for (int i = 0; i < setActiveActions.Length; i++)
     {
         var action = setActiveActions[i];
         if (action != null && action.condition != null && action.condition.IsTrue(actor))
         {
             var  target   = Tools.Select(action.target, this.transform);
             bool newValue = ToggleUtility.GetNewValue(target.gameObject.activeSelf, action.state);
             if (DialogueDebug.logInfo)
             {
                 Debug.Log(string.Format("{0}: Trigger: {1}.SetActive({2})", new System.Object[] { DialogueDebug.Prefix, target.name, newValue }));
             }
             target.gameObject.SetActive(newValue);
         }
     }
 }
        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);
            }
        }
 /// <summary>
 /// Starts the sequence if the condition is true.
 /// </summary>
 /// <param name="actor">Actor.</param>
 /// <param name="interactor">Interactor to test the condition against.</param>
 public void TryStartSequence(Transform actor, Transform interactor)
 {
     if (tryingToStart)
     {
         return;
     }
     tryingToStart = true;
     try
     {
         if (((condition == null) || condition.IsTrue(interactor)) && !string.IsNullOrEmpty(sequence))
         {
             DialogueManager.PlaySequence(sequence, Tools.Select(speaker, this.transform), Tools.Select(listener, actor));
             DestroyIfOnce();
         }
     }
     finally
     {
         tryingToStart = false;
     }
 }
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, startConversationEntryID);
         earliestTimeToAllowTriggerExit = Time.time + MarginToAllowTriggerExit;
         if (stopConversationIfTooFar)
         {
             monitorDistanceCoroutine = StartCoroutine(MonitorDistance(DialogueManager.currentActor));
         }
     }
 }
Example #5
0
 public void DoAction(SetAnimatorStateAction action, Transform actor)
 {
     if (action != null)
     {
         Transform target   = Tools.Select(action.target, this.transform);
         Animator  animator = target.GetComponentInChildren <Animator>();
         if (animator == null)
         {
             if (DialogueDebug.logWarnings)
             {
                 Debug.Log(string.Format("{0}: Trigger: {1}.SetAnimatorState() can't find Animator", new System.Object[] { DialogueDebug.Prefix, target.name }));
             }
         }
         else
         {
             if (DialogueDebug.logInfo)
             {
                 Debug.Log(string.Format("{0}: Trigger: {1}.SetAnimatorState({2})", new System.Object[] { DialogueDebug.Prefix, target.name, action.stateName }));
             }
             animator.CrossFade(action.stateName, action.crossFadeDuration);
         }
     }
 }
Example #6
0
        protected virtual void DoBarkAction(Transform actor)
        {
            switch (barkSource)
            {
            case BarkSource.Conversation:
                if (string.IsNullOrEmpty(barkConversation))
                {
                    return;
                }
                if (DialogueManager.isConversationActive && !allowBarksDuringConversations)
                {
                    if (DialogueDebug.logWarnings)
                    {
                        Debug.LogWarning("Dialogue System: Bark triggered on " + name + ", but a conversation is already active.", GetBarker(barkConversation));
                    }
                }
                else if (cacheBarkLines)
                {
                    BarkCachedLine(GetBarker(barkConversation), Tools.Select(barkTarget, actor));
                }
                else
                {
                    if (barkGroupMember != null)
                    {
                        barkGroupMember.GroupBark(barkConversation, Tools.Select(barkTarget, actor), barkHistory);
                    }
                    else
                    {
                        DialogueManager.Bark(barkConversation, GetBarker(barkConversation), Tools.Select(barkTarget, actor), barkHistory);
                    }
                    sequencer = BarkController.LastSequencer;
                }
                break;

            case BarkSource.Text:
                if (string.IsNullOrEmpty(barkText))
                {
                    return;
                }
                if (DialogueManager.isConversationActive && !allowBarksDuringConversations)
                {
                    if (DialogueDebug.logWarnings)
                    {
                        Debug.LogWarning("Dialogue System: Bark triggered on " + name + ", but a conversation is already active.", GetBarker(null));
                    }
                }
                else
                {
                    if (barkGroupMember != null)
                    {
                        barkGroupMember.GroupBarkString(barkText, Tools.Select(barkTarget, actor), barkTextSequence);
                    }
                    else
                    {
                        DialogueManager.BarkString(barkText, GetBarker(null), Tools.Select(barkTarget, actor), barkTextSequence);
                    }
                    sequencer = BarkController.LastSequencer;
                }
                break;
            }
        }
Example #7
0
 protected virtual void DoSequenceAction(Transform actor)
 {
     if (string.IsNullOrEmpty(sequence))
     {
         return;
     }
     DialogueManager.PlaySequence(sequence, Tools.Select(sequenceSpeaker, transform), Tools.Select(sequenceListener, actor));
 }
Example #8
0
 private Transform GetBarker()
 {
     return(Tools.Select(conversant, this.transform));
 }