Пример #1
0
 private void EndBackgroundSpeechAudio(Speech speech)
 {
     foreach (Speech _speech in speechList)
     {
         if (_speech != speech)
         {
             _speech.EndBackgroundSpeechAudio (speech.GetSpeakingCharacter ());
         }
     }
 }
Пример #2
0
 private void UpdateSpeechLink()
 {
     if (!isDuppingSpeech && KickStarter.dialog.GetLatestSpeech () != null)
     {
         speech = KickStarter.dialog.GetLatestSpeech ();
     }
 }
Пример #3
0
        /**
         * <summary>Initialises a new Speech line.</summary>
         * <param name = "_speaker">The speaking character. If null, the line will be treated as narration</param>
         * <param name = "_text">The subtitle text to display</param>
         * <param name = "isBackground">True if the line should play in the background, and not interrupt any Actions or gameplay</param>
         * <param name = "lineID">The ID number of the line, if it is listed in the Speech Manager</param>
         * <param name = "noAnimation">True if the character should not play a talking animation</param>
         * <returns>The generated Speech line</returns>
         */
        public Speech StartDialog(Char _speaker, string _text, bool isBackground = false, int lineID = -1, bool noAnimation = false)
        {
            // Get the language
            string _language = "";
            int lanuageNumber = Options.GetLanguage ();
            if (lanuageNumber > 0)
            {
                // Not in original language, so pull translation in from Speech Manager
                _language = KickStarter.speechManager.languages [lanuageNumber];
            }

            // Remove speaker's previous line
            for (int i=0; i<speechList.Count; i++)
            {
                if (speechList[i].GetSpeakingCharacter () == _speaker)
                {
                    EndSpeech (i);
                    i=0;
                }
            }

            Speech speech = new Speech (_speaker, _text, lineID, _language, isBackground, noAnimation);
            speechList.Add (speech);

            KickStarter.runtimeVariables.AddToSpeechLog (speech.log);
            KickStarter.playerMenus.AssignSpeechToMenu (speech);

            if (speech.hasAudio)
            {
                if (KickStarter.speechManager.relegateBackgroundSpeechAudio)
                {
                    EndBackgroundSpeechAudio (speech);
                }

                KickStarter.stateHandler.UpdateAllMaxVolumes ();
            }

            return speech;
        }
Пример #4
0
 /**
  * <summary>Unassigns a Speech line from any temporarily-duplicated Menus. This will signal such Menus that they can be removed.</summary>
  * <param name = "speech">The Speech line to unassign</param>
  */
 public void RemoveSpeechFromMenu(Speech speech)
 {
     foreach (Menu menu in dupMenus)
     {
         if (menu.speech == speech)
         {
             menu.speech = null;
         }
     }
 }
Пример #5
0
 /**
  * <summary>Assigns the element to a specific Speech line.</summary>
  * <param name = "_speech">The Speech line to assign the element to</param>
  */
 public override void SetSpeech(Speech _speech)
 {
     isDuppingSpeech = true;
     speech = _speech;
 }
Пример #6
0
        public Speech StartDialog(Char _speaker, string _text, int lineID, string _language, bool isBackground, bool noAnimation)
        {
            // Remove speaker's previous line
            for (int i=0; i<speechList.Count; i++)
            {
                if (speechList[i].GetSpeakingCharacter () == _speaker)
                {
                    EndSpeech (i);
                    i=0;
                }
            }

            Speech speech = new Speech (_speaker, _text, lineID, _language, isBackground, noAnimation);
            speechList.Add (speech);

            KickStarter.runtimeVariables.AddToSpeechLog (speech.log);
            KickStarter.playerMenus.AssignSpeechToMenu (speech);

            if (speech.hasAudio)
            {
                if (KickStarter.speechManager.relegateBackgroundSpeechAudio)
                {
                    EndBackgroundSpeechAudio (speech);
                }

                KickStarter.stateHandler.UpdateAllMaxVolumes ();
            }

            return speech;
        }
Пример #7
0
 /**
  * <summary>Duplicates any Menu set to display a single speech line.</summary>
  * <param name = "speech">The Speech line to assign to any duplicated Menu</param>
  */
 public void AssignSpeechToMenu(Speech speech)
 {
     foreach (Menu menu in menus)
     {
         if (menu.appearType == AppearType.WhenSpeechPlays && menu.oneMenuPerSpeech)
         {
             Menu dupMenu = ScriptableObject.CreateInstance <Menu>();
             dupMenu.Copy (menu);
             if (dupMenu.IsUnityUI ())
             {
                 dupMenu.LoadUnityUI ();
             }
             dupMenu.title += " (Duplicate)";
             dupMenu.SetSpeech (speech);
             dupMenu.TurnOn (true);
             dupMenus.Add (dupMenu);
         }
     }
 }
Пример #8
0
        /**
         * <summary>Combines the class's various fields into a formatted HTML string, for display in exported game text.</summary>
         * <param name = "languageIndex">The index number of the language to display fields for, where 0 = the game's original language</param>
         * <param name = "includeDescriptions">If True, its description will also be included</param>
         * <param name = "removeTokens">If True, text tokens such as [wait] within the text will be removed</param>
         * <returns>A string of the owner, filename, text and description</returns>
         */
        public string Print(int languageIndex = 0, bool includeDescriptions = false, bool removeTokens = false)
        {
            int i = languageIndex;

            string result = "<table>\n";

            result += "<tr><td><b>Line ID:</b></td><td>" + lineID + "</td></tr>\n";
            result += "<tr><td width=150><b>Character:</b></td><td>" + GetSpeakerName() + "</td></tr>\n";

            string lineText = text;

            if (i > 0 && translationText.Count > (i - 1))
            {
                lineText = translationText [i - 1];
            }

            if (removeTokens)
            {
                Speech tempSpeech = new Speech(lineText);
                lineText = tempSpeech.displayText;
            }

            result += "<tr><td><b>Line text:</b></td><td>" + lineText + "</td></tr>\n";

            if (description != null && description.Length > 0 && includeDescriptions)
            {
                result += "<tr><td><b>Description:</b></td><td>" + description + "</td></tr>\n";
            }

            string        language      = "";
            SpeechManager speechManager = AdvGame.GetReferences().speechManager;

            if (i > 0 && speechManager.translateAudio)
            {
                language = AdvGame.GetReferences().speechManager.languages[i];
            }

            if (speechManager.autoNameSpeechFiles)
            {
                if (SeparatePlayerAudio())
                {
                    if (speechManager.UseFileBasedLipSyncing())
                    {
                        for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                        {
                            if (KickStarter.settingsManager.players[j].playerOb != null)
                            {
                                string overrideName = KickStarter.settingsManager.players[j].playerOb.name;
                                result += "<td><b>Lipsync file:</b></td><td>" + GetFolderName(language, true, overrideName) + GetFilename(overrideName) + lineID.ToString() + "</td></tr>\n";
                            }
                        }
                    }

                    for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                    {
                        if (KickStarter.settingsManager.players[j].playerOb != null)
                        {
                            string overrideName = KickStarter.settingsManager.players[j].playerOb.name;
                            result += "<tr><td><b>Audio file:</b></td><td>" + GetFolderName(language, false, overrideName) + GetFilename(overrideName) + lineID.ToString() + "</td></tr>\n";
                        }
                    }
                }
                else
                {
                    if (speechManager.UseFileBasedLipSyncing())
                    {
                        result += "<td><b>Lipsync file:</b></td><td>" + GetFolderName(language, true) + GetFilename() + lineID.ToString() + "</td></tr>\n";
                    }
                    result += "<tr><td><b>Audio file:</b></td><td>" + GetFolderName(language, false) + GetFilename() + lineID.ToString() + "</td></tr>\n";
                }
            }
            else
            {
                if (speechManager.UseFileBasedLipSyncing() && customLipsyncFile != null)
                {
                    result += "<td><b>Lipsync file:</b></td><td>" + customLipsyncFile.name + "</td></tr>\n";
                }
                if (customAudioClip != null)
                {
                    result += "<tr><td><b>Audio file:</b></td><td>" + customAudioClip.name + "</td></tr>\n";
                }
            }

            result += "</table>\n\n";
            result += "<br/>\n";
            return(result);
        }
Пример #9
0
        private float StartSpeech()
        {
            string _text = messageText;
            string _language = "";
            int _lineID = lineID;

            int lanuageNumber = Options.GetLanguage ();
            if (lanuageNumber > 0)
            {
                // Not in original language, so pull translation in from Speech Manager
                _text = SpeechManager.GetTranslation (_text, lineID, lanuageNumber);
                _language = KickStarter.speechManager.languages [lanuageNumber];
            }

            bool isSplittingLines = false;
            bool isLastSplitLine = false;

            _text = _text.Replace ("\\n", "\n");

            if (KickStarter.speechManager.separateLines)
            {
                // Split line into an array, and pull the correct one
                string[] textArray = _text.Split (stringSeparators, System.StringSplitOptions.None);
                _text = textArray [splitNumber];

                if (textArray.Length > 1)
                {
                    isSplittingLines = true;

                    if (splitNumber > 0)
                    {
                        _lineID = -1;
                    }
                    if (textArray.Length > splitNumber)
                    {
                        isLastSplitLine = true;
                    }
                }
            }

            if (_text != "")
            {
                speech = KickStarter.dialog.StartDialog (speaker, _text, _lineID, _language, isBackground, noAnimation);
                float displayDuration = speech.displayDuration;

                if (speaker && !noAnimation)
                {
                    if (speaker.animEngine == null)
                    {
                        speaker.ResetAnimationEngine ();
                    }

                    if (speaker.animEngine != null)
                    {
                        speaker.animEngine.ActionSpeechRun (this);
                    }
                }

                if (isLastSplitLine)
                {
                    return (displayDuration + waitTimeOffset);
                }

                if (isSplittingLines)
                {
                    return displayDuration;
                }

                if (!isBackground)
                {
                    return (displayDuration + waitTimeOffset);
                }
            }

            return 0f;
        }
Пример #10
0
 public override void SetSpeech(Speech _speech)
 {
     isDuppingSpeech = true;
     speech          = _speech;
 }
Пример #11
0
        private float StartSpeech()
        {
            string _text = messageText;
            int _lineID = lineID;

            int languageNumber = Options.GetLanguage ();
            if (languageNumber > 0)
            {
                // Not in original language, so pull translation in from Speech Manager
                _text = KickStarter.runtimeLanguages.GetTranslation (_text, lineID, languageNumber);
            }

            bool isSplittingLines = false;
            bool isLastSplitLine = false;

            _text = _text.Replace ("\\n", "\n");

            if (KickStarter.speechManager.separateLines)
            {
                string[] textArray = messageText.Replace ("\\n", "\n").Split (stringSeparators, System.StringSplitOptions.None);
                if (textArray.Length > 1)
                {
                    _text = textArray [splitIndex];
                    isSplittingLines = true;

                    if (splitIndex > 0)
                    {
                        if (multiLineIDs != null && multiLineIDs.Length > (splitIndex-1))
                        {
                            _lineID = multiLineIDs[splitIndex-1];
                        }
                        else
                        {
                            _lineID = -1;
                        }
                    }
                    if (textArray.Length > splitIndex)
                    {
                        isLastSplitLine = true;
                    }

                    if (languageNumber > 0)
                    {
                        _text = KickStarter.runtimeLanguages.GetTranslation (_text, _lineID, languageNumber);
                    }
                }
            }

            if (_text != "")
            {
                speech = KickStarter.dialog.StartDialog (runtimeSpeaker, _text, isBackground, _lineID, noAnimation);
                float displayDuration = speech.displayDuration;

                if (runtimeSpeaker && !noAnimation)
                {
                    if (runtimeSpeaker.GetAnimEngine () != null)
                    {
                        runtimeSpeaker.GetAnimEngine ().ActionSpeechRun (this);
                    }
                }

                if (isLastSplitLine)
                {
                    return (displayDuration + waitTimeOffset);
                }

                if (isSplittingLines)
                {
                    return displayDuration;
                }

                if (!isBackground)
                {
                    return (displayDuration + waitTimeOffset);
                }
            }

            return 0f;
        }
Пример #12
0
        private float StartSpeech()
        {
            string _text   = messageText;
            int    _lineID = lineID;

            int languageNumber = Options.GetLanguage();

            if (languageNumber > 0)
            {
                // Not in original language, so pull translation in from Speech Manager
                _text = KickStarter.runtimeLanguages.GetTranslation(_text, lineID, languageNumber);
            }

            bool isSplittingLines = false;
            bool isLastSplitLine  = false;

            _text = _text.Replace("\\n", "\n");

            if (KickStarter.speechManager.separateLines)
            {
                string[] textArray = messageText.Replace("\\n", "\n").Split(stringSeparators, System.StringSplitOptions.None);
                if (textArray.Length > 1)
                {
                    _text            = textArray [splitIndex];
                    isSplittingLines = true;

                    if (splitIndex > 0)
                    {
                        if (multiLineIDs != null && multiLineIDs.Length > (splitIndex - 1))
                        {
                            _lineID = multiLineIDs[splitIndex - 1];
                        }
                        else
                        {
                            _lineID = -1;
                        }
                    }
                    if (textArray.Length > splitIndex)
                    {
                        isLastSplitLine = true;
                    }

                    if (languageNumber > 0)
                    {
                        _text = KickStarter.runtimeLanguages.GetTranslation(_text, _lineID, languageNumber);
                    }
                }
            }

            if (_text != "")
            {
                speech = KickStarter.dialog.StartDialog(runtimeSpeaker, _text, isBackground, _lineID, noAnimation);
                float displayDuration = speech.displayDuration;

                if (runtimeSpeaker && !noAnimation)
                {
                    if (runtimeSpeaker.GetAnimEngine() != null)
                    {
                        runtimeSpeaker.GetAnimEngine().ActionSpeechRun(this);
                    }
                }

                if (isLastSplitLine)
                {
                    return(displayDuration + waitTimeOffset);
                }

                if (isSplittingLines)
                {
                    return(displayDuration);
                }

                if (!isBackground)
                {
                    return(displayDuration + waitTimeOffset);
                }
            }

            return(0f);
        }
Пример #13
0
 public virtual void SetSpeech(Speech _speech)
 {
 }
Пример #14
0
        private float StartSpeech()
        {
            string _text     = messageText;
            string _language = "";
            int    _lineID   = lineID;

            int lanuageNumber = Options.GetLanguage();

            if (lanuageNumber > 0)
            {
                // Not in original language, so pull translation in from Speech Manager
                _text     = SpeechManager.GetTranslation(_text, lineID, lanuageNumber);
                _language = KickStarter.speechManager.languages [lanuageNumber];
            }

            bool isSplittingLines = false;
            bool isLastSplitLine  = false;

            _text = _text.Replace("\\n", "\n");

            if (KickStarter.speechManager.separateLines)
            {
                // Split line into an array, and pull the correct one
                string[] textArray = _text.Split(stringSeparators, System.StringSplitOptions.None);
                _text = textArray [splitNumber];

                if (textArray.Length > 1)
                {
                    isSplittingLines = true;

                    if (splitNumber > 0)
                    {
                        _lineID = -1;
                    }
                    if (textArray.Length > splitNumber)
                    {
                        isLastSplitLine = true;
                    }
                }
            }

            if (_text != "")
            {
                speech = KickStarter.dialog.StartDialog(speaker, _text, _lineID, _language, isBackground, noAnimation);
                float displayDuration = speech.displayDuration;

                if (speaker && !noAnimation)
                {
                    if (speaker.animEngine == null)
                    {
                        speaker.ResetAnimationEngine();
                    }

                    if (speaker.animEngine != null)
                    {
                        speaker.animEngine.ActionSpeechRun(this);
                    }
                }

                if (isLastSplitLine)
                {
                    return(displayDuration + waitTimeOffset);
                }

                if (isSplittingLines)
                {
                    return(displayDuration);
                }

                if (!isBackground)
                {
                    return(displayDuration + waitTimeOffset);
                }
            }

            return(0f);
        }