Say() public méthode

Write a line of story text to the Say Dialog. Starts coroutine automatically.
public Say ( string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, AudioClip voiceOverClip, Action onComplete ) : void
text string The text to display.
clearPrevious bool Clear any previous text in the Say Dialog.
waitForInput bool Wait for player input before continuing once text is written.
fadeWhenDone bool Fade out the Say Dialog when writing and player input has finished.
stopVoiceover bool Stop any existing voiceover audio before writing starts.
voiceOverClip AudioClip Voice over audio clip to play.
onComplete Action Callback to execute when writing and player input have finished.
Résultat void
Exemple #1
0
        public override void OnEnter()
        {
            if (showOnce && executionCount > 0)
            {
                Continue();
                return;
            }

            executionCount++;

            SayDialog dialog = SetSayDialog.activeDialog;

            showBasicGUI = false;
            if (dialog == null)
            {
                showBasicGUI = true;
                return;
            }

            dialog.SetCharacter(character);

            dialog.ShowDialog(true);

            if (voiceOverClip != null)
            {
                MusicController.GetInstance().PlaySound(voiceOverClip, 1f);
            }

            dialog.Say(storyText, delegate {
                dialog.ShowDialog(false);
                Continue();
            });
        }
Exemple #2
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            // Override the active say dialog if needed
            if (character != null && character.setSayDialog != null)
            {
                SayDialog.activeSayDialog = character.setSayDialog;
            }

            if (setSayDialog != null)
            {
                SayDialog.activeSayDialog = setSayDialog;
            }

            SayDialog sayDialog = SayDialog.GetSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            Flowchart flowchart = GetFlowchart();

            sayDialog.gameObject.SetActive(true);

            sayDialog.SetCharacter(character, flowchart);
            sayDialog.SetCharacterImage(portrait);

            string displayText = storyText;

            foreach (CustomTag ct in CustomTag.activeCustomTags)
            {
                displayText = displayText.Replace(ct.tagStartSymbol, ct.replaceTagStartWith);
                if (ct.tagEndSymbol != "" && ct.replaceTagEndWith != "")
                {
                    displayText = displayText.Replace(ct.tagEndSymbol, ct.replaceTagEndWith);
                }
            }

            string subbedText = flowchart.SubstituteVariables(displayText);

            sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, voiceOverClip, delegate {
                Continue();
            });
        }
Exemple #3
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            SayDialog sayDialog = SetSayDialog.GetActiveSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            FungusScript fungusScript = GetFungusScript();

            sayDialog.SetCharacter(character, fungusScript);
            sayDialog.SetCharacterImage(portrait);

            sayDialog.ShowDialog(true);

            if (voiceOverClip != null)
            {
                sayDialog.PlayVoiceOver(voiceOverClip);
            }

            string subbedText = fungusScript.SubstituteVariables(storyText);

            sayDialog.Say(subbedText, waitForInput, delegate {
                if (waitForInput)
                {
                    sayDialog.ShowDialog(false);
                }
                Continue();
            });
        }
Exemple #4
0
        /// <summary>
        /// Parse and execute a conversation string
        /// </summary>
        /// <param name="conv"></param>
        public IEnumerator DoConversation(string conv)
        {
            if (string.IsNullOrEmpty(conv))
            {
                yield break;
            }

            var conversationItems = Parse(conv);

            if (conversationItems.Count == 0)
            {
                yield break;
            }

            // Track the current and previous parameter values
            Character     currentCharacter  = null;
            Sprite        currentPortrait   = null;
            RectTransform currentPosition   = null;
            Character     previousCharacter = null;

            // Play the conversation
            for (int i = 0; i < conversationItems.Count; ++i)
            {
                ConversationItem item = conversationItems[i];

                if (item.Character != null)
                {
                    currentCharacter = item.Character;
                }

                currentPortrait = item.Portrait;
                currentPosition = item.Position;

                SayDialog sayDialog = GetSayDialog(currentCharacter);

                if (sayDialog == null)
                {
                    // Should never happen
                    yield break;
                }

                sayDialog.gameObject.SetActive(true);

                if (currentCharacter != null &&
                    currentCharacter != previousCharacter)
                {
                    sayDialog.SetCharacter(currentCharacter);
                }

                var stage = Stage.GetActiveStage();

                if (stage != null && currentCharacter != null &&
                    (currentPortrait != currentCharacter.state.portrait ||
                     currentPosition != currentCharacter.state.position))
                {
                    var portraitOptions = new PortraitOptions(true);
                    portraitOptions.display      = item.Hide ? DisplayType.Hide : DisplayType.Show;
                    portraitOptions.character    = currentCharacter;
                    portraitOptions.fromPosition = currentCharacter.state.position;
                    portraitOptions.toPosition   = currentPosition;
                    portraitOptions.portrait     = currentPortrait;

                    // Do a move tween if the character is already on screen and not yet at the specified position
                    if (currentCharacter.state.onScreen &&
                        currentPosition != currentCharacter.state.position)
                    {
                        portraitOptions.move = true;
                    }

                    if (item.Hide)
                    {
                        stage.Hide(portraitOptions);
                    }
                    else
                    {
                        stage.Show(portraitOptions);
                    }
                }

                if (stage == null &&
                    currentPortrait != null)
                {
                    sayDialog.SetCharacterImage(currentPortrait);
                }

                previousCharacter = currentCharacter;

                if (!string.IsNullOrEmpty(item.Text))
                {
                    exitSayWait = false;
                    sayDialog.Say(item.Text, true, true, true, false, null, () => {
                        exitSayWait = true;
                    });

                    while (!exitSayWait)
                    {
                        yield return(null);
                    }
                    exitSayWait = false;
                }
            }
        }
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            // Override the active say dialog if needed
            if (setSayDialog != null)
            {
                SayDialog.activeSayDialog = setSayDialog;
            }

            SayDialog sayDialog = SayDialog.GetSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            Flowchart flowchart = GetFlowchart();

            sayDialog.SetCharacter(character, flowchart);
            sayDialog.SetCharacterImage(portrait);

            bool fadingIn = false;
            bool movingIn = false;

            if (sayDialog.alwaysFadeDialog || fadeIn)
            {
                sayDialog.FadeInDialog();
                fadingIn = true;
            }
            if (sayDialog.alwaysMoveDialog)
            {
                sayDialog.MoveInDialog();
                movingIn = true;
            }
            if (!fadingIn && !movingIn)
            {
                sayDialog.ShowDialog(true);
            }

            if (voiceOverClip != null)
            {
                sayDialog.PlayVoiceOver(voiceOverClip);
            }

            string displayText = storyText;

            foreach (CustomTag ct in CustomTag.activeCustomTags)
            {
                displayText = displayText.Replace(ct.tagStartSymbol, ct.replaceTagStartWith);
                if (ct.tagEndSymbol != "" && ct.replaceTagEndWith != "")
                {
                    displayText = displayText.Replace(ct.tagEndSymbol, ct.replaceTagEndWith);
                }
            }

            if (extendPrevious)
            {
                displayText = "{s=0}" + Dialog.prevStoryText + "{/s}" + displayText;
            }

            string subbedText = flowchart.SubstituteVariables(displayText);

            sayDialog.Say(subbedText, waitForClick, delegate {
                if (waitForClick)
                {
                    bool fadingOut = false;
                    bool movingOut = false;
                    if (sayDialog.alwaysFadeDialog || fadeOut)
                    {
                        sayDialog.FadeOutDialog();
                        fadingOut = true;
                    }
                    if (sayDialog.alwaysMoveDialog)
                    {
                        sayDialog.MoveOutDialog();
                        movingOut = true;
                    }
                    if (!fadingOut && !movingOut)
                    {
                        sayDialog.ShowDialog(false);
                    }
                }
                Continue();
            });
        }
Exemple #6
0
 public virtual void SayAndContinue(SayDialog sayDialog, string text)
 {
     sayDialog.Say(text, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate {
         Continue();
     });
 }
Exemple #7
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            showBasicGUI = false;
            if (sayDialog == null)
            {
                // Try to get game's default SayDialog
                sayDialog = GetFungusScript().defaultSay;

                if (sayDialog == null)
                {
                    // Try to get any SayDialog in the scene
                    sayDialog = GameObject.FindObjectOfType <SayDialog>();
                }
                if (sayDialog == null)
                {
                    // No custom dialog box exists, just use basic gui
                    showBasicGUI = true;
                    return;
                }
            }

            FungusScript fungusScript = GetFungusScript();

            sayDialog.SetCharacter(character, fungusScript);
            sayDialog.SetCharacterImage(portrait);

            if (fadeIn)
            {
                sayDialog.FadeInDialog();
            }
            else
            {
                sayDialog.ShowDialog(true);
            }

            if (voiceOverClip != null)
            {
                sayDialog.PlayVoiceOver(voiceOverClip);
            }

            string extendedStoryText = storyText;

            if (extendPrevious)
            {
                extendedStoryText = "{s=0}" + Dialog.prevStoryText + "{/s}" + storyText;
            }

            string subbedText = fungusScript.SubstituteVariables(extendedStoryText);

            sayDialog.Say(subbedText, delegate {
                if (fadeOut)
                {
                    sayDialog.FadeOutDialog();
                }
                else
                {
                    sayDialog.ShowDialog(false);
                }
                Continue();
            });
        }