diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index d1fe0d9..4b1082d 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -113,6 +113,131 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &30160409 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 30160410} + - component: {fileID: 30160411} + m_Layer: 0 + m_Name: menu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &30160410 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 30160409} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 120074943} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &30160411 +AudioSource: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 30160409} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: a90787ea4a183c44699deb2babada64b, type: 3} + m_PlayOnAwake: 0 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &120074942 GameObject: m_ObjectHideFlags: 0 @@ -140,6 +265,7 @@ Transform: m_Children: - {fileID: 1600556434} - {fileID: 801288608} + - {fileID: 30160410} m_Father: {fileID: 734498092} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -608,13 +734,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mixer: {fileID: 24100000, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - maintheme: {fileID: 24500006, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - end: {fileID: 245089854461186482, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} + maintheme: {fileID: 1600556435} + end: {fileID: 0} gameovers: {fileID: 801288609} soundeffects: - {fileID: 1908750963} - {fileID: 368878861} - - {fileID: 801288609} + - {fileID: 1908750963} --- !u!1 &1028937042 GameObject: m_ObjectHideFlags: 0 @@ -959,9 +1085,10 @@ AudioSource: m_GameObject: {fileID: 1600556433} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: c89601ee48d799943a756d1d15cd4954, type: 3} + m_PlayOnAwake: 0 m_Volume: 1 m_Pitch: 1 Loop: 0 diff --git a/Assets/Scenes/TitleScene.unity b/Assets/Scenes/TitleScene.unity index dc13dd9..2bb8a9c 100644 --- a/Assets/Scenes/TitleScene.unity +++ b/Assets/Scenes/TitleScene.unity @@ -113,6 +113,131 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &52367873 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 52367874} + - component: {fileID: 52367875} + m_Layer: 0 + m_Name: menu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &52367874 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 52367873} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 792683703} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!82 &52367875 +AudioSource: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 52367873} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: a90787ea4a183c44699deb2babada64b, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1 &287217883 GameObject: m_ObjectHideFlags: 0 @@ -524,6 +649,7 @@ Transform: m_Children: - {fileID: 923869162} - {fileID: 287217884} + - {fileID: 52367874} m_Father: {fileID: 1926562125} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -564,9 +690,10 @@ AudioSource: m_GameObject: {fileID: 923869161} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 0} - m_PlayOnAwake: 1 + OutputAudioMixerGroup: {fileID: 243359265566762914, guid: efb934a745665924d8c7dd46c0a117ae, + type: 2} + m_audioClip: {fileID: 8300000, guid: c89601ee48d799943a756d1d15cd4954, type: 3} + m_PlayOnAwake: 0 m_Volume: 1 m_Pitch: 1 Loop: 0 @@ -871,10 +998,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mixer: {fileID: 24100000, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - maintheme: {fileID: 24500006, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} - end: {fileID: 245089854461186482, guid: efb934a745665924d8c7dd46c0a117ae, type: 2} + maintheme: {fileID: 923869163} + menutheme: {fileID: 52367875} gameovers: {fileID: 287217885} - soundeffects: [] + soundeffects: + - {fileID: 1187801173} + - {fileID: 987581542} + - {fileID: 429380406} --- !u!1 &1039057777 GameObject: m_ObjectHideFlags: 0 @@ -1360,7 +1490,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: notifications: {fileID: 0} - gameOverPanel: {fileID: 0} + restartUIPanel: {fileID: 0} healthcontroller: {fileID: 0} mainMenuSceneIndex: 0 --- !u!1 &1586619316 @@ -1757,6 +1887,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: notifications: {fileID: 0} - gameOverPanel: {fileID: 0} + restartUIPanel: {fileID: 0} healthcontroller: {fileID: 0} mainMenuSceneIndex: 0 diff --git a/Assets/Scripts/AudioControl.cs b/Assets/Scripts/AudioControl.cs index 2a8246a..67bdb03 100644 --- a/Assets/Scripts/AudioControl.cs +++ b/Assets/Scripts/AudioControl.cs @@ -6,22 +6,50 @@ using UnityEngine.Audio; public class AudioControl : MonoBehaviour { public AudioMixer mixer; - public AudioMixerSnapshot maintheme; - public AudioMixerSnapshot end; + public AudioSource maintheme; + public AudioSource menutheme; public AudioSource gameovers; public AudioSource[] soundeffects; - public enum Sfx { shoot, explosion, mobattack}; + public enum Sfx { shoot, explosion, mobattack }; - private float m_TransitionIn; - private float m_TransitionOut; - private bool endstate; + private const float lvlbgm = 37.879f; + private const float gobgm = 14.406f; + private const float loopdelay = 0.05f; + private bool menu; // Use this for initialization void Start() { - m_TransitionIn = 1.2f; - m_TransitionOut = 0.3f; + maintheme.loop = true; + menutheme.loop = true; + gameovers.loop = true; + } + + private void Update() + { + if (maintheme.time >= maintheme.clip.length - loopdelay) + maintheme.time = lvlbgm; + if (gameovers.time >= gameovers.clip.length - loopdelay) + gameovers.time = gobgm; + } + + public void GameOverBgm() + { + maintheme.Stop(); + gameovers.Play(); + } + + public void MenuBgm() + { + if (gameovers.isPlaying) + gameovers.Stop(); + menutheme.Play(); + } + + public void LevelBgm() + { + maintheme.PlayDelayed(1.3f); } public void SfxPlay(int sound) @@ -42,4 +70,15 @@ public class AudioControl : MonoBehaviour { mixer.SetFloat("masterVolume", Mathf.Clamp(nvol, -80f, 20f)); } + + public void SetBgmVolume(float nvol) + { + mixer.SetFloat("bgmVolume", Mathf.Clamp(nvol, -80f, 20f)); + } + + public void SetSfxVolume(float nvol) + { + mixer.SetFloat("sfxVolume", Mathf.Clamp(nvol, -80f, 20f)); + } } + diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 83e6bce..858231c 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -233,6 +233,7 @@ public class GameController : MonoBehaviour { } private void Starting() { + StartObjective goal = new StartObjective(start, playerPrefab); start.SetObjective(goal); start.OnPlayerEnter(player); @@ -244,6 +245,7 @@ public class GameController : MonoBehaviour { Debug.Log("No Player spawned!"); } finish.SetObjective(new FinishObjective(finish)); + cam.GetComponent().LevelBgm(); } private void Running() { @@ -256,13 +258,12 @@ public class GameController : MonoBehaviour { if ( ui != null ) { Debug.Log("show end UI"); if(endCause == EndedCause.DIED) { - cam.GetComponent().SfxPlay(2); + cam.GetComponent().GameOverBgm(); ui.GetComponent().ShowGameOverUI(); } else if(endCause == EndedCause.WIN) { //cam.GetComponent().SfxPlay(2); ui.GetComponent().ShowWinUI(); } - } else { Debug.Log("No UI specified"); } diff --git a/Assets/sound/AudioMixer.mixer b/Assets/sound/AudioMixer.mixer index b893e4e..de0a079 100644 --- a/Assets/sound/AudioMixer.mixer +++ b/Assets/sound/AudioMixer.mixer @@ -71,6 +71,7 @@ AudioMixerSnapshotController: m_SnapshotID: d3789ccdbdc046a448f1887d94c3f7f5 m_FloatValues: 25123d234de4ec84aafee1d0c380f3ad: 0.025578512 + 7e224658afaf14242ba3996793ac12a1: -7.436929 m_TransitionOverrides: {} --- !u!243 &243067197919102372 AudioMixerGroupController: diff --git a/Assets/sound/main(0.5).wav b/Assets/sound/main(0.5).wav new file mode 100644 index 0000000..390c75c Binary files /dev/null and b/Assets/sound/main(0.5).wav differ diff --git a/Assets/sound/main(0.5).wav.meta b/Assets/sound/main(0.5).wav.meta new file mode 100644 index 0000000..f9da932 --- /dev/null +++ b/Assets/sound/main(0.5).wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: c89601ee48d799943a756d1d15cd4954 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/sound/menuV1.wav b/Assets/sound/menuV1.wav new file mode 100644 index 0000000..83ede20 Binary files /dev/null and b/Assets/sound/menuV1.wav differ diff --git a/Assets/sound/menuV1.wav.meta b/Assets/sound/menuV1.wav.meta new file mode 100644 index 0000000..a7ebd32 --- /dev/null +++ b/Assets/sound/menuV1.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: a90787ea4a183c44699deb2babada64b +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: