Gardener audio refactor
This commit is contained in:
@@ -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