private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, global::System.Action onComplete)
        {
            OnLineStart();

            string text = localisationProvider.GetLocalisedTextForLine(line);

            // Sanity check
            if (text == null)
            {
                Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
                text = line.ID;
            }

            SeparateNameAndDialogue(text, out string characterStyleName, out string characterName, out string characterDialogue);

            OnLineStyleUpdated(characterStyleName);
            OnNameLineUpdate(characterName);
            OnDialogueLineUpdate(characterDialogue);

            while (!RequestedNextLine)
            {
                yield return(null);
            }
            RequestedNextLine = false;

            yield return(new WaitForEndOfFrame());

            OnLineEnd();

            onComplete();
        }
Beispiel #2
0
        public static DLine FromYarnLine(Yarn.Line line)
        {
            float speed      = 0.025f;
            float jitter     = 0;
            bool  pause      = true;
            bool  clear_text = true;
            float wait       = 0;

            Match  m    = re.Match(line.text);
            string face = m.Groups[3].Value;

            if (face.Equals(""))
            {
                face = "Neutral";
            }
            // Convert text to title case
            face = textInfo.ToTitleCase(face.Trim().ToLower());

            // Convert flags section to dictionary
            string flags_string = m.Groups[5].Value;

            if (!flags_string.Equals(""))
            {
                Match flags_match;
                // speed
                flags_match = new Regex(@"speed\s*=\s*([\d\.]+)", RegexOptions.IgnoreCase).Match(flags_string);
                if (flags_match.Success)
                {
                    speed = float.Parse(flags_match.Groups[1].Value);
                }
                // jitter
                flags_match = new Regex(@"jitter\s*=\s*([\d\.]+)", RegexOptions.IgnoreCase).Match(flags_string);
                if (flags_match.Success)
                {
                    jitter = float.Parse(flags_match.Groups[1].Value);
                }
                // wait
                flags_match = new Regex(@"wait\s*=\s*([\d\.]+)", RegexOptions.IgnoreCase).Match(flags_string);
                if (flags_match.Success)
                {
                    wait = float.Parse(flags_match.Groups[1].Value);
                }

                // pause
                flags_match = new Regex(@"nopause", RegexOptions.IgnoreCase).Match(flags_string);
                if (flags_match.Success)
                {
                    pause = false;
                }
                // clear_text
                flags_match = new Regex(@"nocleartext", RegexOptions.IgnoreCase).Match(flags_string);
                if (flags_match.Success)
                {
                    clear_text = false;
                }
            }

            return(new DLine(m.Groups[1].Value.Trim(), face, m.Groups[6].Value.Trim(),
                             wait: wait, speed: speed, jitter: jitter, pause: pause, clear_text: clear_text));
        }
Beispiel #3
0
 /// Runs a line.
 /// <inheritdoc/>
 public override Dialogue.HandlerExecutionType RunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onLineComplete)
 {
     // Start displaying the line; it will call onComplete later
     // which will tell the dialogue to continue
     StartCoroutine(DoRunLine(line, localisationProvider, onLineComplete));
     return(Dialogue.HandlerExecutionType.PauseExecution);
 }
Beispiel #4
0
 public override Dialogue.HandlerExecutionType RunLine(Yarn.Line line, IDictionary <string, string> strings, System.Action onComplete)
 {
     // Start displaying the line; it will call onComplete later
     // which will tell the dialogue to continue
     StartCoroutine(DoRunLine(line, strings, onComplete));
     return(Dialogue.HandlerExecutionType.PauseExecution);
 }
Beispiel #5
0
        /// Show a line of dialogue, gradually
        private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, Action onComplete)
        {
            onLineStart?.Invoke();

            // The final text we'll be showing for this line.
            string text = localisationProvider.GetLocalisedTextForLine(line);

            if (text == null)
            {
                Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
                text = line.ID;
            }
            else if (text[0] == LineStartPlaceHolder)
            {
                text = text.Remove(0, 1);
            }

            if (textSpeed > 0.0f && !proceedToNextLine)
            {
                IDialogueText completeText = ComplexDialogueText.AnalyzeText(text, RunLineLogger);

                foreach (string currentText in completeText.Parse())
                {
                    LineUpdate(currentText);
                    if (proceedToNextLine)
                    {
                        // We've requested a skip of the entire line.
                        // Display all of the text immediately.
                        LineUpdate(text);
                        break;
                    }
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the entire line immediately if textSpeed <= 0
                LineUpdate(text);
            }

            // We're now waiting for the player to move on to the next line
            proceedToNextLine = false;

            // Indicate to the rest of the game that the line has finished being delivered
            LineFinishDisplaying();

            while (!proceedToNextLine)
            {
                yield return(CheckContinue());
            }

            // Avoid skipping lines if textSpeed == 0
            yield return(new WaitForEndOfFrame());

            // Hide the text and prompt
            LineEnd();

            onComplete();
        }
Beispiel #6
0
        /// Show a line of dialogue, gradually
        private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete)
        {
            onLineStart?.Invoke();

            userRequestedNextLine = false;

            // The final text we'll be showing for this line.
            string text = localisationProvider.GetLocalisedTextForLine(line);

            if (text == null)
            {
                Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
                text = line.ID;
            }

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in text)
                {
                    stringBuilder.Append(c);
                    onLineUpdate?.Invoke(stringBuilder.ToString());
                    if (userRequestedNextLine)
                    {
                        // We've requested a skip of the entire line.
                        // Display all of the text immediately.
                        onLineUpdate?.Invoke(text);
                        break;
                    }
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the entire line immediately if textSpeed <= 0
                onLineUpdate?.Invoke(text);
            }

            // We're now waiting for the player to move on to the next line
            userRequestedNextLine = false;

            // Indicate to the rest of the game that the line has finished being delivered
            onLineFinishDisplaying?.Invoke();

            while (userRequestedNextLine == false)
            {
                yield return(null);
            }

            // Avoid skipping lines if textSpeed == 0
            yield return(new WaitForEndOfFrame());

            // Hide the text and prompt
            onLineEnd?.Invoke();

            onComplete();
        }
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                displayingLine = true;
                SoundManager.soundManager.PlayLoopingSfx(textSfx);
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    if (skip)
                    {
                        lineText.text = line.text;
                        Input.ResetInputAxes();
                        skip = false;
                        break;
                    }
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
                displayingLine = false;
                SoundManager.soundManager.loopSfx.Stop();
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }

            // Avoid skipping lines if textSpeed == 0
            yield return(new WaitForEndOfFrame());

            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            while (battleContainer.activeInHierarchy == true)
            {
                yield return(null);
            }

            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();
                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    audioManager.PlaySound(dialogueSound);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));

                    if (skipText == true)
                    {
                        break;
                    }
                }
                lineText.text = line.text;
                skipText      = false;
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.GetKeyDown(KeyCode.Return) == false)
            {
                yield return(null);
            }

            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #9
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            string[] lineArray = line.text.Split(':');
            line.text = lineArray[1];
            character = GameObject.Find(lineArray[0]);
            if (character != null)
            {
                balloon = character.transform.Find("Canvas/Balloon").gameObject;
                text    = character.transform.Find("Canvas/Text").gameObject.GetComponent <Text>();
            }

            balloon.SetActive(true);
            text.gameObject.SetActive(true);

            // Show the text

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    text.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                text.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }

            // Hide the text and prompt
            text.gameObject.SetActive(false);
            balloon.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #10
0
        public override LocalizedLine GetLocalizedLine(Yarn.Line line)
        {
            var text = YarnProject.GetLocalization(CurrentTextLanguageCode).GetLocalizedString(line.ID);

            return(new LocalizedLine()
            {
                TextID = line.ID,
                RawText = text,
                Substitutions = line.Substitutions
            });
        }
Beispiel #11
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                writing = true;
                foreach (char c in line.text)
                {
                    if (skipLine == true)
                    {
                        lineText.text = line.text;
                        break;
                    }
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
                writing  = false;
                skipLine = false;
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input  <<-- REPLACE LATER
            while (!Input.GetKeyDown(KeyCode.Space))
            {
                yield return(null);
            }

            // Hide the text and prompt << -- Comment out for now
            //lineText.gameObject.SetActive (false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #12
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            //TalkAnimation
            if (!currentTransform.gameObject.name.Equals("Nehuen"))
            {
                currentTransform.gameObject.GetComponent <Animator>().SetTrigger("Talk");
            }


            // Show the text
            lineText.gameObject.SetActive(true);
            //lineText.text = line.text;

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }

            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #13
0
        // Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed != 0)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    if (Input.anyKeyDown)
                    {
                        yield return(new WaitForSeconds(0.00001f));

                        lineText.text = line.text;
                        break;
                    }
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immedately if textSpeed == 0
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }
            yield return(new WaitForSeconds(0.001f));

            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #14
0
        public IEnumerator RunLine(Yarn.Line line, bool autoAdvance)
        {
            displayStringFull = line.text;
            optionStrings     = new string[0];
            // display dialog
            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();
                inputContinue = false;
                foreach (char c in line.text)
                {
                    float timeWaited = 0f;
                    stringBuilder.Append(c);
                    displayString = stringBuilder.ToString();
                    while (timeWaited < textSpeed)
                    {
                        timeWaited += textSpeed;
                        // early out / skip ahead
                        if (inputContinue)
                        {
                            break;
                        }
                        yield return(new WaitForSeconds(timeWaited));
                    }
                    if (inputContinue)
                    {
                        displayString = line.text; break;
                    }
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                displayString = line.text;
            }

            inputContinue = false;

            // Show the 'press any key' prompt when done, if we have one
            showContinuePrompt = true;

            // Wait for any user input
            while (inputContinue == false && autoAdvance == false)
            {
                yield return(new WaitForSeconds(0.01f));
            }

            // Hide the text and prompt
            showContinuePrompt = false;
        }
Beispiel #15
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line, Text lineText)
        {
            if (lineText == null)
            {
                lineText = defaultLineText;
            }

            // Replaces variables with their values.
            string moddedLine = CheckVars(line.text);

            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in moddedLine)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = moddedLine;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.GetButtonDown("Fire1") == false)
            {
                yield return(null);
            }

            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #16
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            string reline = line.text;
            string result = reline.Replace("Customer: ", "");

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in result)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = result;
                yield return(new WaitForSeconds(0.0001f));
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            //while (Input.anyKeyDown == false) {
            //while (Input.GetMouseButtonUp(0) == false){
            while (Input.GetKeyDown(KeyCode.JoystickButton1) == false) //X controller
            {
                yield return(null);
            }


            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #17
0
        public override Dialogue.HandlerExecutionType RunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onLineComplete)
        {
            string text = localisationProvider.GetLocalisedTextForLine(line);

            speakerName = Regex.Match(text, @"^.*?(?=:)").Value;

            lastLine    = currentLine;
            currentLine = line;

            // Start displaying the line; it will call onComplete later
            // which will tell the dialogue to continue
            StartCoroutine(DoRunLine(line, localisationProvider, onLineComplete));
            return(Dialogue.HandlerExecutionType.PauseExecution);
        }
Beispiel #18
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            tmPro_lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);

                    tmPro_lineText.text = stringBuilder.ToString();

                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                tmPro_lineText.text = line.text;
            }


            while (m_textLineWaitTime > 0)
            {
                m_textLineWaitTime -= Time.deltaTime;
                yield return(null);
            }

            m_textLineWaitTime = defaultTextLineWaitTime;

            //// Show the 'press any key' prompt when done, if we have one
            //if (continuePrompt != null)
            //    continuePrompt.SetActive(true);

            //// Wait for any user input
            //while (Input.anyKeyDown == false)
            //{
            //    yield return null;
            //}

            tmPro_lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #19
0
        // Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            LineText.gameObject.SetActive(true);
            DialogueContainer.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    LineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                LineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }


            // Wait for any user input
            //while (Input.anyKeyDown == false)
            //{
            //    yield return null;
            //}

            // Wait for user specified seconds
            yield return(new WaitForSeconds(WaitTime));

            // Hide the text and prompt
            LineText.gameObject.SetActive(false);
            DialogueContainer.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #20
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in LocalizationManager.GetTranslation(line.text))
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = LocalizationManager.GetTranslation(line.text);
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }

            // Avoid skipping lines if textSpeed == 0
            yield return(new WaitForEndOfFrame());

            Debug.Log("Hidding Text");
            // Hide the text and prompt
            lineText.gameObject.SetActive(false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                //--------------------------------------------------------------SPEAK-----------------------------
                // Speaker.Speak(line.text, null, null, true, 1, 1, "", 1);
                lineText.text = line.text;
            }

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input
            while (Input.anyKeyDown == false)
            {
                yield return(null);
            }

            // Hide the text and prompt
            // -----------------------|| COMMENTED OUT || -------------------------------------------------------
            //    lineText.gameObject.SetActive (false);

            if (continuePrompt != null)
            {
                continuePrompt.SetActive(false);
            }
        }
Beispiel #22
0
        /// Show a line of dialogue, gradually
        public override IEnumerator RunLine(Yarn.Line line)
        {
            // Show the text
            currentAIBubble = NewBubble(aiBubble, "test");
            //lineText.gameObject.SetActive(true);

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in line.text)
                {
                    stringBuilder.Append(c);
                    lineText.text = stringBuilder.ToString();
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the line immediately if textSpeed == 0
                lineText.text = line.text;
            }
            currentConversation[0].Add(line.text);
            currentConversation[1].Add(currentName);

            // Show the 'press any key' prompt when done, if we have one
            if (continuePrompt != null)
            {
                continuePrompt.SetActive(true);
            }

            // Wait for any user input

            /*
             * while (Input.anyKeyDown == false) {
             *  yield return null;
             * }
             *
             * // Hide the text and prompt
             * lineText.gameObject.SetActive (false);
             *
             * if (continuePrompt != null)
             *  continuePrompt.SetActive (false);
             */
        }
Beispiel #23
0
            public void RunLine(Yarn.Line lineText)
            {
                if (expectedNextLine != null && expectedNextLine != lineText.text)
                {
                    // TODO: Output diagnostic info here
                    Error(string.Format(CultureInfo.CurrentCulture, "Unexpected line.\nExpected: {0}\nReceived: {1}",
                                        expectedNextLine, lineText.text));
                }

                expectedNextLine = null;

                Console.WriteLine(lineText.text);
                if (waitForLines == true)
                {
                    Console.Read();
                }
            }
Beispiel #24
0
        /// Show a line of dialogue, gradually
        private IEnumerator DoRunLine(Yarn.Line line, IDictionary <string, string> strings, System.Action onComplete)
        {
            onLineStart?.Invoke();

            if (strings.TryGetValue(line.ID, out var text) == false)
            {
                Debug.LogWarning($"Line {line.ID} doesn't have any localised text.");
                text = line.ID;
            }

            if (textSpeed > 0.0f)
            {
                // Display the line one character at a time
                var stringBuilder = new StringBuilder();

                foreach (char c in text)
                {
                    stringBuilder.Append(c);
                    onLineUpdate?.Invoke(stringBuilder.ToString());
                    yield return(new WaitForSeconds(textSpeed));
                }
            }
            else
            {
                // Display the entire line immediately if textSpeed <= 0
                onLineUpdate?.Invoke(text);
            }

            waitingForLineContinue = true;

            onLineFinishDisplaying?.Invoke();

            // Wait for any user input
            while (waitingForLineContinue)
            {
                yield return(null);
            }

            // Avoid skipping lines if textSpeed == 0
            yield return(new WaitForEndOfFrame());

            // Hide the text and prompt
            onLineEnd?.Invoke();

            onComplete();
        }
Beispiel #25
0
            public void RunLine(Yarn.Line lineText)
            {
                if (expectedNextLine != null && expectedNextLine != lineText.text)
                {
                    // TODO: Output diagnostic info here
                    Console.WriteLine(string.Format("Unexpected line.\nExpected: {0}\nReceived: {1}",
                                                    expectedNextLine, lineText.text));
                    Environment.Exit(1);
                }

                expectedNextLine = null;

                Console.WriteLine(lineText.text);
                if (waitForLines == true)
                {
                    Console.Read();
                }
            }
Beispiel #26
0
        public override Yarn.Dialogue.HandlerExecutionType RunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, Action onComplete)
        {
            proceedToNextLine = false;

            if (skipDialogue)
            {
                if (AllowSkip)
                {
                    return(Yarn.Dialogue.HandlerExecutionType.ContinueExecution);
                }
                else
                {
                    SkipDialogueEnd();
                }
            }

            // Start displaying the line; it will call onComplete later
            // which will tell the dialogue to continue
            StartCoroutine(DoRunLine(line, localisationProvider, onComplete));
            return(Yarn.Dialogue.HandlerExecutionType.PauseExecution);
        }
        IEnumerator RunLine(Yarn.Line line)
        {
            displayStringFull = line.text;
            optionStrings     = new string[0];

            // Display the line one character at a time
            var stringBuilder = new StringBuilder();

            inputContinue = false;

            foreach (char c in line.text)
            {
                float timeWaited = 0f;
                stringBuilder.Append(c);
                displayString = stringBuilder.ToString();
                while (timeWaited < textSpeed)
                {
                    if (inputContinue)
                    {
                        break;                                    // early out / skip ahead
                    }
                    timeWaited += textSpeed;
                    yield return(new WaitForSeconds(timeWaited));
                }

                if (inputContinue)
                {
                    displayString = line.text;
                    break;
                }
            }

            showContinuePrompt = true;

            // Wait for user input
            inputContinue = false;
            yield return(new WaitWhile(() => !inputContinue && !MerinoPrefs.useAutoAdvance));

            showContinuePrompt = false;
        }
        public override Yarn.Dialogue.HandlerExecutionType RunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onLineComplete)
        {
            var text = localisationProvider.GetLocalisedTextForLine(line);

            if (text.IsNullOrEmpty())
            {
                text = line.ID;
                $"Line {line.ID} doesn't have any localised text".Log();
            }

            if (_line.IsNull())
            {
                _line = new YarnSpinnerDialogueLine();
            }

            _line.text = text;
            _line.RemoveAllListener();
            _line.AddListener(onLineComplete);
            _line.AddListener(_ui.OnLineEnd);
            _ui?.OnLineStart(_line);

            return(Yarn.Dialogue.HandlerExecutionType.PauseExecution);
        }
Beispiel #29
0
 /// Display a line.
 public abstract IEnumerator RunLine(Yarn.Line line);
Beispiel #30
0
 /// Display a line.
 public abstract Dialogue.HandlerExecutionType RunLine(Yarn.Line line, IDictionary <string, string> strings, System.Action onLineComplete);