Пример #1
0
 /// <summary>
 /// Initialize a UI and sequencer with displaySettings.
 /// </summary>
 /// <param name='ui'>
 /// Dialogue UI.
 /// </param>
 /// <param name='sequencer'>
 /// Sequencer.
 /// </param>
 /// <param name='displaySettings'>
 /// Display settings to initiate the UI and sequencer with.
 /// </param>
 public void Initialize(IDialogueUI ui, Sequencer sequencer, DisplaySettings displaySettings, DialogueEntrySpokenDelegate dialogueEntrySpokenHandler)
 {
     this.ui        = ui;
     this.sequencer = sequencer;
     this.settings  = displaySettings;
     this.dialogueEntrySpokenHandler = dialogueEntrySpokenHandler;
     ui.Open();
     sequencer.Open();
     ui.SelectedResponseHandler        += OnSelectedResponse;
     sequencer.FinishedSequenceHandler += OnFinishedSubtitle;
 }
Пример #2
0
        /// <summary>
        /// Initializes a new ConversationModel.
        /// </summary>
        /// <param name="database">The database to use.</param>
        /// <param name="title">The title of the conversation in the database.</param>
        /// <param name="actor">Actor.</param>
        /// <param name="conversant">Conversant.</param>
        /// <param name="allowLuaExceptions">If set to <c>true</c> allow Lua exceptions.</param>
        /// <param name="isDialogueEntryValid">Is dialogue entry valid.</param>
        /// <param name="initialDialogueEntryID">Initial dialogue entry ID (-1 to start at beginning).</param>
        /// <param name="stopAtFirstValid">If set to <c>true</c> stop at first valid link from the initial entry.</param>
        /// <param name="skipExecution">IF set to <c>true</c>, doesn't run the Lua Script or OnExecute event on the initial entry.</param>
        public ConversationModel(DialogueDatabase database, string title, Transform actor, Transform conversant,
                                 bool allowLuaExceptions, IsDialogueEntryValidDelegate isDialogueEntryValid,
                                 int initialDialogueEntryID = -1, bool stopAtFirstValid = false, bool skipExecution = false)
        {
            this.m_allowLuaExceptions = allowLuaExceptions;
            this.m_database           = database;
            this.isDialogueEntryValid = isDialogueEntryValid;
            DisplaySettings displaySettings = DialogueManager.displaySettings;

            if (displaySettings != null)
            {
                if (displaySettings.cameraSettings != null)
                {
                    m_entrytagFormat = displaySettings.cameraSettings.entrytagFormat;
                }
                if (displaySettings.inputSettings != null)
                {
                    m_emTagForOldResponses     = displaySettings.inputSettings.emTagForOldResponses;
                    m_emTagForInvalidResponses = displaySettings.inputSettings.emTagForInvalidResponses;
                    m_includeInvalidEntries    = displaySettings.GetIncludeInvalidEntries();
                }
            }
            Conversation conversation = database.GetConversation(title);

            if (conversation != null)
            {
                SetParticipants(conversation, actor, conversant);
                if (initialDialogueEntryID == -1)
                {
                    firstState = GetState(conversation.GetFirstDialogueEntry(), true, stopAtFirstValid, skipExecution);
                    FixFirstStateSequence();
                }
                else
                {
                    firstState = GetState(conversation.GetDialogueEntry(initialDialogueEntryID), true, stopAtFirstValid, skipExecution);
                }
            }
            else
            {
                firstState = null;
                if (DialogueDebug.logErrors)
                {
                    Debug.LogWarning(string.Format("{0}: Conversation '{1}' not found in database.", new System.Object[] { DialogueDebug.Prefix, title }));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// A duration based on the text length and the Dialogue Manager's
        /// Subtitle Settings > Min Subtitle Seconds and Subtitle Chars Per Second.
        /// Also factors in time for RPGMaker-style pause codes.
        /// </summary>
        /// <param name="text">Text.</param>
        /// <param name="displaySettings">If null, uses Dialogue Manager's Display Settings.</param>
        public static float GetDefaultSubtitleDurationInSeconds(string text, DisplaySettings displaySettings = null)
        {
            if (overrideGetDefaultSubtitleDuration != null)
            {
                return(overrideGetDefaultSubtitleDuration(text));
            }
            var   settings          = displaySettings ?? DialogueManager.displaySettings;
            int   numCharacters     = string.IsNullOrEmpty(text) ? 0 : Tools.StripRichTextCodes(text).Length;
            float numRPGMakerPauses = 0;

            if (text.Contains("\\"))
            {
                var numFullPauses    = (text.Length - text.Replace("\\.", string.Empty).Length) / 2;
                var numQuarterPauses = (text.Length - text.Replace("\\,", string.Empty).Length) / 2;
                numRPGMakerPauses = (1.0f * numFullPauses) + (0.25f * numQuarterPauses);
            }
            return(Mathf.Max(settings.GetMinSubtitleSeconds(), numRPGMakerPauses + (numCharacters / Mathf.Max(1, settings.GetSubtitleCharsPerSecond()))));
        }
Пример #4
0
        /// <summary>
        /// Initializes a new ConversationModel.
        /// </summary>
        /// <param name='database'>
        /// The database to use.
        /// </param>
        /// <param name='title'>
        /// The title of the conversation in the database.
        /// </param>
        /// <param name='actor'>
        /// Actor.
        /// </param>
        /// <param name='conversant'>
        /// Conversant.
        /// </param>
        public ConversationModel(DialogueDatabase database, string title, Transform actor, Transform conversant,
                                 bool allowLuaExceptions, IsDialogueEntryValidDelegate isDialogueEntryValid)
        {
            this.allowLuaExceptions   = allowLuaExceptions;
            this.database             = database;
            this.IsDialogueEntryValid = isDialogueEntryValid;
            Conversation conversation = database.GetConversation(title);

            if (conversation != null)
            {
                SetParticipants(conversation, actor, conversant);
                FirstState = GetState(conversation.GetFirstDialogueEntry());
                FixFirstStateSequence();
            }
            else
            {
                FirstState = null;
                if (DialogueDebug.LogErrors)
                {
                    Debug.LogWarning(string.Format("{0}: Conversation '{1}' not found in database.", new System.Object[] { DialogueDebug.Prefix, title }));
                }
            }
            DisplaySettings displaySettings = DialogueManager.DisplaySettings;

            if (displaySettings != null)
            {
                if (displaySettings.cameraSettings != null)
                {
                    entrytagFormat = displaySettings.cameraSettings.entrytagFormat;
                }
                if (displaySettings.inputSettings != null)
                {
                    emTagForOldResponses = displaySettings.inputSettings.emTagForOldResponses;
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Initialize a UI and sequencer with displaySettings.
 /// </summary>
 /// <param name='ui'>
 /// Dialogue UI.
 /// </param>
 /// <param name='sequencer'>
 /// Sequencer.
 /// </param>
 /// <param name='displaySettings'>
 /// Display settings to initiate the UI and sequencer with.
 /// </param>
 public void Initialize(IDialogueUI ui, Sequencer sequencer, DisplaySettings displaySettings, DialogueEntrySpokenDelegate dialogueEntrySpokenHandler)
 {
     this.ui = ui;
     this.sequencer = sequencer;
     this.settings = displaySettings;
     this.dialogueEntrySpokenHandler = dialogueEntrySpokenHandler;
     ui.Open ();
     sequencer.Open ();
     ui.SelectedResponseHandler += OnSelectedResponse;
     sequencer.FinishedSequenceHandler += OnFinishedSubtitle;
 }
 /// <summary>
 /// Looks for any dialogue UI or display settings overrides on the conversant.
 /// </summary>
 /// <param name='conversant'>
 /// Conversant.
 /// </param>
 private void SetConversationUI(Transform conversant)
 {
     if (conversant != null) {
         OverrideDialogueUI overrideDialogueUI = conversant.GetComponentInChildren<OverrideDialogueUI>();
         OverrideDisplaySettings overrideDisplaySettings = conversant.GetComponentInChildren<OverrideDisplaySettings>();
         if ((overrideDialogueUI != null) && (overrideDialogueUI.ui != null)) {
             isOverrideUIPrefab = Tools.IsPrefab(overrideDialogueUI.ui);
             originalDialogueUI = DialogueUI;
             displaySettings.dialogueUI = overrideDialogueUI.ui;
             currentDialogueUI = null;
         } else if (overrideDisplaySettings != null) {
             if (overrideDisplaySettings.displaySettings.dialogueUI != null) {
                 isOverrideUIPrefab = Tools.IsPrefab(overrideDisplaySettings.displaySettings.dialogueUI);
                 originalDialogueUI = DialogueUI;
                 currentDialogueUI = null;
             }
             originalDisplaySettings = displaySettings;
             displaySettings = overrideDisplaySettings.displaySettings;
         }
         ValidateCurrentDialogueUI();
     }
 }
 private void RestoreOriginalUI()
 {
     if (originalDisplaySettings != null) displaySettings = originalDisplaySettings;
     if (originalDialogueUI != null) {
         if (isOverrideUIPrefab) {
             MonoBehaviour uiBehaviour = currentDialogueUI as MonoBehaviour;
             if (uiBehaviour != null) Destroy(uiBehaviour.gameObject);
         }
         currentDialogueUI = originalDialogueUI;
         displaySettings.dialogueUI = (originalDialogueUI as MonoBehaviour).gameObject;
     }
     isOverrideUIPrefab = false;
     originalDialogueUI = null;
     originalDisplaySettings = null;
 }
 private void InitializeDisplaySettings()
 {
     if (displaySettings == null) {
         displaySettings = new DisplaySettings();
         displaySettings.cameraSettings = new DisplaySettings.CameraSettings();
         displaySettings.inputSettings = new DisplaySettings.InputSettings();
         displaySettings.inputSettings.cancel = new InputTrigger(KeyCode.Escape);
         displaySettings.inputSettings.qteButtons = new string[2] { "Fire1", "Fire2" };
         displaySettings.subtitleSettings = new DisplaySettings.SubtitleSettings();
         displaySettings.localizationSettings = new DisplaySettings.LocalizationSettings();
     }
     if (displaySettings.localizationSettings.useSystemLanguage) displaySettings.localizationSettings.language = Localization.GetLanguage(Application.systemLanguage);
     Localization.Language = displaySettings.localizationSettings.language;
 }