Commit d0599b57 authored by Tommé Nöll's avatar Tommé Nöll
Browse files

added boss music transitions, not tested yet

parent d08aaab3
......@@ -35,7 +35,7 @@ public class BackgroundMusic : MonoBehaviour {
if (AS[current].timeSamples != preTransitionSample)
{
inTransition = false;
AS[other].volume = 1;
AS[1 - current].volume = 1;
fadePerSecond = -1;
Debug.Log("Music transition complete, playing " + AS[current].clip.name +
"\nSample new: " + AS[current].timeSamples + ", Sample old: " + AS[1-current].timeSamples +
......
......@@ -20,4 +20,11 @@ public class MusicObject : ScriptableObject {
public bool isLoop = false;
[Tooltip("The non-looped version if this song is looped (required), the looped version otherwise (optional).")]
public MusicObject loopCounterpiece;
public MusicObject() {}
public MusicObject(AudioClip clip)
{
this.clip = clip;
isLoop = false;
}
}
......@@ -54,6 +54,8 @@ public class BossAI : MonoBehaviour
//CameraShake der MainCamera
public CameraShake cameraShake;
private BackgroundMusic bgMusic;
//Events, die während des Phasenwechsels screen shake den Bildschirm schwarz und wieder sichtbar machen
public UnityEvent screenShake;
public UnityEvent fadeToBlack;
......@@ -71,7 +73,8 @@ public class BossAI : MonoBehaviour
[SerializeField] private AudioSource audioSource;
[SerializeField] private SoundVolume soundVolumeHit;
[SerializeField] private SoundVolume soundVolumeScream1;
[SerializeField] private SoundVolume soundVolumeScream2;
[SerializeField] private SoundVolume soundVolumeScream2;
[SerializeField] private AudioClip[] music;
private void Awake()
{
......@@ -79,6 +82,7 @@ public class BossAI : MonoBehaviour
health = bossHealth.healthPoints;
player = GameObject.FindGameObjectWithTag("Player");
bgMusic = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<BackgroundMusic>();
shootingPoint = transform.position + horizontalOffset * Vector3.right + verticalOffset * Vector3.up;
......@@ -160,10 +164,12 @@ public class BossAI : MonoBehaviour
if(health == 3)
{
audioSource.PlayOneShot(soundVolumeScream1.clip, soundVolumeScream1.volume);
bgMusic.TransitionTo(new MusicObject(music[1]), 2f);
}
else if(health == 2)
{
audioSource.PlayOneShot(soundVolumeScream2.clip, soundVolumeScream2.volume);
bgMusic.TransitionTo(new MusicObject(music[2]), 2f);
}
yield return new WaitForSeconds(timeBetweenShakeAndFade);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment