Ejemplo n.º 1
0
        public IEnumerator Text(string richText)
        {
            // Announce new ID is typing
            int myTypingId = ++typingId;

            startTyping.Invoke();
            TextComponent.text = string.Empty;

            string plainText = TextUtil.StripTags(richText);

            for (int visibleLength = 1; visibleLength <= plainText.Length; visibleLength++)
            {
                TypingState typingState = new TypingState(richText, visibleLength, plainText);
                float       delay       = GetDelay(typingState) * DelayScale;

                // Finish typing (with cleanup) if delay is 0
                if (delay == 0)
                {
                    break;
                }
                else
                {
                    yield return(YieldUtil.WaitForSecondsScaled(delay, scaledTime));
                }

                // Stop typing if anyone else has started
                if (typingId != myTypingId)
                {
                    yield break;
                }

                TextComponent.text = TextUtil.InsertTagRichText(richText, visibleLength, plainText.Length, "<color=#fff0>", "</color>");
                characterTyped.Invoke(typingState);
            }

            TextComponent.text = richText;
            typingId           = 0;
            finishTyping.Invoke();
        }
Ejemplo n.º 2
0
        public IEnumerator Play(DialogueManager manager, int id)
        {
            foreach (string message in messages)
            {
                yield return(manager.Prompt.Text(message, !automatic));

                if (automatic)
                {
                    yield return(YieldUtil.WaitForSecondsScaled(automaticDelay, useScaledTime));
                }

                if (manager.RunningId != id)
                {
                    yield break;
                }
            }

            if (clearOnFinish)
            {
                yield return(manager.Prompt.Text("", false));
            }
        }