Added rest of the sequencing
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MusicManager : MonoBehaviour
|
||||
{
|
||||
public enum Track
|
||||
{
|
||||
None,
|
||||
Cozy,
|
||||
Trash,
|
||||
TrashPlusBuilding,
|
||||
TurnAround,
|
||||
TurnAroundPlusJeremyLives,
|
||||
FinaleBuildUp,
|
||||
}
|
||||
|
||||
private Track currentTrack = Track.None;
|
||||
private List<AudioSource> currentlyPlaying = new();
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _CozySource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _TrashSource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _AdditiveBuildingSource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _TurnAroundSource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _AdditiveJeremyLivesSource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource _FinaleBuildUpSource;
|
||||
|
||||
public void PlayMusic(Track track)
|
||||
{
|
||||
switch (track)
|
||||
{
|
||||
case Track.None:
|
||||
break;
|
||||
case Track.Cozy:
|
||||
break;
|
||||
case Track.Trash:
|
||||
break;
|
||||
case Track.TrashPlusBuilding:
|
||||
break;
|
||||
case Track.TurnAround:
|
||||
break;
|
||||
case Track.TurnAroundPlusJeremyLives:
|
||||
break;
|
||||
case Track.FinaleBuildUp:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(track), track, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var fadeMultiplier = 0.2f;
|
||||
|
||||
if(currentTrack == Track.Cozy)
|
||||
{
|
||||
if(!_CozySource.isPlaying)
|
||||
_CozySource.Play();
|
||||
|
||||
_CozySource.volume = Mathf.Clamp(_CozySource.volume + (fadeMultiplier * Time.deltaTime),0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_CozySource.volume = Mathf.Clamp(_CozySource.volume - (fadeMultiplier * Time.deltaTime),0,1);
|
||||
if(_CozySource.volume == 0 && _CozySource.isPlaying)
|
||||
_CozySource.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user