diff --git a/Assets/Prefabs/Puzzles/AnneLiseBush.prefab b/Assets/Prefabs/Puzzles/AnneLiseBush.prefab index 7f47ff63..ce823f8e 100644 --- a/Assets/Prefabs/Puzzles/AnneLiseBush.prefab +++ b/Assets/Prefabs/Puzzles/AnneLiseBush.prefab @@ -651,6 +651,7 @@ GameObject: - component: {fileID: 578146208477020881} - component: {fileID: 1193493154550576580} - component: {fileID: 7652960462502122104} + - component: {fileID: 989520896849684110} m_Layer: 0 m_Name: AnneLiseBush m_TagString: Untagged @@ -747,10 +748,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: edc43a9f07fedb44abb68b06c71d17ea, type: 3} m_Name: m_EditorClassIdentifier: '::' - VOPlayer: {fileID: 7652960462502122104} - SFXPlayer: {fileID: 5129281429389775297} + VOPlayer: {fileID: 989520896849684110} + SFXPlayer: {fileID: 2614810362455218124} reactionClipToPlay: {fileID: 0} flashSFXClipToPlay: {fileID: 8300000, guid: 2ac461fcc3f7a014ca716a4f231be004, type: 3} + birdGameStats: {fileID: 0} birdCounterClip: - {fileID: 8300000, guid: 60d02b75b267d5949a36f04bb5dfe409, type: 3} - {fileID: 8300000, guid: 86dc2e8f9a1cf7440adccad824209334, type: 3} @@ -853,6 +855,21 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &989520896849684110 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5943355783477523754} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + priority: 0 --- !u!1 &6948354193133336628 GameObject: m_ObjectHideFlags: 0 @@ -863,6 +880,7 @@ GameObject: m_Component: - component: {fileID: 6330838396794415978} - component: {fileID: 5129281429389775297} + - component: {fileID: 2614810362455218124} m_Layer: 0 m_Name: SFXAudio m_TagString: Untagged @@ -982,6 +1000,21 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &2614810362455218124 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6948354193133336628} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 3 + audioSource: {fileID: 0} + priority: 0 --- !u!1 &7019503702609181254 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Levels/Quarry.unity b/Assets/Scenes/Levels/Quarry.unity index c9eb0c40..efe0062a 100644 --- a/Assets/Scenes/Levels/Quarry.unity +++ b/Assets/Scenes/Levels/Quarry.unity @@ -917,6 +917,22 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &21238932 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 21238920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + clipPriority: 0 + sourcePriority: 0 --- !u!1001 &28205340 PrefabInstance: m_ObjectHideFlags: 0 @@ -3233,7 +3249,7 @@ MonoBehaviour: m_CorrespondingSourceObject: {fileID: 578146208477020881, guid: 9b2926886934b554f9a1727331d34787, type: 3} m_PrefabInstance: {fileID: 661675797} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1638507537} + m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 603ecc4a6ab6bb84c8cb9773fa310b69, type: 3} @@ -441161,9 +441177,6 @@ PrefabInstance: insertIndex: 0 addedObject: {fileID: 1982530897} m_AddedComponents: - - targetCorrespondingSourceObject: {fileID: 5943355783477523754, guid: 9b2926886934b554f9a1727331d34787, type: 3} - insertIndex: -1 - addedObject: {fileID: 1638507543} - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} insertIndex: -1 addedObject: {fileID: 1872179205} @@ -441173,6 +441186,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} insertIndex: -1 addedObject: {fileID: 1872179203} + - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} + insertIndex: -1 + addedObject: {fileID: 1872179206} m_SourcePrefab: {fileID: 100100000, guid: 9b2926886934b554f9a1727331d34787, type: 3} --- !u!1001 &666234666 PrefabInstance: @@ -444156,11 +444172,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 6638967295122936466, guid: f4ac8282240dd544e9a92e7635486fd1, type: 3} m_PrefabInstance: {fileID: 779867978} m_PrefabAsset: {fileID: 0} ---- !u!82 &781815198 stripped -AudioSource: - m_CorrespondingSourceObject: {fileID: 7585931024614860467, guid: ead4e790fa3a1924ebd1586c93cd5479, type: 3} - m_PrefabInstance: {fileID: 1374202465} - m_PrefabAsset: {fileID: 0} --- !u!1 &801067978 stripped GameObject: m_CorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} @@ -444303,6 +444314,22 @@ MonoBehaviour: interactionComplete: m_PersistentCalls: m_Calls: [] +--- !u!114 &801067985 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 801067978} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + clipPriority: 0 + sourcePriority: 0 --- !u!1 &812734406 GameObject: m_ObjectHideFlags: 0 @@ -445271,6 +445298,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} insertIndex: -1 addedObject: {fileID: 801067982} + - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} + insertIndex: -1 + addedObject: {fileID: 801067985} m_SourcePrefab: {fileID: 100100000, guid: 9b2926886934b554f9a1727331d34787, type: 3} --- !u!1001 &845071531 PrefabInstance: @@ -445884,6 +445914,22 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &863771842 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 178369350} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + clipPriority: 0 + sourcePriority: 0 --- !u!1 &871315074 stripped GameObject: m_CorrespondingSourceObject: {fileID: 5383276844808284485, guid: afbb486e5456a20479aee4cf8bc949b6, type: 3} @@ -450600,6 +450646,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} insertIndex: -1 addedObject: {fileID: 2133104408} + - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} + insertIndex: -1 + addedObject: {fileID: 2133104411} m_SourcePrefab: {fileID: 100100000, guid: 9b2926886934b554f9a1727331d34787, type: 3} --- !u!1 &1073425382 GameObject: @@ -451710,6 +451759,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 780600094299918916, guid: 4b7426bc1f8736749b68973653f4dbfb, type: 3} insertIndex: -1 addedObject: {fileID: 21238931} + - targetCorrespondingSourceObject: {fileID: 780600094299918916, guid: 4b7426bc1f8736749b68973653f4dbfb, type: 3} + insertIndex: -1 + addedObject: {fileID: 21238932} m_SourcePrefab: {fileID: 100100000, guid: 4b7426bc1f8736749b68973653f4dbfb, type: 3} --- !u!1 &1106104746 GameObject: @@ -457157,6 +457209,10 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 4188190597242138317, guid: ead4e790fa3a1924ebd1586c93cd5479, type: 3} + propertyPath: sourcePriority + value: 1 + objectReference: {fileID: 0} - target: {fileID: 6199677512542707633, guid: ead4e790fa3a1924ebd1586c93cd5479, type: 3} propertyPath: m_Name value: QuarryAudio @@ -462708,108 +462764,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 5145306031820616614, guid: fbbe1f4baf226904b96f839fe0c00181, type: 3} m_PrefabInstance: {fileID: 1638360119} m_PrefabAsset: {fileID: 0} ---- !u!1 &1638507537 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 5943355783477523754, guid: 9b2926886934b554f9a1727331d34787, type: 3} - m_PrefabInstance: {fileID: 661675797} - m_PrefabAsset: {fileID: 0} ---- !u!82 &1638507543 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1638507537} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_Resource: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1001 &1643200520 PrefabInstance: m_ObjectHideFlags: 0 @@ -468626,6 +468580,22 @@ MonoBehaviour: interactionComplete: m_PersistentCalls: m_Calls: [] +--- !u!114 &1872179206 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1872179199} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + clipPriority: 0 + sourcePriority: 0 --- !u!1 &1877702733 GameObject: m_ObjectHideFlags: 0 @@ -474235,9 +474205,6 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 5172497182660285677, guid: 0c2275f0a1451a142b686a049a2ebcec, type: 3} insertIndex: -1 addedObject: {fileID: 2117822313} - - targetCorrespondingSourceObject: {fileID: 5172497182660285677, guid: 0c2275f0a1451a142b686a049a2ebcec, type: 3} - insertIndex: -1 - addedObject: {fileID: 2117822314} m_SourcePrefab: {fileID: 100100000, guid: 0c2275f0a1451a142b686a049a2ebcec, type: 3} --- !u!4 &2117822311 stripped Transform: @@ -474262,103 +474229,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: AppleHillsScripts::Dialogue.DialogueComponent dialogueGraph: {fileID: 3965311268370046156, guid: ef08ef9a5b2f5064a889414ba2244a62, type: 3} ---- !u!82 &2117822314 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2117822312} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 3533147658878909314, guid: 727a7e4b6df4b0d47897f7d8ee7fa323, type: 2} - m_audioClip: {fileID: 0} - m_Resource: {fileID: 0} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1001 &2122075105 PrefabInstance: m_ObjectHideFlags: 0 @@ -474369,11 +474239,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 1592061707390547073, guid: 7be57ba4ecd292f4c90169045a2d69e4, type: 3} propertyPath: m_LocalPosition.x - value: 7.4399986 + value: 7.439999 objectReference: {fileID: 0} - target: {fileID: 1592061707390547073, guid: 7be57ba4ecd292f4c90169045a2d69e4, type: 3} propertyPath: m_LocalPosition.y - value: 11.469999 + value: 11.47 objectReference: {fileID: 0} - target: {fileID: 1592061707390547073, guid: 7be57ba4ecd292f4c90169045a2d69e4, type: 3} propertyPath: m_LocalPosition.z @@ -475124,6 +474994,22 @@ MonoBehaviour: interactionComplete: m_PersistentCalls: m_Calls: [] +--- !u!114 &2133104411 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2133104404} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 242e6101be071f44fb14c3c12641c833, type: 3} + m_Name: + m_EditorClassIdentifier: AppleHillsScripts::AppleAudioSource + audioSourceType: 0 + audioSource: {fileID: 0} + clipPriority: 0 + sourcePriority: 0 --- !u!4 &2144703707 stripped Transform: m_CorrespondingSourceObject: {fileID: 9067462609398217044, guid: 6cbcaf4eb20e63e4fb462f6fb1ada3a7, type: 3} @@ -475547,6 +475433,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} insertIndex: -1 addedObject: {fileID: 863771839} + - targetCorrespondingSourceObject: {fileID: 1011363502278351410, guid: 9b2926886934b554f9a1727331d34787, type: 3} + insertIndex: -1 + addedObject: {fileID: 863771842} m_SourcePrefab: {fileID: 100100000, guid: 9b2926886934b554f9a1727331d34787, type: 3} --- !u!1001 &2428672463423402429 PrefabInstance: @@ -477469,7 +477358,7 @@ PrefabInstance: - target: {fileID: 1569498917964935965, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} propertyPath: m_SceneBindings.Array.data[12].value value: - objectReference: {fileID: 781815198} + objectReference: {fileID: 0} - target: {fileID: 1569498917964935965, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} propertyPath: m_SceneBindings.Array.data[13].value value: diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index 209daff4..216946e0 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -122,7 +122,7 @@ namespace Dialogue if (clip != null) { appleAudioSource.audioSource.resource = clip; - appleAudioSource.Play(); + appleAudioSource.Play(1); Logging.Debug($"Playing dialogue audio: {clip.name}"); } } diff --git a/Assets/Scripts/Sound/AppleAudioSource.cs b/Assets/Scripts/Sound/AppleAudioSource.cs index 19d74c0f..19896244 100644 --- a/Assets/Scripts/Sound/AppleAudioSource.cs +++ b/Assets/Scripts/Sound/AppleAudioSource.cs @@ -15,8 +15,8 @@ public class AppleAudioSource : MonoBehaviour public AudioSourceType audioSourceType; public AudioSource audioSource; private AudioMixer _audioMixer; - - public int priority; + [HideInInspector ] public int clipPriority; + public int sourcePriority; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() @@ -52,8 +52,9 @@ public class AppleAudioSource : MonoBehaviour } - public void Play() + public void Play(int requestedClipPriority) { + clipPriority = requestedClipPriority; if (audioSourceType == AudioSourceType.CriticalVO || audioSourceType == AudioSourceType.VO) { if (AudioManager.Instance.RequestPlayVO(this)) @@ -62,20 +63,24 @@ public class AppleAudioSource : MonoBehaviour } else { - Debug.Log("AppleAudioSource " + name + " was suppressed because something more important is playing"); + Debug.Log("[AUDIOMANAGER] AppleAudioSource " + name + " was suppressed because something more important is playing"); } } + else + { + audioSource.Play(); + } } public void InterruptAudio(string nameOfInterruptingAudio) { - Debug.Log("AppleAudioSource " + name + " was interrupted by source: " + nameOfInterruptingAudio); Stop(); } public void Stop() - { + { + clipPriority = 0; audioSource.Stop(); } diff --git a/Assets/Scripts/Sound/AudioManager.cs b/Assets/Scripts/Sound/AudioManager.cs index 5e6c2300..a47326e4 100644 --- a/Assets/Scripts/Sound/AudioManager.cs +++ b/Assets/Scripts/Sound/AudioManager.cs @@ -35,6 +35,7 @@ public class AudioManager : MonoBehaviour, IPausable public List SFXSources; private IAudioEventSource _eventSource; + private bool wasInterrupted; /// /// Singleton instance of the AudioManager. @@ -141,33 +142,61 @@ public class AudioManager : MonoBehaviour, IPausable /// public bool RequestPlayVO(AppleAudioSource requestedAudioSource) { - + //Debug.Log($"[AUDIOMANAGER] CurrentVO source prio: {currentlyPlayingVO.sourcePriority}, clip prio: {currentlyPlayingVO.clipPriority} requested VO prio: {requestedAudioSource.sourcePriority}, clip prio: {clipPriority}"); + // If nothing is playing, let the requested audio source play if (currentlyPlayingVO == null) { - currentlyPlayingVO = requestedAudioSource; - Debug.Log($"CurrentVO prio: {currentlyPlayingVO.priority} requested VO prio: {requestedAudioSource.priority}"); - RegisterStartStopEvents(requestedAudioSource.audioSource); + SetupNewAudioSource(requestedAudioSource); + Debug.Log($"[AUDIOMANAGER] Playing {currentlyPlayingVO.name} as nothing is currently playing."); return true; } - if(currentlyPlayingVO.audioSourceType != AppleAudioSource.AudioSourceType.CriticalVO) + // If the requested audio source is the same, interrupt and trigger it again + if (currentlyPlayingVO == requestedAudioSource) + { + InterruptAudioSource(requestedAudioSource); + SetupNewAudioSource(requestedAudioSource); + Debug.Log($"[AUDIOMANAGER] {currentlyPlayingVO.name} is the same as {requestedAudioSource.name}. Triggering it again."); + return true; + + } + // if the currently playing audio source is not critical, interrupt it and play the requested audio source + if (currentlyPlayingVO.audioSourceType != AppleAudioSource.AudioSourceType.CriticalVO) + { + + InterruptAudioSource(requestedAudioSource); + SetupNewAudioSource(requestedAudioSource); + Debug.Log($"[AUDIOMANAGER] {currentlyPlayingVO.name} is not critical. Playing {requestedAudioSource.name} instead because it is critical."); + return true; + } + // If the requested audio source has the same priority as currently playing source, check the priority of the requested clip + if (currentlyPlayingVO.audioSourceType == AppleAudioSource.AudioSourceType.CriticalVO && currentlyPlayingVO.sourcePriority == requestedAudioSource.sourcePriority) + { + if (currentlyPlayingVO.clipPriority > requestedAudioSource.clipPriority) + { + InterruptAudioSource(requestedAudioSource); + SetupNewAudioSource(requestedAudioSource); + Debug.Log($"[AUDIOMANAGER] Interrupted {currentlyPlayingVO.name} because it has same priority as {requestedAudioSource.name} but the requested clip has higher priority"); + + return true; + } + else + { + return false; + } + } + // If the requested audio source has higher priority than the currently playing source, interrupt the current source and let the requested one play + if (currentlyPlayingVO.audioSourceType == AppleAudioSource.AudioSourceType.CriticalVO && currentlyPlayingVO.sourcePriority > requestedAudioSource.sourcePriority) { currentlyPlayingVO.InterruptAudio(requestedAudioSource.name); - currentlyPlayingVO = requestedAudioSource; - Debug.Log($"CurrentVO prio: {currentlyPlayingVO.priority} requested VO prio: {requestedAudioSource.priority}"); - RegisterStartStopEvents(requestedAudioSource.audioSource); - return true; - } - if (currentlyPlayingVO.audioSourceType == AppleAudioSource.AudioSourceType.CriticalVO && currentlyPlayingVO.priority > requestedAudioSource.priority) - { - currentlyPlayingVO.InterruptAudio(requestedAudioSource.name); - Debug.Log($"CurrentVO prio: {currentlyPlayingVO.priority} requested VO prio: {requestedAudioSource.priority}"); - currentlyPlayingVO = requestedAudioSource; - RegisterStartStopEvents(requestedAudioSource.audioSource); + Debug.Log($"[AUDIOMANAGER] Interrupted {currentlyPlayingVO.name} because {requestedAudioSource.name} has higher priority"); + InterruptAudioSource(requestedAudioSource); + SetupNewAudioSource(requestedAudioSource); return true; } + // If the requested audio source didn't clear any of the above cases, tell it to get rekt. else - { - Debug.Log($"CurrentVO prio: {currentlyPlayingVO.priority} requested VO prio: {requestedAudioSource.priority}"); + { + Debug.Log($"[AUDIOMANAGER] {currentlyPlayingVO.name} is still playing. {requestedAudioSource.name} has lower priority"); return false; } } @@ -177,15 +206,16 @@ public class AudioManager : MonoBehaviour, IPausable // TODO: Release the handles safely ReleaseAllHandles(); } - private void RegisterStartStopEvents(AudioSource audioSource) + private void SetupNewAudioSource(AppleAudioSource audioSource) { - if (audioSource.resource == null) + if (audioSource.audioSource.resource == null) { - Debug.Log($"AppleAudioSource {audioSource.name} could not register Start and Stop events."); + Debug.Log($"[AUDIOMANAGER] Faled to setup {audioSource.name}. Invalid resource"); } else { - _eventSource = audioSource.RequestEventHandlers(); + currentlyPlayingVO = audioSource; + _eventSource = audioSource.audioSource.RequestEventHandlers(); _eventSource.AudioStopped += OnAudioStopped; _eventSource.AudioStarted += OnAudioStarted; } @@ -193,14 +223,34 @@ public class AudioManager : MonoBehaviour, IPausable private void OnAudioStopped(object sender, EventArgs e) { - currentlyPlayingVO = null; - _eventSource.AudioStopped -= OnAudioStopped; - _eventSource.AudioStarted -= OnAudioStarted; - + if (wasInterrupted) + { + ResetAudioSource(); + } + else + { + currentlyPlayingVO = null; + ResetAudioSource(); + } } private void OnAudioStarted(object sender, EventArgs e) { } + + private void ResetAudioSource() + { + _eventSource.AudioStopped -= OnAudioStopped; + _eventSource.AudioStarted -= OnAudioStarted; + wasInterrupted = false; + } + + private void InterruptAudioSource(AppleAudioSource newAudioSource) + { + wasInterrupted = true; + currentlyPlayingVO.InterruptAudio(newAudioSource.name); + ResetAudioSource(); + currentlyPlayingVO = newAudioSource; + } } diff --git a/Assets/Scripts/Sound/BushAudioController.cs b/Assets/Scripts/Sound/BushAudioController.cs index 6064e92f..71163db1 100644 --- a/Assets/Scripts/Sound/BushAudioController.cs +++ b/Assets/Scripts/Sound/BushAudioController.cs @@ -8,8 +8,8 @@ using UnityEngine.Audio; public class BushAudioController : MonoBehaviour { private IAudioEventSource _eventSource; - public AudioSource VOPlayer; - public AudioSource SFXPlayer; + public AppleAudioSource VOPlayer; + public AppleAudioSource SFXPlayer; public AudioResource reactionClipToPlay; public AudioResource flashSFXClipToPlay; @@ -22,28 +22,28 @@ public class BushAudioController : MonoBehaviour // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { - _eventSource = VOPlayer.RequestEventHandlers(); + _eventSource = VOPlayer.audioSource.RequestEventHandlers(); _eventSource.AudioStopped += PlayBirdCounter; } public void PlayPhotoSoundBite() { - VOPlayer.resource = reactionClipToPlay; - VOPlayer.Play(); + VOPlayer.audioSource.resource = reactionClipToPlay; + VOPlayer.Play(0); } public void PlayFlashSound() { - SFXPlayer.resource = flashSFXClipToPlay; - SFXPlayer.Play(); + SFXPlayer.audioSource.resource = flashSFXClipToPlay; + SFXPlayer.Play(0); } private void PlayBirdCounter(object sender, EventArgs e) { _eventSource.AudioStopped -= PlayBirdCounter; - VOPlayer.resource = birdCounterClip[birdGameStats.birdsFoundInLevel]; - VOPlayer.Play(); + VOPlayer.audioSource.resource = birdCounterClip[birdGameStats.birdsFoundInLevel]; + VOPlayer.Play(0); birdGameStats.BirdFound(); } diff --git a/Assets/Scripts/Sound/LevelAudioObject.cs b/Assets/Scripts/Sound/LevelAudioObject.cs index 86a4c1ff..ed74b94d 100644 --- a/Assets/Scripts/Sound/LevelAudioObject.cs +++ b/Assets/Scripts/Sound/LevelAudioObject.cs @@ -16,7 +16,7 @@ public class LevelAudioObject : MonoBehaviour void PlayNarrationAudio() { narratorAudioSource.audioSource.resource = firstNarration; - narratorAudioSource.Play(); + narratorAudioSource.Play(0); } } diff --git a/docs/audiomanager_readme.md b/docs/audiomanager_readme.md new file mode 100644 index 00000000..501ea6a1 --- /dev/null +++ b/docs/audiomanager_readme.md @@ -0,0 +1,44 @@ +# Apple Hills Audio Manager +This document describes the classes and functionality of the AudioManager, LevelAudioObject and AppleAudioSource classes and components. + +# AudioManager +The AudioManager is loaded through the bootstrap framework and will be added to every single level and minigame automatically. + +It implements our Singletong framework and you can call functionality on the manager from any script in the project using: +``` +AudioManager.Instance.WhatEverFunctionYouDesire(); +``` + +## General overview +Everything that makes a sound should add the `AppleAudioSource` component. This component automatically adds Unity's own AudioSource that handles playing audio, but wraps it in our own custom class enabling more control over the game's audio assets. +All `AppleAudioSource` assets registers themselves with the `AudioManager` Singleton class that gets loaded in all levels allowing us to control all audio sources without fiddling with every single gameobject that makes sound. +All `AppleAudioSource` assets routes their audio to the AudioMixer which allows us to change the volume on categories of sounds i.e. ambience, music, sound etc. seperately. The AudioMixer also allows us to add effects to every category of sounds seperately and has a Master bus to control the general volume of all sound effects in the game. + +## AudioManager component +![The AudioManager Component.](media/audiomanager_component.png) +The AudioManager component requires only one reference to function: The AudioMixer asset that handles all audio routing and volume mixing of the project. + +### AudioManager options +The AudioManager only has one available option which is how it should handle audio when the game is paused. +**No Audio** pauses all audio sources when Pause is called on the GameManager. +**Play All Audio** ignores Pause completely by using `UnscaledTime`. +**MusicOnly** is still TODO and not fully implemented, but it also sets the mixer to work on `UnscaledTime` and we just need pause all other audio sources when Pause is called on the GameManager. + +### AudioMixer +![The AudioMixer asset controlling all volumes.](media/audiomixer.png) +All AppleAudioSources outputs their audio to the `AppleHillsAudioMix` asset which handles the final volume of all audio sources of the game. +This allows us to expose volume sliders to options, and to tweak the volume of each sound source seperately, add effects like limiters, compressors etc. +**Ambience** is for the atmospheric background audio. Wind in the trees, bird chirps, water burbles etc. Outputs audio to the Master channel. +**SFX** is for smacks, whooshes, and other sound effects. Outputs audio to the Master channel. +**Music** is for.. music.. Outputs audio to the Master channel. +**Voice Over** is the accumulated audio of critical voice-over and flavor VO. Outputs audio to the Master channel. +**Critical VO** is all voice-over that guides the player and is considered more important to hear than everything else in the game. Outputs audio the the Voice Over channel. +**Flavor VO** is voice-over used for jokes, screams etc. and which is considered less important to hear than critical VO. Outputs audio to the Voice Over channel. + + + + + +``` +Some code +``` \ No newline at end of file diff --git a/docs/media/audiomanager_component.png b/docs/media/audiomanager_component.png new file mode 100644 index 00000000..4839fbdb Binary files /dev/null and b/docs/media/audiomanager_component.png differ diff --git a/docs/media/audiomixer.png b/docs/media/audiomixer.png new file mode 100644 index 00000000..9f9fb341 Binary files /dev/null and b/docs/media/audiomixer.png differ