Example #1
0
    public void DisplayNextSentence()
    {
        if (sentences.Count == 0)
        {
            EndDialog();
            return;
        }

        DialogSentence sentence = sentences.Dequeue();

        if (sentence.speaker.characterImage)
        {
            characterSpot.gameObject.SetActive(true);
            characterSpot.sprite = sentence.speaker.characterImage;
        }
        else
        {
            characterSpot.gameObject.SetActive(false);
        }


        nameText.text = sentence.speaker.characterName;

        StartCoroutine(TypeSentence(sentence.sentence));
    }
Example #2
0
    public void DisplayNextSentence()
    {
        if (dialogSentences.Count == 0)
        {
            EndDialog();
            return;
        }

        DialogSentence dialogSentence = dialogSentences.Dequeue();

        //sentencesText.text = dialogSentence.sentence;
        StopAllCoroutines();
        StartCoroutine(TypeSentence(dialogSentence.sentence));

        if (dialogSentence.dialogParticipant == DialogParticipant.NPC)
        {
            nameText.text                 = currentNPCname;
            nameText.alignment            = TextAnchor.MiddleRight;
            charImage.sprite              = currentNPCImage;
            charImage.rectTransform.pivot = new Vector2(0, 0.5f);
        }
        else
        {
            nameText.text                 = playerName;
            nameText.alignment            = TextAnchor.MiddleLeft;
            charImage.sprite              = playerImage;
            charImage.rectTransform.pivot = new Vector2(1, 0.5f);
        }
    }
 void EndDialog()
 {
     //Debug.Log("对话结束");
     sentence = null;
     DialogBox.SetActive(false);
     dialogEnd.Send();
 }
Example #4
0
 private IEnumerator WriteSentece(DialogSentence sentence)
 {
     m_SentenceText.text = string.Empty;
     foreach (char letter in sentence.m_Text.ToCharArray())
     {
         while (Time.timeScale == 0)
         {
             yield return(null);
         }
         m_SentenceText.text += letter;
         yield return(null);
     }
 }
    /// <summary>
    /// 显示句子
    /// </summary>
    public void DisplayNextSentence()
    {
        if (Sentences.Count == 0)
        {
            EndDialog();
            return;
        }
        StopAllCoroutines();

        sentenceEnd  = false;
        sentence     = Sentences.Dequeue();//出队列
        Image.sprite = sentence.portrait;
        Name.text    = sentence.name;
        //Debug.Log("显示下一句");
        StartCoroutine(TypeSentence(sentence.sentence));
    }
Example #6
0
    private IEnumerator WriteSentence(DialogSentence sentence)
    {
        if (m_Audio)
        {
            m_Audio.clip = sentence.m_Voice;
            m_Audio.Play();
        }

        m_MessageUI.text = string.Empty;
        foreach (char letter in sentence.m_Text.ToCharArray())
        {
            while (Time.timeScale == 0)
            {
                yield return(null);
            }
            m_MessageUI.text += letter;
            yield return(null);
        }
    }
Example #7
0
    IEnumerator TypeSequence(DialogSentence sentence)
    {
        if (m_AudioSource)
        {
            m_AudioSource.clip = sentence.Voice;
            m_AudioSource.Play();
        }

        m_DialogText.text = string.Empty;
        foreach (char letter in sentence.Text.ToCharArray())
        {
            while (Time.timeScale == 0)
            {
                yield return(null);
            }

            m_DialogText.text += letter;
            yield return(null);
        }
    }
Example #8
0
    public void NextSentence()
    {
        if (m_AudioSource)
        {
            m_AudioSource.Stop();
        }

        if (m_Sentences.Count == 0)
        {
            EndDialog();
            return;
        }

        DialogSentence sentence = m_Sentences.Dequeue();

        if (m_TypeSentenceCoroutine != null)
        {
            StopCoroutine(m_TypeSentenceCoroutine);
        }

        m_TypeSentenceCoroutine = TypeSequence(sentence);
        StartCoroutine(m_TypeSentenceCoroutine);
    }
Example #9
0
 public Dialog(string id, DialogSentence sentence)
 {
     this.id           = id;
     this.sentences[0] = sentence;
 }