Done with Audio Implementation via C# #347

Merged
mushgunAX merged 14 commits from AudioImplementation into main 2023-02-04 10:18:26 +08:00
3 changed files with 39 additions and 14 deletions
Showing only changes of commit 23f7812a70 - Show all commits

View File

@ -12,5 +12,12 @@ namespace SHADE_Scripting.Audio
public static Dictionary<string, AudioClipHandler> audioClipHandlers = new Dictionary<string, AudioClipHandler>();
//Functions here, maybe
public static void stopAllSounds(bool fadeOut)
{
foreach (KeyValuePair<string, AudioClipHandler> h in audioClipHandlers)
{
h.Value.Stop(fadeOut);
}
}
}
}

View File

@ -39,6 +39,23 @@ public class GameManager : Script
public static GameManager Instance { get; private set; }
protected override void start()
{
base.start();
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["BGMAdaptive"].Play();
Audio.SetParameter("Detected", 0.0f);
AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen");
AudioHandler.audioClipHandlers["KitchenAmbience"].Play();
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
}
protected override void awake()
{
if (Instance != null && Instance != this)
@ -46,17 +63,12 @@ public class GameManager : Script
else
Instance = this;
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["BGMAdaptive"].Play();
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
Audio.SetParameter("Detected", 0.0f);
//Audio.PlayBGMOnce2D("event:/Music/player_undetected");
AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen");
AudioHandler.audioClipHandlers["KitchenAmbience"].Play();
//Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
@ -102,18 +114,22 @@ public class GameManager : Script
if ((timer > 0 && totalItemCount < 0) || Input.GetKeyDown(Input.KeyCode.F1))
{
currGameState = GameState.WIN;
Audio.StopAllSounds();
//Audio.StopAllSounds(); //Calling this outright breaks audio clip handlers
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["BGMWin"].Play();
SceneManager.ChangeScene(winScene);
//Audio.PlaySFXOnce2D("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMWin"].Play();
}
else if(timer < 0 || Input.GetKeyDown(Input.KeyCode.F2))
{
currGameState = GameState.LOSE;
Audio.StopAllSounds();
//Audio.StopAllSounds();
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["BGMLose"].Play();
SceneManager.ChangeScene(loseScene);
//Audio.PlaySFXOnce2D("event:/Music/stingers/game_lose");
AudioHandler.audioClipHandlers["BGMLose"].Play();
}
}
}

View File

@ -22,8 +22,9 @@ public class EndScene : Script
if (Input.GetKeyUp(Input.KeyCode.R))
{
//Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.StopAllSounds();
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
Audio.StopAllSounds();
SceneManager.ChangeScene(mainGameScene);
}
@ -35,8 +36,9 @@ public class EndScene : Script
if (Input.GetKeyUp(Input.KeyCode.M))
{
//Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.StopAllSounds();
AudioHandler.stopAllSounds(false);
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
Audio.StopAllSounds();
SceneManager.ChangeScene(mainMainScene);
}