public virtual void Append(string words)
        {
            if (beepPerCharacter && (writingSpeed <= slowBeepsAt || writingSpeed >= fastBeepsAt)) // beeps match character speed at these speeds
                oneBeep = true;
            else
                oneBeep = false;
            if (typingAudio != null)
            {
                typingAudio.Stop();
                if (!oneBeep)
                    typingAudio.Play();
            }

            float hideTimer = 0f;
            if (writingSpeed > 0f)
            {
                hideTimer = 1f / writingSpeed;
            }

            bool doPunctuationPause = false;
            for (int i = 0; i < words.Length; ++i)
            {
                char c = words[i];

                // Ignore leading newlines
                if (glyphs.Count == 0 && c == '\n')
                {
                    continue;
                }

                Glyph glyph = new Glyph();
                glyph.hideTimer = hideTimer;
                if (doPunctuationPause && writingSpeed != 0)
                {
                    glyph.hasPunctuationPause = true;
                    glyph.hideTimer += punctuationPause;
                    doPunctuationPause = false;
                }

                glyph.character = c.ToString();
                glyph.boldActive = boldActive;
                glyph.italicActive = italicActive;
                glyph.colorActive = colorActive;
                glyph.colorText = colorText;
                glyphs.Add(glyph);

                if (IsPunctuation(c)) // If punctuation, do punctuation pause
                {
                    doPunctuationPause = true;
                }

                // Special case: pause just before open parentheses
                if (i < words.Length - 2)
                {
                    if (words[i + 1] == '(')
                    {
                        doPunctuationPause = true;
                    }
                }
            }
        }
Example #2
0
		void AddCharacterGlyph(List<Glyph> glyphList, string character)
		{
			Glyph glyph = new Glyph();
			glyph.type = GlyphType.Character;
			glyph.param = character;
			glyphList.Add(glyph);
		}
Example #3
0
		void AddTagGlyph(List<Glyph> glyphList, string tagText)
		{
			if (tagText.Length < 3 ||
			    tagText.Substring(0,1) != "{" ||
			    tagText.Substring(tagText.Length - 1,1) != "}")
			{
				return;
			}

			string tag = tagText.Substring(1, tagText.Length - 2);

			GlyphType type = GlyphType.Character;
			string paramText = "";

			if (tag == "b")
			{
				type = GlyphType.BoldStart;
			}
			else if (tag == "/b")
			{
				type = GlyphType.BoldEnd;
			}
			else if (tag == "i")
			{
				type = GlyphType.ItalicStart;
			}
			else if (tag == "/i")
			{
				type = GlyphType.ItalicEnd;
			}
			else if (tag.StartsWith("color="))
			{
				type = GlyphType.ColorStart;
				paramText = tag.Substring(6, tag.Length - 6);
			}
			else if (tag == "/color")
			{
				type = GlyphType.ColorEnd;
			}
			else if (tag == "wi")
			{
				type = GlyphType.WaitForInputNoClear;
			}
			if (tag == "wc")
			{
				type = GlyphType.WaitForInputAndClear;
			}
			else if (tag.StartsWith("wp="))
			{
				type = GlyphType.WaitOnPunctuation;
				paramText = tag.Substring(3, tag.Length - 3);
			}
			else if (tag == "wp")
			{
				type = GlyphType.WaitOnPunctuation;
			}
			else if (tag.StartsWith("w="))
			{
				type = GlyphType.Wait;
				paramText = tag.Substring(2, tag.Length - 2);
			}
			else if (tag == "w")
			{
				type = GlyphType.Wait;
			}
			else if (tag == "c")
			{
				type = GlyphType.Clear;
			}
			else if (tag.StartsWith("s="))
			{
				type = GlyphType.Speed;
				paramText = tag.Substring(2, tag.Length - 2);
			}
			else if (tag == "s")
			{
				type = GlyphType.Speed;
			}
			else if (tag == "x")
			{
				type = GlyphType.Exit;
			}

			Glyph glyph = new Glyph();
			glyph.type = type;
			glyph.param = paramText.Trim();

			glyphList.Add(glyph);
		}
Example #4
0
        public virtual void Append(string words)
        {
            AudioSource typingAudio = parentDialog.GetComponent <AudioSource>();

            if (beepPerCharacter && (writingSpeed <= slowBeepsAt || writingSpeed >= fastBeepsAt))             // beeps match character speed at these speeds
            {
                oneBeep = true;
            }
            else
            {
                oneBeep = false;
            }
            if (typingAudio != null)
            {
                typingAudio.Stop();
                if (!oneBeep)
                {
                    typingAudio.Play();
                }
            }

            float hideTimer = 0f;

            if (writingSpeed > 0f)
            {
                hideTimer = 1f / writingSpeed;
            }

            bool doPunctuationPause = false;

            for (int i = 0; i < words.Length; ++i)
            {
                char c = words[i];

                // Ignore leading newlines
                if (glyphs.Count == 0 && c == '\n')
                {
                    continue;
                }

                Glyph glyph = new Glyph();
                glyph.hideTimer = hideTimer;
                if (doPunctuationPause && writingSpeed != 0)
                {
                    glyph.hasPunctuationPause = true;
                    glyph.hideTimer          += punctuationPause;
                    doPunctuationPause        = false;
                }

                glyph.character    = c.ToString();
                glyph.boldActive   = boldActive;
                glyph.italicActive = italicActive;
                glyph.colorActive  = colorActive;
                glyph.colorText    = colorText;
                glyphs.Add(glyph);

                if (IsPunctuation(c))                 // If punctuation, do punctuation pause
                {
                    doPunctuationPause = true;
                }

                // Special case: pause just before open parentheses
                if (i < words.Length - 2)
                {
                    if (words[i + 1] == '(')
                    {
                        doPunctuationPause = true;
                    }
                }
            }
        }