|
|
@ -15,6 +15,8 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
public float writingSpeed = 60; |
|
|
|
public float writingSpeed = 60; |
|
|
|
public AudioClip writingSound; |
|
|
|
public AudioClip writingSound; |
|
|
|
|
|
|
|
[Range(0,1)] |
|
|
|
|
|
|
|
public float writingVolume = 1f; |
|
|
|
public bool loopWritingSound = true; |
|
|
|
public bool loopWritingSound = true; |
|
|
|
public bool beepPerCharacter = false; |
|
|
|
public bool beepPerCharacter = false; |
|
|
|
public float slowBeepsAt = 10f; |
|
|
|
public float slowBeepsAt = 10f; |
|
|
@ -50,6 +52,9 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
protected AudioSource voiceOverAudio; |
|
|
|
protected AudioSource voiceOverAudio; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The current target writing volume to move towards |
|
|
|
|
|
|
|
protected float targetWritingVolume; |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void LateUpdate() |
|
|
|
protected virtual void LateUpdate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
wasPointerClicked = false; |
|
|
|
wasPointerClicked = false; |
|
|
@ -67,6 +72,30 @@ namespace Fungus |
|
|
|
wasPointerClicked = true; |
|
|
|
wasPointerClicked = true; |
|
|
|
clickCooldownTimer = 0.2f; |
|
|
|
clickCooldownTimer = 0.2f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fade writing sound |
|
|
|
|
|
|
|
AudioSource audio = GetComponent<AudioSource>(); |
|
|
|
|
|
|
|
if (audio != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (audio.volume == 0f && |
|
|
|
|
|
|
|
targetWritingVolume > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
audio.Play(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (targetWritingVolume > audio.volume) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
audio.volume = targetWritingVolume; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
audio.volume = Mathf.MoveTowards(audio.volume, targetWritingVolume, Time.deltaTime * 8f); |
|
|
|
|
|
|
|
if (audio.volume == 0f) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
audio.Stop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void ShowDialog(bool visible) |
|
|
|
public virtual void ShowDialog(bool visible) |
|
|
@ -90,6 +119,18 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void SetTypingSoundVolume(bool audible) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (audible) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
targetWritingVolume = writingVolume; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
targetWritingVolume = 0f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual void FadeInDialog() |
|
|
|
public virtual void FadeInDialog() |
|
|
|
{ |
|
|
|
{ |
|
|
|
LeanTween.cancel(dialogCanvas.gameObject); |
|
|
|
LeanTween.cancel(dialogCanvas.gameObject); |
|
|
@ -271,32 +312,32 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DialogText dialogText = new DialogText(); |
|
|
|
DialogText dialogText = new DialogText(); |
|
|
|
|
|
|
|
dialogText.parentDialog = this; |
|
|
|
dialogText.writingSpeed = writingSpeed; |
|
|
|
dialogText.writingSpeed = writingSpeed; |
|
|
|
dialogText.punctuationPause = punctuationPause; |
|
|
|
dialogText.punctuationPause = punctuationPause; |
|
|
|
dialogText.beepPerCharacter = beepPerCharacter; |
|
|
|
dialogText.beepPerCharacter = beepPerCharacter; |
|
|
|
dialogText.slowBeepsAt = slowBeepsAt; |
|
|
|
dialogText.slowBeepsAt = slowBeepsAt; |
|
|
|
dialogText.fastBeepsAt = fastBeepsAt; |
|
|
|
dialogText.fastBeepsAt = fastBeepsAt; |
|
|
|
|
|
|
|
|
|
|
|
GameObject typingAudio = null; |
|
|
|
AudioSource typingAudio = GetComponent<AudioSource>(); |
|
|
|
if (characterTypingSound != null || writingSound != null) |
|
|
|
if (characterTypingSound != null || writingSound != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typingAudio = new GameObject("WritingSound"); |
|
|
|
|
|
|
|
typingAudio.AddComponent<AudioSource>(); |
|
|
|
|
|
|
|
typingAudio.hideFlags = HideFlags.HideInHierarchy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (characterTypingSound != null) |
|
|
|
if (characterTypingSound != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typingAudio.GetComponent<AudioSource>().clip = characterTypingSound; |
|
|
|
typingAudio.clip = characterTypingSound; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (writingSound != null) |
|
|
|
else if (writingSound != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typingAudio.GetComponent<AudioSource>().clip = writingSound; |
|
|
|
typingAudio.clip = writingSound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
typingAudio.GetComponent<AudioSource>().loop = loopWritingSound; |
|
|
|
typingAudio.loop = loopWritingSound; |
|
|
|
typingAudio.GetComponent<AudioSource>().Play(); |
|
|
|
|
|
|
|
|
|
|
|
// Start at full volume |
|
|
|
|
|
|
|
typingAudio.volume = writingVolume; |
|
|
|
|
|
|
|
SetTypingSoundVolume(true); |
|
|
|
|
|
|
|
|
|
|
|
dialogText.typingAudio = typingAudio.GetComponent<AudioSource>(); |
|
|
|
typingAudio.Play(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (Token token in parser.tokens) |
|
|
|
foreach (Token token in parser.tokens) |
|
|
@ -490,7 +531,7 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
prevStoryText = storyText.text; |
|
|
|
prevStoryText = storyText.text; |
|
|
|
|
|
|
|
|
|
|
|
Destroy(typingAudio); |
|
|
|
SetTypingSoundVolume(false); |
|
|
|
|
|
|
|
|
|
|
|
if (onWritingComplete != null) |
|
|
|
if (onWritingComplete != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|