Exemple #1
0
    //Each frame of the behaviour
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        m_TrackBinding = playerData as RPGTalk;
        if (!m_FirstFrameHappened)
        {
            OnBehaviourPlay(playable, info);
            return;
        }



        //for now, we wont support spped changes into timeline
        if (m_TrackBinding.actualTextSpeed != textSpeed)
        {
            m_TrackBinding.actualTextSpeed = textSpeed;
        }

        //The current character will be calculated based on the textspeed and the time of the playable
        float currentChar = m_TrackBinding.actualTextSpeed * (float)playable.GetTime();



        //only change it if there is something new to change and we are not paused
        if (m_TrackBinding.rpgtalkElements.Count > m_TrackBinding.cutscenePosition - 1 &&
            Mathf.Min(currentChar, m_TrackBinding.rpgtalkElements [m_TrackBinding.cutscenePosition - 1].dialogText.Length)
            != m_TrackBinding.currentChar)
        {
            if (!rpgTime || !rpgTime.isPaused)
            {
                m_TrackBinding.currentChar = currentChar;
                m_TrackBinding.PutRightTextToShow();
            }
        }

        //If we reached the final, check if we should pause the timeline until the player finish the talk
        if (playable.GetTime() >= playable.GetDuration() - (double)0.1)
        {
            if (!reachedFinal)
            {
                reachedFinal = true;
                if (pauseUntilTalkEnd)
                {
                    if (!rpgTime)
                    {
                        Debug.LogError("To use the option 'Pause Until Talk End' the RpgTalk must contain a RPGTalkTimeline Component");
                    }
                    else
                    {
                        rpgTime.Pause();
                    }
                }
            }
        }
        else
        {
            reachedFinal = false;
        }
    }