diff --git a/Assets/Audio/Master.bank b/Assets/Audio/Master.bank index 21c524fe..49135fbc 100644 Binary files a/Assets/Audio/Master.bank and b/Assets/Audio/Master.bank differ diff --git a/Assets/Audio/Master.strings.bank b/Assets/Audio/Master.strings.bank index 3992afa1..b769c07f 100644 Binary files a/Assets/Audio/Master.strings.bank and b/Assets/Audio/Master.strings.bank differ diff --git a/Assets/Audio/Music.bank b/Assets/Audio/Music.bank index a7a856e5..41112f65 100644 Binary files a/Assets/Audio/Music.bank and b/Assets/Audio/Music.bank differ diff --git a/Assets/Audio/SFX.bank b/Assets/Audio/SFX.bank index d1c9cf58..acf5260a 100644 Binary files a/Assets/Audio/SFX.bank and b/Assets/Audio/SFX.bank differ diff --git a/Assets/Materials/UI/UIMat_Black.shmat b/Assets/Materials/UI/UIMat_Black.shmat index 183b5f26..8451828f 100644 --- a/Assets/Materials/UI/UIMat_Black.shmat +++ b/Assets/Materials/UI/UIMat_Black.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 50110174 - SubPass: UI + SubPass: UI Translucent Properties: data.color: {x: 0, y: 0, z: 0, w: 1} data.textureIndex: 0 diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafChase.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafChase.cs index 2a3647b3..6085c974 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafChase.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafChase.cs @@ -113,7 +113,8 @@ public partial class LeafChase : BehaviourTreeNode if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true) { //AudioHandler.audioClipHandlers["BGMAdpative"].SetParameter("Detected", 0.0f); - Audio.SetParameter("Detected", 0.0f); + //Audio.SetParameter("Detected", 0.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Undetected"); AudioHandler.audioClipHandlers["SFXHumming"].Play(); } SetNodeData("isAlert", false); diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs index ba061972..6199bd19 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafPatrol.cs @@ -245,7 +245,8 @@ public partial class LeafPatrol : BehaviourTreeNode AudioHandler.audioClipHandlers["SFXHumming"].Play(); //AudioHandler.audioClipHandlers["BGMUnalert"].Play(); //AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f); - Audio.SetParameter("Detected", 0.0f); + //Audio.SetParameter("Detected", 0.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Undetected"); } SetNodeData("isAlert", false); } diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs index b2760e4a..c433f912 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs @@ -26,6 +26,7 @@ public partial class LeafSearch : BehaviourTreeNode private Vector3 eyeOffset; private float sightDistance; private GameObject? player; //To be searched for and marked + private bool screamOnce; } //FUNCTIONS HERE @@ -67,7 +68,8 @@ public partial class LeafSearch : BehaviourTreeNode if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true) { //AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 0.0f); - Audio.SetParameter("Detected", 0.0f); + //Audio.SetParameter("Detected", 0.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Undetected"); AudioHandler.audioClipHandlers["SFXHumming"].Play(); reevaluateWaypoint(); } @@ -97,6 +99,7 @@ public partial class LeafSearch : BehaviourTreeNode //Search for player player = GameObject.Find("Player"); + screamOnce = false; //Automatically fail if no player is found if (player == null) @@ -188,31 +191,41 @@ public partial class LeafSearch : BehaviourTreeNode if (GetNodeData("isAlert") == null) { SetNodeData("isAlert", true); + screamOnce = true; //Audio.StopAllSounds(); - AudioHandler.audioClipHandlers["SFXDetectAh"].Play(); + //AudioHandler.audioClipHandlers["SFXDetectAh"].Play(); AudioHandler.audioClipHandlers["SFXDetectSting"].Play(); //AudioHandler.audioClipHandlers["BGMAlert"].Play(); AudioHandler.audioClipHandlers["SFXHumming"].Stop(false); //AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true); //AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f); - Audio.SetParameter("Detected", 1.0f); + //Audio.SetParameter("Detected", 1.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Detected"); } else { if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false) { //Audio.StopAllSounds(); - AudioHandler.audioClipHandlers["SFXDetectAh"].Play(); + screamOnce = true; + //AudioHandler.audioClipHandlers["SFXDetectAh"].Play(); AudioHandler.audioClipHandlers["SFXDetectSting"].Play(); //AudioHandler.audioClipHandlers["BGMAlert"].Play(); AudioHandler.audioClipHandlers["SFXHumming"].Stop(false); //AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true); //AudioHandler.audioClipHandlers["BGMAdaptive"].SetParameter("Detected", 1.0f); - Audio.SetParameter("Detected", 1.0f); + //Audio.SetParameter("Detected", 1.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Detected"); } SetNodeData("isAlert", true); } + if (screamOnce) + { + screamOnce = false; + AudioHandler.audioClipHandlers["SFXDetectAh"].Play(); + } + status = BehaviourTreeNodeStatus.SUCCESS; onExit(BehaviourTreeNodeStatus.SUCCESS); return status; diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index ee974787..d1cb8685 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -83,10 +83,10 @@ public class GameManager : Script protected override void start() { - AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive"); + AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive_new"); AudioHandler.audioClipHandlers["BGMAdaptive"].Play(); - Audio.SetParameter("Detected", 0.0f); + Audio.SetParameterWithLabel("PlayerDetection", "Undetected"); AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen"); AudioHandler.audioClipHandlers["KitchenAmbience"].Play(); @@ -95,18 +95,24 @@ public class GameManager : Script AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f); AudioHandler.audioClipHandlers["SFXHumming"].Play(); - SceneFadeInOut.Instance.CallFadeOut(); + if (SceneFadeInOut.Instance != null) + SceneFadeInOut.Instance.CallFadeOut(); + Application.IsCursorVisible = false; } protected override void update() { if (GamePause || !stealFoodPopUpDone) { + Input.SetMouseCentering(false); + //Application.IsCursorVisible = true; return; } if (currGameState == GameState.START) { + Input.SetMouseCentering(true); + timer -= Time.DeltaTimeF; if(scoreText) scoreText.GetComponent().Text = $"{Score}"; @@ -138,7 +144,8 @@ public class GameManager : Script AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["BGMWin"].Play(); goingToWin = true; - SceneFadeInOut.Instance.CallFadeIn(); + if (SceneFadeInOut.Instance != null) + SceneFadeInOut.Instance.CallFadeIn(); } else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2))) { @@ -146,12 +153,27 @@ public class GameManager : Script AudioHandler.StopAllSounds(false); AudioHandler.audioClipHandlers["BGMLose"].Play(); goingToLose = true; - SceneFadeInOut.Instance.CallFadeIn(); + if (SceneFadeInOut.Instance != null) + SceneFadeInOut.Instance.CallFadeIn(); } } //Handling transitions - if (SceneFadeInOut.Instance.FadeInFinished()) + if (SceneFadeInOut.Instance != null) + { + if (SceneFadeInOut.Instance.FadeInFinished()) + { + if (goingToWin) + { + SceneManager.ChangeScene(winScene); + } + if (goingToLose) + { + SceneManager.ChangeScene(loseScene); + } + } + } + else { if (goingToWin) { diff --git a/Assets/Scripts/UI/SC_ChangeSceneButton.cs b/Assets/Scripts/UI/SC_ChangeSceneButton.cs index 6a51716b..09e4cf5b 100644 --- a/Assets/Scripts/UI/SC_ChangeSceneButton.cs +++ b/Assets/Scripts/UI/SC_ChangeSceneButton.cs @@ -22,22 +22,19 @@ public class ChangeSceneButton : Script { ui.OnRelease.RegisterAction(() => { - if (sceneID != 0) { - Audio.PlaySFXOnce2D("event:/UI/success"); - - Audio.StopAllSounds(); - + Audio.PlaySFXOnce2D("event:/UI/success"); + Audio.StopAllSounds(); + if (SceneFadeInOut.Instance != null) SceneFadeInOut.Instance.CallFadeIn(); - clickedFlag = true; + clickedFlag = true; } }); } else { Debug.LogError("Failed to register button action for ChangeSceneButton."); - } } protected override void update() diff --git a/Assets/Scripts/UI/SC_EndScene.cs b/Assets/Scripts/UI/SC_EndScene.cs index 2117b24a..7d00c334 100644 --- a/Assets/Scripts/UI/SC_EndScene.cs +++ b/Assets/Scripts/UI/SC_EndScene.cs @@ -1,6 +1,7 @@ using System; using SHADE; using SHADE_Scripting.Audio; +using SHADE_Scripting.UI; public class EndScene : Script { @@ -12,6 +13,15 @@ public class EndScene : Script AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element"); AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success"); } + + protected override void start() + { + Input.SetMouseCentering(false); + Debug.Log("EndScene::Start():"); + Application.IsCursorVisible = true; + SceneFadeInOut.Instance.CallFadeOut(); + } + protected override void update() { if (Input.GetKeyDown(Input.KeyCode.R)) diff --git a/Assets/Scripts/UI/SC_MainMenu.cs b/Assets/Scripts/UI/SC_MainMenu.cs index 59b6594e..16c2d593 100644 --- a/Assets/Scripts/UI/SC_MainMenu.cs +++ b/Assets/Scripts/UI/SC_MainMenu.cs @@ -1,6 +1,7 @@ using System; using SHADE; using SHADE_Scripting.Audio; +using SHADE_Scripting.UI; public class MainMenu : Script { @@ -23,6 +24,9 @@ public class MainMenu : Script protected override void start() { + Input.SetMouseCentering(false); + Application.IsCursorVisible = true; + SceneFadeInOut.Instance.CallFadeOut(); } protected override void update() { diff --git a/Assets/Scripts/UI/SC_PauseMenu.cs b/Assets/Scripts/UI/SC_PauseMenu.cs index 8e9ec42c..822c416c 100644 --- a/Assets/Scripts/UI/SC_PauseMenu.cs +++ b/Assets/Scripts/UI/SC_PauseMenu.cs @@ -13,7 +13,8 @@ public class PauseMenu : Script protected override void awake() { - GameManager.Instance.GamePause = false; + if (GameManager.Instance != null) + GameManager.Instance.GamePause = false; if (canvas) { @@ -41,6 +42,8 @@ public class PauseMenu : Script if (GameManager.Instance.GamePause) { GameManager.Instance.GamePause = false; + Input.SetMouseCentering(true); + Application.IsCursorVisible = false; AudioHandler.PauseAllSounds(false); if (gamePauseText) gamePauseText.Enabled = false; @@ -91,6 +94,8 @@ public class PauseMenu : Script if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause && GameManager.Instance.stealFoodPopUpDone) { GameManager.Instance.GamePause = true; + Input.SetMouseCentering(false); + Application.IsCursorVisible = true; AudioHandler.PauseAllSounds(true); if (gamePauseText) gamePauseText.Enabled = true; diff --git a/Assets/Scripts/UI/SC_SceneFadeInOut.cs b/Assets/Scripts/UI/SC_SceneFadeInOut.cs index f4469591..81710f2d 100644 --- a/Assets/Scripts/UI/SC_SceneFadeInOut.cs +++ b/Assets/Scripts/UI/SC_SceneFadeInOut.cs @@ -43,7 +43,6 @@ namespace SHADE_Scripting.UI protected override void start() { - } protected override void update() @@ -56,7 +55,6 @@ namespace SHADE_Scripting.UI if (fadeInTime == 0.0f) { alphaValue = 1.0f; - } else { @@ -64,7 +62,8 @@ namespace SHADE_Scripting.UI } if (alphaValue >= 1.0f) { - alphaValue = 1.0f; + alphaValue = 1.0f; + //GameObject.Parent.SetActive(false); } } @@ -82,8 +81,10 @@ namespace SHADE_Scripting.UI } if (alphaValue <= 0.0f) { - alphaValue = 0.0f; - GameObject.Parent.SetActive(false); + alphaValue = 0.0f; + //This line is to be added so that (because the fade in and out item is usually the front-most UI element) + //the fade in and out UI element does not block functionality of other UI elements + GameObject.Parent.SetActive(false); } } diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp index e02eac50..60b709c2 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp @@ -656,6 +656,15 @@ namespace SHADE } } + void SHAudioSystem::SetParameterWithLabel(const char* path, const char* label) + { + result = fmodStudioSystem->setParameterByNameWithLabel(path, label); + if (result != FMOD_OK) + { + ErrorCheck(); + } + } + void AudioClip::Play() { if(!instance) @@ -734,12 +743,16 @@ namespace SHADE } } - //void AudioClip::SetParameterLabel(const char* paramName, const char* label) - //{ - // if (!instance) - // return; - // instance->setParameterByNameWithLabel(paramName, label); - //} + void AudioClip::SetParameterWithLabel(const char* paramName, const char* label) + { + if (!instance) + return; + FMOD_RESULT result = instance->setParameterByNameWithLabel(paramName, label); + if (result != FMOD_OK) + { + SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result)) + } + } float AudioClip::GetParameterValue(const char* paramName) { diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h index 68942a8e..99ff7953 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.h +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.h @@ -33,7 +33,7 @@ namespace SHADE void SetPause(bool pause); bool IsPaused(); void SetParameter(const char* paramName, float value); - //void SetParameterLabel(const char* paramName, const char* label); + void SetParameterWithLabel(const char* paramName, const char* label); float GetParameterValue(const char* paramName); float GetVolume(); void SetVolume(float volume); @@ -94,6 +94,7 @@ namespace SHADE float GetParameterValue(const char* path); void SetParameter(const char* path, float value); + void SetParameterWithLabel(const char* path, const char* label); private: FMOD::Studio::System* fmodStudioSystem; diff --git a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp index a0aaf0fa..a6e506b5 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp @@ -376,7 +376,9 @@ namespace SHADE { if(editor->LoadScene(asset->id)) { +#ifdef SHEDITOR editor->editorConfig->workingSceneID = asset->id; +#endif } } break; diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 346bfbed..6d71f98d 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -592,8 +592,10 @@ namespace SHADE { //Load the scene sceneToLoad = 0; +#ifdef SHEDITOR editorConfig->workingSceneID = assetID; SHConfigurationManager::SaveEditorConfig(); +#endif SHSceneManager::RestartScene(assetID); return true; } diff --git a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp index 078d9fc8..84df5f88 100644 --- a/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp +++ b/SHADE_Engine/src/Graphics/Windowing/SHWindow.cpp @@ -198,7 +198,8 @@ namespace SHADE void SHWindow::SetMouseVisible(bool show) { - ShowCursor(show); + while(GetMouseVisible() != show) + ShowCursor(show); } void SHWindow::SetMousePosition(int x, int y) diff --git a/SHADE_Managed/src/Audio/Audio.cxx b/SHADE_Managed/src/Audio/Audio.cxx index c3994cd4..33cfdd83 100644 --- a/SHADE_Managed/src/Audio/Audio.cxx +++ b/SHADE_Managed/src/Audio/Audio.cxx @@ -124,6 +124,12 @@ namespace SHADE audioSys->SetParameter(Convert::ToNative(path).data(), value); } + void Audio::SetParameterWithLabel(System::String^ path, System::String^ label) + { + auto audioSys = SHSystemManager::GetSystem(); + audioSys->SetParameterWithLabel(Convert::ToNative(path).data(), Convert::ToNative(label).data()); + } + AudioClipHandler Audio::CreateAudioClip(System::String^ path) { auto audioSys = SHSystemManager::GetSystem(); diff --git a/SHADE_Managed/src/Audio/Audio.hxx b/SHADE_Managed/src/Audio/Audio.hxx index 179a3eb7..fa1e97de 100644 --- a/SHADE_Managed/src/Audio/Audio.hxx +++ b/SHADE_Managed/src/Audio/Audio.hxx @@ -105,6 +105,7 @@ namespace SHADE static void SetVCAVolume(System::String^ path, float volume); static float GetParameterValue(System::String^ path); static void SetParameter(System::String^ path, float value); + static void SetParameterWithLabel(System::String^ path, System::String^ label); //to comment ltr static AudioClipHandler CreateAudioClip(System::String^ path); diff --git a/SHADE_Managed/src/Audio/AudioClip.cxx b/SHADE_Managed/src/Audio/AudioClip.cxx index 7ed58714..062b543e 100644 --- a/SHADE_Managed/src/Audio/AudioClip.cxx +++ b/SHADE_Managed/src/Audio/AudioClip.cxx @@ -79,6 +79,11 @@ namespace SHADE NativeObject->SetParameter(Convert::ToNative(paramName).data(), value); } + void AudioClipHandler::SetParameterWithLabel(System::String^ paramName, System::String^ label) + { + NativeObject->SetParameterWithLabel(Convert::ToNative(paramName).data(), Convert::ToNative(label).data()); + } + float AudioClipHandler::GetParameterValue(System::String^ paramName) { return NativeObject->GetParameterValue(Convert::ToNative(paramName).data()); diff --git a/SHADE_Managed/src/Audio/AudioClip.hxx b/SHADE_Managed/src/Audio/AudioClip.hxx index 34e9b4a5..317c5bad 100644 --- a/SHADE_Managed/src/Audio/AudioClip.hxx +++ b/SHADE_Managed/src/Audio/AudioClip.hxx @@ -71,6 +71,7 @@ namespace SHADE void SetPause(bool pause); bool IsPaused(); void SetParameter(System::String^ paramName, float value); + void SetParameterWithLabel(System::String^ paramName, System::String^ label); float GetParameterValue(System::String^ paramName); float GetVolume(); void SetVolume(float volume);