Esempio n. 1
0
 private void Reset()
 {
     PlayerState           = DialogPlayerState.NotPlaying;
     CurrentSection        = 0;
     CurrentPlaceInSection = 0;
     CurrentSectionText    = string.Empty;
 }
Esempio n. 2
0
    public bool PlayDialog()
    {
        if (IsPlaying || CurrentDialog == null)
        {
            return(false);
        }

        Reset();
        PlayerState = DialogPlayerState.ShouldBePlaying;
        OnStartedPlaying();
        InvokeRepeating("PlayCurrentSection", fadeInTime, fadeInTime);
        return(true);
    }
Esempio n. 3
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++;
        }
    }
Esempio n. 4
0
 public DialogPlayer()
 {
     CurrentSection        = 0;
     CurrentPlaceInSection = 0;
     PlayerState           = DialogPlayerState.NotPlaying;
 }