예제 #1
0
        /// <summary>
        /// Writes text using a typewriter effect to a UI text object.
        /// </summary>
        /// <param name="content">Text to be written</param>
        /// <param name="clear">If true clears the previous text.</param>
        /// <param name="waitForInput">Writes the text and then waits for player input before calling onComplete.</param>
        /// <param name="stopAudio">Stops any currently playing audioclip.</param>
        /// <param name="waitForVO">Wait for the Voice over to complete before proceeding</param>
        /// <param name="audioClip">Audio clip to play when text starts writing.</param>
        /// <param name="onComplete">Callback to call when writing is finished.</param>
        public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, System.Action onComplete)
        {
            if (clear)
            {
                textAdapter.Text      = "";
                visibleCharacterCount = 0;
            }

            if (!textAdapter.HasTextObject())
            {
                yield break;
            }

            // If this clip is null then WriterAudio will play the default sound effect (if any)
            NotifyStart(audioClip);

            string tokenText = TextVariationHandler.SelectVariations(content);

            if (waitForInput)
            {
                tokenText += "{wi}";
            }

            if (waitForVO)
            {
                tokenText += "{wvo}";
            }


            List <TextTagToken> tokens = TextTagParser.Tokenize(tokenText);

            gameObject.SetActive(true);

            yield return(StartCoroutine(ProcessTokens(tokens, stopAudio, onComplete)));
        }
예제 #2
0
        public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, AudioClip audioClip, Action onComplete)
        {
            if (clear)
            {
                this.text = "";
            }

            if (!HasTextObject())
            {
                yield break;
            }

            // If this clip is null then WriterAudio will play the default sound effect (if any)
            NotifyStart(audioClip);

            string tokenText = content;

            if (waitForInput)
            {
                tokenText += "{wi}";
            }

            ITextTagParser      tagParser = new TextTagParser();
            List <TextTagToken> tokens    = tagParser.Tokenize(tokenText);

            gameObject.SetActive(true);

            yield return(StartCoroutine(ProcessTokens(tokens, stopAudio, onComplete)));
        }
예제 #3
0
        public virtual void Write(string content, bool clear, bool waitForInput, AudioClip audioClip, Action onComplete)
        {
            if (clear)
            {
                this.text = "";
            }

            if (!HasTextObject())
            {
                return;
            }

            // If this clip is null then WriterAudio will play the default sound effect (if any)
            NotifyStart(audioClip);

            string tokenText = content;

            if (waitForInput)
            {
                tokenText += "{wi}";
            }

            TextTagParser tagParser           = new TextTagParser();
            List <TextTagParser.Token> tokens = tagParser.Tokenize(tokenText);

            StartCoroutine(ProcessTokens(tokens, onComplete));
        }
예제 #4
0
    public void TextTagParser_AudioWaitBug()
    {
        var textTagParser = new TextTagParser();

        // Parse an example string, generate correct sequence of tags
        List<TextTagParser.Token> tokens = textTagParser.Tokenize("Play sound{audio=BeepSound}{w=1} Play loop{audioloop=BeepSound}{w=3} Stop{audiostop=BeepSound}");

        int i = 0;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "Play sound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Audio);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList[0] == "1");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == " Play loop");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioLoop);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList[0] == "3");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == " Stop");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioStop);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        Assert.That(tokens.Count == 8);
    }
예제 #5
0
    public void TextTagParser_Parser()
    {
        var textTagParser = new TextTagParser();

        // Parse an example string, generate correct sequence of tags
        List<TextTagParser.Token> tokens = textTagParser.Tokenize("Words " +
                                                                  "{b}bold test{/b}" +
                                                                  "{i}italic test{/i}" +
                                                                  "{color=red}color test{/color}" +
                                                                  "{w}{w=0.5}" +
                                                                  "{wi}{wc}" +
                                                                  "{wp}{wp=0.5}{/wp}" +
                                                                  "{c}" +
                                                                  "{s}{s=60}{/s}" +
                                                                  "{x}{m=Message}" +
                                                                  "{vpunch=0.5}" +
                                                                  "{hpunch=0.5}" +
                                                                  "{punch=0.5}" +
                                                                  "{flash=0.5}" +
                                                                  "{audio=Sound}" +
                                                                  "{audioloop=Sound}" +
                                                                  "{audiopause=Sound}" +
                                                                  "{audiostop=Sound}");

        int i = 0;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "Words ");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.BoldStart);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "bold test");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.BoldEnd);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.ItalicStart);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "italic test");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.ItalicEnd);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.ColorStart);
        Assert.That(tokens[i].paramList[0] == "red");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "color test");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.ColorEnd);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.WaitForInputNoClear);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.WaitForInputAndClear);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.WaitOnPunctuationStart);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.WaitOnPunctuationStart);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.WaitOnPunctuationEnd);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Clear);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.SpeedStart);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.SpeedStart);
        Assert.That(tokens[i].paramList[0] == "60");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.SpeedEnd);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Exit);
        Assert.That(tokens[i].paramList.Count == 0);

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Message);
        Assert.That(tokens[i].paramList[0] == "Message");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.VerticalPunch);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.HorizontalPunch);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Punch);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Flash);
        Assert.That(tokens[i].paramList[0] == "0.5");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Audio);
        Assert.That(tokens[i].paramList[0] == "Sound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioLoop);
        Assert.That(tokens[i].paramList[0] == "Sound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioPause);
        Assert.That(tokens[i].paramList[0] == "Sound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioStop);
        Assert.That(tokens[i].paramList[0] == "Sound");

        Assert.That(tokens.Count == 31);
    }
예제 #6
0
파일: Writer.cs 프로젝트: nullsquid/Diviner
        public virtual void Write(string content, bool clear, bool waitForInput, AudioClip audioClip, Action onComplete)
        {
            if (clear)
            {
                this.text = "";
            }

            if (!HasTextObject())
            {
                return;
            }

            // If this clip is null then WriterAudio will play the default sound effect (if any)
            NotifyStart(audioClip);

            string tokenText = content;
            if (waitForInput)
            {
                tokenText += "{wi}";
            }

            TextTagParser tagParser = new TextTagParser();
            List<TextTagParser.Token> tokens = tagParser.Tokenize(tokenText);

            StartCoroutine(ProcessTokens(tokens, onComplete));
        }
예제 #7
0
        public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, AudioClip audioClip, Action onComplete)
        {
            if (clear)
            {
                this.text = "";
            }
            
            if (!HasTextObject())
            {
                yield break;
            }

            // If this clip is null then WriterAudio will play the default sound effect (if any)
            NotifyStart(audioClip);

            string tokenText = content;
            if (waitForInput)
            {
                tokenText += "{wi}";
            }

            TextTagParser tagParser = new TextTagParser();
            List<TextTagParser.Token> tokens = tagParser.Tokenize(tokenText);

            gameObject.SetActive(true);

            yield return StartCoroutine(ProcessTokens(tokens, stopAudio, onComplete));
        }