using AudioSourceEvents; using Input; using System; using System.Diagnostics.Tracing; using UnityEngine; using UnityEngine.Audio; using Core; using Core.Lifecycle; using PuzzleS; public class BushAudioController : ManagedBehaviour { private IAudioEventSource _eventSource; public AppleAudioSource VOPlayer; public AppleAudioSource SFXPlayer; public AudioResource reactionClipToPlay; public AudioResource flashSFXClipToPlay; public BirdGameStats birdGameStats; public AudioResource[] birdCounterClip; private int _birdCounter; // Start is called once before the first execution of Update after the MonoBehaviour is created internal override void OnManagedStart() { _eventSource = VOPlayer.audioSource.RequestEventHandlers(); _eventSource.AudioStopped += PlayBirdCounter; } public void PlayPhotoSoundBite() { VOPlayer.audioSource.resource = reactionClipToPlay; VOPlayer.Play(1); } public void PlayFlashSound() { SFXPlayer.audioSource.resource = flashSFXClipToPlay; SFXPlayer.Play(0); } private void PlayBirdCounter(object sender, EventArgs e) { _eventSource.AudioStopped -= PlayBirdCounter; VOPlayer.audioSource.resource = birdCounterClip[birdGameStats.birdsFoundInLevel]; VOPlayer.Play(0); birdGameStats.BirdFound(); } //public void OnDisable() //{ // // Unsubscribe from events when disabled // _eventSource.AudioStopped -= PlayBirdCounter; //} }