Esempio n. 1
0
        /// <summary>
        /// Searches the current conversation for any DialogueActors who use subtitle
        /// panels that are configured to appear when the conversation starts.
        /// </summary>
        public void OpenSubtitlePanelsOnStartConversation()
        {
            ApplyQueuedActorPanelCache();

            var conversation = DialogueManager.MasterDatabase.GetConversation(DialogueManager.lastConversationStarted);

            if (conversation == null)
            {
                return;
            }
            HashSet <StandardUISubtitlePanel> checkedPanels = new HashSet <StandardUISubtitlePanel>();
            HashSet <int> checkedActorIDs = new HashSet <int>();

            // Check main Actor & Conversant:
            var mainActorID = conversation.ActorID;
            var mainActor   = DialogueManager.masterDatabase.GetActor(DialogueActor.GetActorName(DialogueManager.currentActor));

            if (mainActor != null)
            {
                mainActorID = mainActor.id;
            }
            CheckActorIDOnStartConversation(mainActorID, checkedActorIDs, checkedPanels);
            CheckActorIDOnStartConversation(conversation.ConversantID, checkedActorIDs, checkedPanels);

            // Check other actors:
            for (int i = 0; i < conversation.dialogueEntries.Count; i++)
            {
                var actorID = conversation.dialogueEntries[i].ActorID;
                CheckActorIDOnStartConversation(actorID, checkedActorIDs, checkedPanels);
            }
        }
Esempio n. 2
0
 public virtual void Start()
 {
     if (string.IsNullOrEmpty(overrideName))
     {
         DialogueActor overrideActorName = GetComponentInChildren <DialogueActor>();
         if (overrideActorName != null)
         {
             overrideName = overrideActorName.GetActorName();
         }
     }
 }
Esempio n. 3
0
 protected virtual void DoLuaAction(Transform actor)
 {
     if (actor != null)
     {
         var dialogueActor = actor.GetComponent <DialogueActor>();
         var actorName     = (dialogueActor != null) ? dialogueActor.actor : actor.name;
         DialogueLua.SetVariable("ActorIndex", actorName);
         DialogueLua.SetVariable("Actor", DialogueActor.GetActorName(actor));
     }
     DoLuaAction();
 }
Esempio n. 4
0
 /// <summary>
 /// Gets the name of the override, including parsing if it contains a [lua]
 /// or [var] tag.
 /// </summary>
 /// <returns>The override name.</returns>
 public string GetName()
 {
     if (string.IsNullOrEmpty(overrideName))
     {
         return(DialogueActor.GetActorName(transform));
     }
     else if (overrideName.Contains("[lua") || overrideName.Contains("[var"))
     {
         return(DialogueManager.GetLocalizedText(FormattedText.Parse(overrideName, DialogueManager.masterDatabase.emphasisSettings).text));
     }
     else
     {
         return(DialogueManager.GetLocalizedText(overrideName));
     }
 }
 private void AssignUniquePersistentDataName()
 {
     serializedObject.ApplyModifiedProperties();
     foreach (var t in targets)
     {
         var dialogueActor = t as DialogueActor;
         if (dialogueActor == null)
         {
             continue;
         }
         Undo.RecordObject(dialogueActor, "Unique ID");
         dialogueActor.persistentDataName = DialogueLua.StringToTableIndex(DialogueActor.GetActorName(dialogueActor.transform) + "_" + dialogueActor.GetInstanceID());
         EditorUtility.SetDirty(dialogueActor);
         UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(dialogueActor.gameObject.scene);
     }
     serializedObject.Update();
 }
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            GameObject trackBinding = playerData as GameObject;

            if (!trackBinding)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight > 0.001f && !played.Contains(i))
                {
                    played.Add(i);
                    ScriptPlayable <BarkBehaviour> inputPlayable = (ScriptPlayable <BarkBehaviour>)playable.GetInput(i);
                    BarkBehaviour input = inputPlayable.GetBehaviour();
                    if (Application.isPlaying)
                    {
                        if (input.useConversation)
                        {
                            DialogueManager.Bark(input.conversation, trackBinding.transform, input.listener);
                        }
                        else
                        {
                            DialogueManager.BarkString(input.text, trackBinding.transform, input.listener);
                        }
                    }
                    else
                    {
                        var message = DialogueActor.GetActorName(trackBinding.transform) + " bark: " + input.GetEditorBarkText();
                        if (input.useConversation)
                        {
                            message += " (may vary)";
                        }
                        PreviewUI.ShowMessage(message, 2, 1);
                    }
                }
                else if (inputWeight <= 0.001f && played.Contains(i))
                {
                    played.Remove(i);
                }
            }
        }
        private Texture2D GetPortrait(Transform character, Actor actor)
        {
            Texture2D portrait = null;

            if (character != null)
            {
                portrait = GetPortraitByActorName(DialogueActor.GetActorName(character), actor);
            }
            if ((portrait == null) && (actor != null))
            {
                portrait = GetPortraitByActorName(actor.Name, actor);
                if (portrait == null)
                {
                    portrait = actor.portrait;
                }
            }
            return(portrait);
        }
        private Sprite GetPortrait(Transform character, Actor actor)
        {
            Sprite portrait = null;

            if (character != null)
            {
                portrait = GetPortraitByActorName(DialogueActor.GetActorName(character), actor);
            }
            if ((portrait == null) && (actor != null))
            {
                portrait = GetPortraitByActorName(actor.Name, actor);
                if (portrait == null)
                {
                    portrait = actor.GetPortraitSprite();
                }
            }
            return(portrait);
        }
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            GameObject trackBinding = playerData as GameObject;

            if (!trackBinding)
            {
                return;
            }

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight > 0.001f && !played.Contains(i))
                {
                    played.Add(i);
                    ScriptPlayable <StartConversationBehaviour> inputPlayable = (ScriptPlayable <StartConversationBehaviour>)playable.GetInput(i);
                    StartConversationBehaviour input = inputPlayable.GetBehaviour();
                    if (Application.isPlaying)
                    {
                        if (input.entryID <= 0)
                        {
                            DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant);
                        }
                        else
                        {
                            DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant, input.entryID);
                        }
                    }
                    else
                    {
                        var message = DialogueActor.GetActorName(trackBinding.transform) + " conversation: " + input.conversant;
                        PreviewUI.ShowMessage(message, 2, 0);
                    }
                }
                else if (inputWeight <= 0.001f && played.Contains(i))
                {
                    played.Remove(i);
                }
            }
        }
        // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            GameObject trackBinding = playerData as GameObject;

            Transform actorTransform = (trackBinding != null) ? trackBinding.transform : null;

            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight > 0.001f && !played.Contains(i))
                {
                    played.Add(i);
                    ScriptPlayable <StartConversationBehaviour> inputPlayable = (ScriptPlayable <StartConversationBehaviour>)playable.GetInput(i);
                    StartConversationBehaviour input = inputPlayable.GetBehaviour();
                    if (Application.isPlaying)
                    {
                        if (input.jumpToSpecificEntry && input.entryID > 0)
                        {
                            DialogueManager.StartConversation(input.conversation, actorTransform, input.conversant, input.entryID);
                        }
                        else
                        {
                            DialogueManager.StartConversation(input.conversation, actorTransform, input.conversant);
                        }
                    }
                    else
                    {
                        var message = "Conversation (" + DialogueActor.GetActorName(actorTransform) + "->" + DialogueActor.GetActorName(input.conversant) + "): [" + input.conversation + "] '" + input.GetEditorDialogueText() + "' (may vary)";
                        PreviewUI.ShowMessage(message, 2, 0);
                    }
                }
                else if (inputWeight <= 0.001f && played.Contains(i))
                {
                    played.Remove(i);
                }
            }
        }
Esempio n. 11
0
 protected virtual string GetBarkerName()
 {
     return(DialogueActor.GetActorName(GetBarker((barkSource == BarkSource.Conversation) ? barkConversation : null)));
 }
Esempio n. 12
0
 private string GetBarkerName()
 {
     return(DialogueActor.GetActorName(GetBarker()));
 }