feat : music manager v0.1
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
public enum WwiseMusicState { Menu, Sane, Staircase, Mad, None};
|
||||
public class Audio_AudioManager : MonoBehaviour
|
||||
{
|
||||
public static Audio_AudioManager Instance;
|
||||
|
||||
private bool isInitialized = false;
|
||||
|
||||
|
||||
|
||||
[Header("Music State variables")]
|
||||
[SerializeField] private AK.Wwise.State MusicGlobal_Menu;
|
||||
[SerializeField] private AK.Wwise.State MusicGlobal_Sane;
|
||||
[SerializeField] private AK.Wwise.State MusicGlobal_Staircase;
|
||||
[SerializeField] private AK.Wwise.State MusicGlobal_Mad;
|
||||
[SerializeField] private AK.Wwise.State MusicGlobal_None;
|
||||
|
||||
private WwiseMusicState currentMusicState;
|
||||
|
||||
[Header("Wwise Music Events")]
|
||||
public AK.Wwise.Event PlayMusic;
|
||||
public AK.Wwise.Event StopMusic;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
SetWwiseMusicState(WwiseMusicState.Sane); //Need to switch if we have a menu music.
|
||||
|
||||
PlayMusic.Post(gameObject);
|
||||
}
|
||||
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
//Singleton Logic
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("AudioManager already exist! Destroying new ibnstance.");
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
if (isInitialized)
|
||||
{
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
SetWwiseMusicState(WwiseMusicState.None);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void SetWwiseMusicState(WwiseMusicState MusicState)
|
||||
{
|
||||
if (MusicState == currentMusicState)
|
||||
{
|
||||
Debug.Log("MusicState is already" + MusicState + ".");
|
||||
return;
|
||||
}
|
||||
switch (MusicState)
|
||||
{
|
||||
default:
|
||||
case (WwiseMusicState.Menu):
|
||||
MusicGlobal_Menu.SetValue();
|
||||
break;
|
||||
case (WwiseMusicState.Sane):
|
||||
MusicGlobal_Sane.SetValue();
|
||||
break;
|
||||
case (WwiseMusicState.Staircase):
|
||||
MusicGlobal_Staircase.SetValue();
|
||||
break;
|
||||
case (WwiseMusicState.Mad):
|
||||
MusicGlobal_Mad.SetValue();
|
||||
break;
|
||||
case (WwiseMusicState.None):
|
||||
MusicGlobal_None.SetValue();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
Debug.Log("New Wwise MusicState" + MusicState + ".");
|
||||
|
||||
currentMusicState = MusicState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53583b7aad5dc7044bbd6c7946fe6999
|
||||
Reference in New Issue
Block a user