Dynamic BGM

This commit is contained in:
mushgunAX 2023-02-04 00:23:05 +08:00
parent 136d86dce3
commit 49fadfed74
7 changed files with 46 additions and 17 deletions

View File

@ -108,7 +108,6 @@ public partial class Homeowner1 : BehaviourTree
AudioHandler.audioClipHandlers["BGMAlert"] = Audio.CreateAudioClip("event:/Music/player_detected");
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon");
AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected");

View File

@ -112,7 +112,8 @@ public partial class LeafChase : BehaviourTreeNode
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
{
AudioHandler.audioClipHandlers["BGMAdpative"].SetParameter("Detected", 0.0f);
//AudioHandler.audioClipHandlers["BGMAdpative"].SetParameter("Detected", 0.0f);
Audio.SetParameter("Detected", 0.0f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
}
SetNodeData("isAlert", false);

View File

@ -244,7 +244,8 @@ public partial class LeafPatrol : BehaviourTreeNode
//Audio.PlaySFXOnce2D("event:/Homeowner/humming");
AudioHandler.audioClipHandlers["SFXHumming"].Play();
//AudioHandler.audioClipHandlers["BGMUnalert"].Play();
AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
Audio.SetParameter("Detected", 0.0f);
}
SetNodeData("isAlert", false);
}

View File

@ -66,7 +66,8 @@ public partial class LeafSearch : BehaviourTreeNode
{
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
{
AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
Audio.SetParameter("Detected", 0.0f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
reevaluateWaypoint();
}
@ -193,7 +194,8 @@ public partial class LeafSearch : BehaviourTreeNode
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
Audio.SetParameter("Detected", 1.0f);
}
else
{
@ -205,7 +207,8 @@ public partial class LeafSearch : BehaviourTreeNode
//AudioHandler.audioClipHandlers["BGMAlert"].Play();
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
//AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f);
Audio.SetParameter("Detected", 1.0f);
}
SetNodeData("isAlert", true);
}

View File

@ -48,9 +48,15 @@ public class GameManager : Script
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["BGMAdaptive"].Play();
AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
//AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f);
Audio.SetParameter("Detected", 0.0f);
//Audio.PlayBGMOnce2D("event:/Music/player_undetected");
Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
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;
@ -58,6 +64,9 @@ public class GameManager : Script
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose");
}
protected override void update()
@ -95,14 +104,16 @@ public class GameManager : Script
currGameState = GameState.WIN;
Audio.StopAllSounds();
SceneManager.ChangeScene(winScene);
Audio.PlaySFXOnce2D("event:/Music/stingers/game_win");
//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();
SceneManager.ChangeScene(loseScene);
Audio.PlaySFXOnce2D("event:/Music/stingers/game_lose");
//Audio.PlaySFXOnce2D("event:/Music/stingers/game_lose");
AudioHandler.audioClipHandlers["BGMLose"].Play();
}
}
}

View File

@ -1,5 +1,6 @@
using System;
using SHADE;
using SHADE_Scripting.Audio;
public class EndScene : Script
{
@ -8,27 +9,33 @@ public class EndScene : Script
protected override void awake()
{
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
}
protected override void update()
{
if (Input.GetKeyDown(Input.KeyCode.R))
{
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
//Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
}
if (Input.GetKeyUp(Input.KeyCode.R))
{
Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.PlaySFXOnce2D("event:/UI/success");
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
Audio.StopAllSounds();
SceneManager.ChangeScene(mainGameScene);
}
if (Input.GetKeyDown(Input.KeyCode.M))
{
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
//Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
}
if (Input.GetKeyUp(Input.KeyCode.M))
{
Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.PlaySFXOnce2D("event:/UI/success");
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
Audio.StopAllSounds();
SceneManager.ChangeScene(mainMainScene);
}

View File

@ -1,23 +1,30 @@
using System;
using SHADE;
using SHADE_Scripting.Audio;
public class MainMenu : Script
{
public uint sceneID;
protected override void awake()
{
Audio.PlayBGMOnce2D("event:/Music/main_menu");
AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu");
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
//Audio.PlayBGMOnce2D("event:/Music/main_menu");
AudioHandler.audioClipHandlers["BGMMainMenu"].Play();
}
protected override void update()
{
if (Input.GetKeyDown(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
//Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXMouseDownElement"].Play();
}
if (Input.GetKeyUp(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/success");
//Audio.PlaySFXOnce2D("event:/UI/success");
AudioHandler.audioClipHandlers["SFXUISuccess"].Play();
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}