Browse Source

Voice over is now cancelled when story progresses to next line

master
chrisgregan 10 years ago
parent
commit
03047fc17f
  1. 2
      Assets/Fungus/Dialog/Scripts/Commands/Choose.cs
  2. 2
      Assets/Fungus/Dialog/Scripts/Commands/Say.cs
  3. 21
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  4. 1
      Assets/Fungus/Dialog/Scripts/SayDialog.cs

2
Assets/Fungus/Dialog/Scripts/Commands/Choose.cs

@ -98,7 +98,7 @@ namespace Fungus
if (voiceOverClip != null) if (voiceOverClip != null)
{ {
MusicController.GetInstance().PlaySound(voiceOverClip, 1f); chooseDialog.PlayVoiceOver(voiceOverClip);
} }
chooseDialog.Choose(chooseText, dialogOptions, timeoutDuration, delegate { chooseDialog.Choose(chooseText, dialogOptions, timeoutDuration, delegate {

2
Assets/Fungus/Dialog/Scripts/Commands/Say.cs

@ -60,7 +60,7 @@ namespace Fungus
if (voiceOverClip != null) if (voiceOverClip != null)
{ {
MusicController.GetInstance().PlaySound(voiceOverClip, 1f); sayDialog.PlayVoiceOver(voiceOverClip);
} }
sayDialog.Say(storyText, delegate { sayDialog.Say(storyText, delegate {

21
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -34,6 +34,8 @@ namespace Fungus
protected bool wasPointerClicked; protected bool wasPointerClicked;
protected AudioSource voiceOverAudio;
protected virtual void LateUpdate() protected virtual void LateUpdate()
{ {
wasPointerClicked = false; wasPointerClicked = false;
@ -210,6 +212,7 @@ namespace Fungus
OnWaitForInputTag(false); OnWaitForInputTag(false);
currentSpeed = writingSpeed; currentSpeed = writingSpeed;
dialogText.Clear(); dialogText.Clear();
StopVoiceOver();
break; break;
case TokenType.WaitOnPunctuation: case TokenType.WaitOnPunctuation:
@ -332,6 +335,24 @@ namespace Fungus
wasPointerClicked = true; wasPointerClicked = true;
} }
} }
public virtual void PlayVoiceOver(AudioClip voiceOverSound)
{
if (voiceOverAudio == null)
{
voiceOverAudio = gameObject.AddComponent<AudioSource>();
}
voiceOverAudio.clip = voiceOverSound;
voiceOverAudio.Play();
}
public virtual void StopVoiceOver()
{
if (voiceOverAudio)
{
Destroy(voiceOverAudio);
}
}
} }
} }

1
Assets/Fungus/Dialog/Scripts/SayDialog.cs

@ -40,6 +40,7 @@ namespace Fungus
ShowContinueImage(true); ShowContinueImage(true);
StartCoroutine(WaitForInput(delegate { StartCoroutine(WaitForInput(delegate {
Clear(); Clear();
StopVoiceOver();
if (onComplete != null) if (onComplete != null)
{ {
onComplete(); onComplete();

Loading…
Cancel
Save