Exemple #1
0
    protected virtual void ProgressWriting(bool immediately, float timeStep)
    {
        SpritedStringUI textLineComponent = null;
        int             lineLength        = 0;
        int             totalToReveal     = 0;

        if (pictureObject != null)
        {
            written          = true;
            writeImmediately = false;
            if (autoCloseDuration > 0f)
            {
                autoCloseElapsed = 0f;
            }
        }
        else if (textLineComponents != null)
        {
            if (currentLineIndex < 0)
            {
                currentLineIndex = pageFirstLineIndex;
            }
            if (immediately)
            {
                writeImmediately = true;
            }
            if ((textSpeed == 0f) || writeImmediately)
            {
                if (currentLineIndex > -1)
                {
                    for (int i = currentLineIndex; i < pageLastLineIndex + 1; i++)
                    {
                        if (textLineComponents.Length > i)
                        {
                            textLineComponent = textLineComponents[i];
                            if (textLineComponent != null)
                            {
                                textLineComponent.ToggleAllSymbolVisuals(true);
                            }
                        }
                    }
                }
                written          = true;
                writeImmediately = false;
            }
            else
            {
                if (currentLine == null)
                {
                    if ((currentLineIndex > -1) && (currentLineIndex <= pageLastLineIndex) && (textLineComponents.Length > currentLineIndex))
                    {
                        textLineComponent = textLineComponents[currentLineIndex];
                        if (textLineComponent != null)
                        {
                            lineLength = textLineComponent.GetTotalSymbols();
                            if (lineLength > 0)
                            {
                                currentLine        = textLineComponent;
                                currentSymbolIndex = 0;
                                currentLineLength  = lineLength;
                                textLineComponent.ToggleSymbolVisual(currentSymbolIndex, true);
                                symbolElapsed = 0f;
                            }
                        }
                    }
                    if (currentLine == null)
                    {
                        written = true;
                    }
                }
                else
                {
                    if (ShouldShowImmediately(currentLineIndex))
                    {
                        totalToReveal = currentLineLength;
                    }
                    else
                    {
                        symbolElapsed += textSpeed * timeStep;
                        totalToReveal  = (int)(symbolElapsed / symbolDuration);
                    }
                    if (totalToReveal > 0)
                    {
                        for (int i = totalToReveal; i > 0; i--)
                        {
                            currentSymbolIndex++;
                            if (currentSymbolIndex < currentLineLength)
                            {
                                currentLine.ToggleSymbolVisual(currentSymbolIndex, true);
                            }
                            else
                            {
                                currentLineIndex++;
                                currentLine = null;
                                break;
                            }
                        }
                        symbolElapsed = 0f;
                    }
                }
            }
            if (written)
            {
                if (autoCloseDuration > 0f)
                {
                    autoCloseElapsed = 0f;
                }
            }
        }
    }