Gardener audio refactor
This commit is contained in:
@@ -28,6 +28,11 @@ public class AppleAudioSource : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Start();
|
||||
}
|
||||
|
||||
public void InitializeAudioSource()
|
||||
{
|
||||
// Route the audio to the correct bus depending on type
|
||||
@@ -37,7 +42,7 @@ public class AppleAudioSource : MonoBehaviour
|
||||
audioSource.outputAudioMixerGroup = _audioMixer.FindMatchingGroups("Critical VO")[0];
|
||||
break;
|
||||
case AppleAudioSource.AudioSourceType.VO:
|
||||
audioSource.outputAudioMixerGroup = _audioMixer.FindMatchingGroups("VO")[0];
|
||||
audioSource.outputAudioMixerGroup = _audioMixer.FindMatchingGroups("Flavor VO")[0];
|
||||
break;
|
||||
case AppleAudioSource.AudioSourceType.SFX:
|
||||
audioSource.outputAudioMixerGroup = _audioMixer.FindMatchingGroups("SFX")[0];
|
||||
|
||||
@@ -7,8 +7,9 @@ using UnityEngine.Audio;
|
||||
public class GardenerAudioController : MonoBehaviour
|
||||
{
|
||||
|
||||
public AudioSource gardenerAudioPlayer;
|
||||
public AudioSource mowerAudioPlayer;
|
||||
public AppleAudioSource gardenerIdleAudioPlayer;
|
||||
public AppleAudioSource gardenerRunningAudioPlayer;
|
||||
public AppleAudioSource mowerAudioPlayer;
|
||||
public AudioResource mowerStartAudio;
|
||||
public AudioResource mowerLoopAudio;
|
||||
public AudioResource gardenerFleeAudioClip;
|
||||
@@ -23,15 +24,11 @@ public class GardenerAudioController : MonoBehaviour
|
||||
{
|
||||
}
|
||||
|
||||
void GardenerIsOnScreen()
|
||||
{
|
||||
Debug.Log("Gardener spotted!");
|
||||
}
|
||||
|
||||
public void StartMowerSound()
|
||||
{
|
||||
mowerAudioPlayer.Play();
|
||||
_eventSource = mowerAudioPlayer.RequestEventHandlers();
|
||||
mowerAudioPlayer.Play(0);
|
||||
_eventSource = mowerAudioPlayer.audioSource.RequestEventHandlers();
|
||||
_eventSource.AudioStopped += PlayMowerLoop;
|
||||
|
||||
}
|
||||
@@ -39,22 +36,22 @@ public class GardenerAudioController : MonoBehaviour
|
||||
private void PlayMowerLoop(object sender, EventArgs e)
|
||||
{
|
||||
_eventSource.AudioStopped -= PlayMowerLoop;
|
||||
mowerAudioPlayer.resource = mowerLoopAudio;
|
||||
mowerAudioPlayer.loop = true;
|
||||
mowerAudioPlayer.Play();
|
||||
mowerAudioPlayer.audioSource.resource = mowerLoopAudio;
|
||||
mowerAudioPlayer.audioSource.loop = true;
|
||||
mowerAudioPlayer.Play(0);
|
||||
}
|
||||
|
||||
public void PlayGardenerVOClip(bool fleeing)
|
||||
{
|
||||
if (gardenerAudioPlayer.isPlaying) { return; }
|
||||
if (gardenerRunningAudioPlayer.audioSource.isPlaying) { return; }
|
||||
if (fleeing) {
|
||||
gardenerAudioPlayer.resource = gardenerFleeAudioClip;
|
||||
gardenerAudioPlayer.Play();
|
||||
gardenerRunningAudioPlayer.audioSource.resource = gardenerFleeAudioClip;
|
||||
gardenerRunningAudioPlayer.Play(1);
|
||||
}
|
||||
if (!fleeing)
|
||||
{
|
||||
gardenerAudioPlayer.resource = gardenerChaseAudioClip;
|
||||
gardenerAudioPlayer.Play();
|
||||
gardenerRunningAudioPlayer.audioSource.resource = gardenerChaseAudioClip;
|
||||
gardenerRunningAudioPlayer.Play(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user