add doug to dialogue, start grandma quest
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
public class DialogueManager : MonoBehaviour
|
||||
{
|
||||
private Queue<string> sentences;
|
||||
private Queue<DialogueLine> sentences;
|
||||
private Dialogue currentDialogue;
|
||||
private DialogueVoice currentDialogueVoice;
|
||||
private float maxDialogueWaitTime = 1.0f;
|
||||
@@ -25,7 +25,7 @@ public class DialogueManager : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
sentences = new Queue<string>();
|
||||
sentences = new Queue<DialogueLine>();
|
||||
voiceSourcePool = GetComponentsInChildren<AudioSource>();
|
||||
}
|
||||
|
||||
@@ -45,9 +45,8 @@ public void StartDialogue(Dialogue dialogue, DialogueVoice dialogueVoice)
|
||||
sentences.Clear();
|
||||
currentDialogue = dialogue;
|
||||
currentDialogueVoice = dialogueVoice;
|
||||
nameText.text = dialogue.charName;
|
||||
|
||||
foreach (string sentence in dialogue.sentences)
|
||||
foreach (DialogueLine sentence in dialogue.sentences)
|
||||
{
|
||||
sentences.Enqueue(sentence);
|
||||
}
|
||||
@@ -64,7 +63,7 @@ public void DisplayNextSentence()
|
||||
return;
|
||||
}
|
||||
|
||||
string sentence = sentences.Dequeue();
|
||||
DialogueLine sentence = sentences.Dequeue();
|
||||
StopAllCoroutines();
|
||||
StopVoices();
|
||||
StartCoroutine(TypeSentence(sentence));
|
||||
@@ -82,34 +81,51 @@ public void EndDialogue()
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator TypeSentence(string sentence)
|
||||
IEnumerator TypeSentence(DialogueLine sentence)
|
||||
{
|
||||
dialogueText.text = "";
|
||||
char[] sentenceCharArray = sentence.ToCharArray();
|
||||
|
||||
if (sentence.isDoug)
|
||||
{
|
||||
nameText.text = "Doug";
|
||||
}
|
||||
else
|
||||
{
|
||||
nameText.text = currentDialogue.charName;
|
||||
}
|
||||
|
||||
char[] sentenceCharArray = sentence.line.ToCharArray();
|
||||
for (int i = 0; i < sentenceCharArray.Length; i++)
|
||||
{
|
||||
dialogueText.text += sentenceCharArray[i];
|
||||
|
||||
if (currentDialogueVoice != null && currentDialogueVoice.voice != Voices.None)
|
||||
if (sentence.isDoug)
|
||||
{
|
||||
if (i % currentDialogueVoice.speechInterval == 0)
|
||||
{
|
||||
AudioClip voiceToPlay = currentDialogueVoice.GetClipFromChar(char.ToLower(sentenceCharArray[i]));
|
||||
|
||||
if (voiceToPlay != null)
|
||||
{
|
||||
PlayNextClip(voiceToPlay);
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(maxDialogueWaitTime - currentDialogueVoice.talkSpeed * maxDialogueWaitTime);
|
||||
// TODO: Add Doug voice
|
||||
yield return new WaitForSeconds(0.03f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Add speed variable to non-voices (Talkable.cs)
|
||||
yield return new WaitForSeconds(0.03f);
|
||||
if (currentDialogueVoice != null && currentDialogueVoice.voice != Voices.None)
|
||||
{
|
||||
if (i % currentDialogueVoice.speechInterval == 0)
|
||||
{
|
||||
AudioClip voiceToPlay = currentDialogueVoice.GetClipFromChar(char.ToLower(sentenceCharArray[i]));
|
||||
|
||||
if (voiceToPlay != null)
|
||||
{
|
||||
PlayNextClip(voiceToPlay);
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(maxDialogueWaitTime - currentDialogueVoice.talkSpeed * maxDialogueWaitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Add speed variable to non-voices (Talkable.cs)
|
||||
yield return new WaitForSeconds(0.03f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user