diff --git a/Assets/SZZ/Code/Scripts/BackgroundAudioController.cs b/Assets/SZZ/Code/Scripts/BackgroundAudioController.cs index 13d15ca7144fc3a41192e13ad32033efeb6a423f..2ff07cd63d051b17a5b8db1c333c7dc7ecbbdb40 100644 --- a/Assets/SZZ/Code/Scripts/BackgroundAudioController.cs +++ b/Assets/SZZ/Code/Scripts/BackgroundAudioController.cs @@ -4,12 +4,12 @@ using UnityEngine; public class BackgroundAudioController : MonoBehaviour { - [SerializeField] private AudioSource OSTSource; + [SerializeField] public AudioSource OSTSource; [SerializeField] public bool playOST = true; public static BackgroundAudioController instance; - private AudioSource currentAudio; + public AudioSource currentAudio; private Coroutine waitForAudioCoroutine; private Action onAudioEnd; diff --git a/Assets/SZZ/Code/Scripts/Level/Timer.cs b/Assets/SZZ/Code/Scripts/Level/Timer.cs index 919c76b60ff9534751dba6108bb5fd9ff1b4b60a..19d207bd8fe7abdc25bd8013ef193f3ee1512c4d 100644 --- a/Assets/SZZ/Code/Scripts/Level/Timer.cs +++ b/Assets/SZZ/Code/Scripts/Level/Timer.cs @@ -25,9 +25,10 @@ void Start() { void Update() { if (!running) return; - - if (remainingTime - Time.deltaTime > 0) + if (remainingTime - Time.deltaTime > 0){ remainingTime -= Time.deltaTime; + PlayHeartbeat(); + } else { remainingTime = 0; running = false; @@ -54,6 +55,9 @@ private void PlayHeartbeat() { if (remainingTime <= fashHeartbeatThreshold) source = remainingTime > fashHeartbeatThreshold / 2 ? heartbeatSources[1] : heartbeatSources[2]; - backgroundAudioController.Play(source, () => PlayHeartbeat()); + if(!backgroundAudioController.currentAudio.isPlaying || backgroundAudioController.currentAudio == backgroundAudioController.OSTSource){ + Debug.Log("Play heartbeat"); + backgroundAudioController.Play(source, () => PlayHeartbeat()); + } } } diff --git a/Assets/SZZ/Level/Scenes/building a.unity b/Assets/SZZ/Level/Scenes/building a.unity index b1669a1a149a632c10af143e26b6b56d8ba5ba90..4ed7c97f14d88154b2d700fda7055cfb63ab7e16 100644 --- a/Assets/SZZ/Level/Scenes/building a.unity +++ b/Assets/SZZ/Level/Scenes/building a.unity @@ -24573,6 +24573,12 @@ Transform: type: 3} m_PrefabInstance: {fileID: 937011645} m_PrefabAsset: {fileID: 0} +--- !u!82 &939025055 stripped +AudioSource: + m_CorrespondingSourceObject: {fileID: 6330820103093283617, guid: 1eb73f1b5311760469cc6e221f2538a9, + type: 3} + m_PrefabInstance: {fileID: 6330820102361427840} + m_PrefabAsset: {fileID: 0} --- !u!4 &939848585 stripped Transform: m_CorrespondingSourceObject: {fileID: 4580154537569598494, guid: ea5dbed22855f6643ae5161cc71c250d, @@ -54089,6 +54095,16 @@ PrefabInstance: propertyPath: questField value: objectReference: {fileID: 944964131} + - target: {fileID: 6330820103093283617, guid: 1eb73f1b5311760469cc6e221f2538a9, + type: 3} + propertyPath: m_Volume + value: 0.307 + objectReference: {fileID: 0} + - target: {fileID: 6330820103093283619, guid: 1eb73f1b5311760469cc6e221f2538a9, + type: 3} + propertyPath: currentAudio + value: + objectReference: {fileID: 939025055} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1eb73f1b5311760469cc6e221f2538a9, type: 3} --- !u!1001 &6819322687301725324