Esempio n. 1
0
        internal static void AddText(GameUi gameUi, string[] newParagraphs, bool isLoading)
        {
            int oldCharacterCount = gameUi.storyText.textInfo.characterCount;

            gameUi.stillRevealingText = true;

            string twoBlankLines = Environment.NewLine + Environment.NewLine;

            string newText = string.Join(twoBlankLines, newParagraphs);

            if (!string.IsNullOrWhiteSpace(gameUi.storyText.text))
            {
                gameUi.storyText.text += twoBlankLines;
            }

            // ADD THE TEXT AND UPDATE THE TEXT COMPONENT.
            gameUi.storyText.text += newText;
            gameUi.storyText.ForceMeshUpdate();

            if (isLoading)
            {
                gameUi.currentCharacterIndex = gameUi.storyText.textInfo.characterInfo.Reverse()
                                               .SkipWhile(c => c.character == '\0')
                                               .SkipWhile(c => c.style != FontStyles.Italic)
                                               .First().index;
            }

            // SKIP THE ACTION TEXT
            gameUi.currentCharacterIndex += gameUi.storyText.textInfo.characterInfo
                                            .Skip(RoundCurrentCharacterIndex(gameUi))
                                            .Count(c => c.style == FontStyles.Italic);

            // START FADING IN **ALL** THE NEW LETTERS.
            // TO START, THIS HIDES THEM, HOPEFULLY BEFORE THE NEXT UPDATE.
            var newLetterIndexes = gameUi.storyText.textInfo.characterInfo
                                   .Select((characterInfo, index) => index)
                                   // NOTE: You HAVE to Select BEFORE you Skip on this command.
                                   // If you Skip first, all of the indexes will be off. :/
                                   .Skip(oldCharacterCount)
                                   .Take(gameUi.storyText.textInfo.characterCount - oldCharacterCount)
                                   .ToArray();

            foreach (var newLetterIndex in newLetterIndexes)
            {
                gameUi.StartCoroutine(FadeInLetter(gameUi, newLetterIndex));
            }

            gameUi.storyText.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);
        }
Esempio n. 2
0
        internal static void ScrollToSmooth(GameUi gameUi, int lineNumber, Line linePos)
        {
            var targetScrollY = ScrollYForLine(gameUi, lineNumber, linePos);

            gameUi.StartCoroutine(ScrollToSmooth(gameUi, targetScrollY));
        }