Beispiel #1
0
    private void SectionStarted(object sender, DialogSection section)
    {
        if (this.DialogSpeakerName == null)
        {
            return;
        }

        this.DialogSpeakerName.text = string.IsNullOrEmpty(section.SpeakerName) ? string.Empty : section.SpeakerName;
        var speakerNameColor = this.defaultSpeakerNameColor;

        if (!string.IsNullOrEmpty(section.SpeakerNameColor))
        {
            if (!ColorUtility.TryParseHtmlString(section.SpeakerNameColor, out speakerNameColor))
            {
                speakerNameColor = this.defaultSpeakerNameColor;
            }
        }
        this.DialogSpeakerName.color = speakerNameColor;
    }
Beispiel #2
0
    void PlayCurrentSection()
    {
        if (PlayerState == DialogPlayerState.ShouldFinishPlaying)
        {
            CancelInvoke("PlayCurrentSection");
            return;
        }
        PlayerState = DialogPlayerState.IsPlaying;
        if (CurrentSection >= CurrentDialog.Sections.Count)
        {
            PlayerState = DialogPlayerState.FinishedPlaying;
            CancelInvoke("PlayCurrentSection");
            return;
        }
        DialogSection ourCurrentSection = CurrentDialog.Sections[CurrentSection];

        if (CurrentPlaceInSection == 0 && ourCurrentSection.SectionText.Length > 0)
        {
            OnSectionStarted(ourCurrentSection);
        }
        if (CurrentPlaceInSection >= ourCurrentSection.SectionText.Length)
        {
            CancelInvoke("PlayCurrentSection");
            CurrentSectionText = ourCurrentSection.SectionText;
            OnTextUpdated(CurrentSectionText);
            OnSectionFinished(ourCurrentSection);

            if (DonePlayingEntireDialog)
            {
                PlayerState             = DialogPlayerState.FinishedPlaying;
                CurrentDialog.HasPlayed = true;
                OnFinishedPlaying();
            }
        }
        else
        {
            CurrentSectionText += ourCurrentSection.SectionText[CurrentPlaceInSection];
            OnTextUpdated(CurrentSectionText);
            CurrentPlaceInSection++;
        }
    }