Skip to content
Snippets Groups Projects
Commit d8887883 authored by Kristýna Janovská's avatar Kristýna Janovská
Browse files

heartbeat works

parent 9f1352d8
No related branches found
No related tags found
No related merge requests found
Pipeline #248670 passed
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
using UnityEngine; using UnityEngine;
   
public class BackgroundAudioController : MonoBehaviour { public class BackgroundAudioController : MonoBehaviour {
[SerializeField] private AudioSource OSTSource; [SerializeField] public AudioSource OSTSource;
[SerializeField] public bool playOST = true; [SerializeField] public bool playOST = true;
   
public static BackgroundAudioController instance; public static BackgroundAudioController instance;
   
private AudioSource currentAudio; public AudioSource currentAudio;
private Coroutine waitForAudioCoroutine; private Coroutine waitForAudioCoroutine;
private Action onAudioEnd; private Action onAudioEnd;
   
......
...@@ -25,9 +25,10 @@ void Start() { ...@@ -25,9 +25,10 @@ void Start() {
void Update() { void Update() {
if (!running) if (!running)
return; return;
if (remainingTime - Time.deltaTime > 0){
if (remainingTime - Time.deltaTime > 0)
remainingTime -= Time.deltaTime; remainingTime -= Time.deltaTime;
PlayHeartbeat();
}
else { else {
remainingTime = 0; remainingTime = 0;
running = false; running = false;
...@@ -54,6 +55,9 @@ private void PlayHeartbeat() { ...@@ -54,6 +55,9 @@ private void PlayHeartbeat() {
if (remainingTime <= fashHeartbeatThreshold) if (remainingTime <= fashHeartbeatThreshold)
source = remainingTime > fashHeartbeatThreshold / 2 ? heartbeatSources[1] : heartbeatSources[2]; 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());
}
} }
} }
...@@ -24573,6 +24573,12 @@ Transform: ...@@ -24573,6 +24573,12 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 937011645} m_PrefabInstance: {fileID: 937011645}
m_PrefabAsset: {fileID: 0} 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 --- !u!4 &939848585 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 4580154537569598494, guid: ea5dbed22855f6643ae5161cc71c250d, m_CorrespondingSourceObject: {fileID: 4580154537569598494, guid: ea5dbed22855f6643ae5161cc71c250d,
...@@ -54089,6 +54095,16 @@ PrefabInstance: ...@@ -54089,6 +54095,16 @@ PrefabInstance:
propertyPath: questField propertyPath: questField
value: value:
objectReference: {fileID: 944964131} 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_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1eb73f1b5311760469cc6e221f2538a9, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 1eb73f1b5311760469cc6e221f2538a9, type: 3}
--- !u!1001 &6819322687301725324 --- !u!1001 &6819322687301725324
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment