Exemple #1
0
        /**
         * Updates the state of the line.
         * This is called every FixedUpdate call by StateHandler.
         */
        public void _FixedUpdate()
        {
            if (minSkipTime > 0f)
            {
                minSkipTime -= Time.deltaTime;
            }

            if (pauseEndTime > 0f)
            {
                pauseEndTime -= Time.deltaTime;
            }

            if (pauseGap)
            {
                if (!pauseIsIndefinite && pauseEndTime <= 0f)
                {
                    EndPause();
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (endTime > 0f)
                {
                    endTime -= Time.deltaTime;
                }
            }

            if (CanScroll())
            {
                if (scrollAmount < 1f)
                {
                    if (!pauseGap)
                    {
                        scrollAmount += KickStarter.speechManager.textScrollSpeed / 100f / log.fullText.Length;
                        if (scrollAmount >= 1f)                         // was >
                        {
                            StopScrolling();
                        }

                        int currentCharIndex = (int)(scrollAmount * log.fullText.Length);
                        if (gapIndex > 0)
                        {
                            currentCharIndex += speechGaps[gapIndex - 1].characterIndex;
                            if (currentCharIndex > log.fullText.Length)
                            {
                                currentCharIndex = log.fullText.Length;
                            }
                        }

                        string newText = GetTextPortion(log.fullText, currentCharIndex);

                        if (displayText != newText && !hasAudio)
                        {
                            KickStarter.dialog.PlayScrollAudio(speaker);
                        }

                        displayText = newText;
                        if (gapIndex >= 0 && speechGaps.Count > gapIndex)
                        {
                            if (currentCharIndex >= speechGaps [gapIndex].characterIndex)                             // was ==
                            {
                                SetPauseGap();
                                return;
                            }
                        }

                        if (continueIndex >= 0)
                        {
                            if (currentCharIndex >= continueIndex)
                            {
                                continueIndex      = -1;
                                continueFromSpeech = true;
                            }
                        }
                    }
                    return;
                }
                displayText = log.fullText;
            }
            else
            {
                if (gapIndex >= 0 && speechGaps.Count >= gapIndex)
                {
                    if (gapIndex == speechGaps.Count)
                    {
                        displayText = log.fullText;
                    }
                    else
                    {
                        float waitTime = (float)speechGaps[gapIndex].waitTime;
                        displayText = log.fullText.Substring(0, speechGaps[gapIndex].characterIndex);

                        if (waitTime >= 0)
                        {
                            pauseEndTime = waitTime;
                            pauseGap     = true;
                        }
                        else if (speechGaps[gapIndex].expressionID >= 0)
                        {
                            speaker.SetExpression(speechGaps [gapIndex].expressionID);
                            gapIndex++;
                        }
                        else
                        {
                            pauseIsIndefinite = true;
                            pauseGap          = true;
                        }
                    }
                }
                else
                {
                    displayText = log.fullText;
                }

                if (continueIndex >= 0)
                {
                    if (continueTime > 0f)
                    {
                        continueFromSpeech = true;
                    }
                }
            }

            if (endTime < 0f)
            {
                if ((KickStarter.speechManager.displayForever && isBackground) ||
                    !KickStarter.speechManager.displayForever)
                {
                    EndMessage();
                }
            }
        }