From fd26e1d3ac618fbf259b11e5a017e199911a4891 Mon Sep 17 00:00:00 2001 From: bewe <93899302+bernarduswillson@users.noreply.github.com> Date: Sat, 11 May 2024 06:04:21 +0700 Subject: [PATCH] feat: music and sfx --- Assets/Audio/Effects/GameOver.mp3 | 3 + ...ayerWalking.mp3.meta => GameOver.mp3.meta} | 2 +- Assets/Audio/Effects/KerocoAttack.mp3 | 3 + Assets/Audio/Effects/KerocoAttack.mp3.meta | 23 +++ Assets/Audio/Effects/PlayerWalking.mp3 | 3 - Assets/Audio/Effects/PlayerWalking.wav | 3 + Assets/Audio/Effects/PlayerWalking.wav.meta | 23 +++ Assets/Audio/Effects/Reload.mp3 | 3 + Assets/Audio/Effects/Reload.mp3.meta | 23 +++ Assets/Audio/Effects/StageGateOpen.mp3 | 3 + Assets/Audio/Effects/StageGateOpen.mp3.meta | 23 +++ Assets/Scenes/InitialStage.unity | 171 +++++++++++++++++- Assets/Scenes/MainMenu.unity | 145 ++++++++++++++- Assets/Script/Audio/AudioManager.cs | 22 ++- .../Bot/Enemy/Slave/SlaveAttackState.cs | 5 + Assets/Script/Menu/GameOver.cs | 40 +++- Assets/Script/Menu/StatisticsMenu.cs | 15 +- Assets/Script/Player/PlayerMotor.cs | 20 +- Assets/Script/Weapon/GunSystem.cs | 1 + 19 files changed, 515 insertions(+), 16 deletions(-) create mode 100644 Assets/Audio/Effects/GameOver.mp3 rename Assets/Audio/Effects/{PlayerWalking.mp3.meta => GameOver.mp3.meta} (91%) create mode 100644 Assets/Audio/Effects/KerocoAttack.mp3 create mode 100644 Assets/Audio/Effects/KerocoAttack.mp3.meta delete mode 100644 Assets/Audio/Effects/PlayerWalking.mp3 create mode 100644 Assets/Audio/Effects/PlayerWalking.wav create mode 100644 Assets/Audio/Effects/PlayerWalking.wav.meta create mode 100644 Assets/Audio/Effects/Reload.mp3 create mode 100644 Assets/Audio/Effects/Reload.mp3.meta create mode 100644 Assets/Audio/Effects/StageGateOpen.mp3 create mode 100644 Assets/Audio/Effects/StageGateOpen.mp3.meta diff --git a/Assets/Audio/Effects/GameOver.mp3 b/Assets/Audio/Effects/GameOver.mp3 new file mode 100644 index 00000000..92fe6247 --- /dev/null +++ b/Assets/Audio/Effects/GameOver.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb83d906d5ba94a943c2939a9be2ab13a419e14d25e5c4c2f76e7a173b39a2b2 +size 130961 diff --git a/Assets/Audio/Effects/PlayerWalking.mp3.meta b/Assets/Audio/Effects/GameOver.mp3.meta similarity index 91% rename from Assets/Audio/Effects/PlayerWalking.mp3.meta rename to Assets/Audio/Effects/GameOver.mp3.meta index 43fcf00f..cce2e647 100644 --- a/Assets/Audio/Effects/PlayerWalking.mp3.meta +++ b/Assets/Audio/Effects/GameOver.mp3.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7bc5171ae192e0845a7d0057d5945ef7 +guid: 8d70cf2a6e18357419c92cb875f95d54 AudioImporter: externalObjects: {} serializedVersion: 7 diff --git a/Assets/Audio/Effects/KerocoAttack.mp3 b/Assets/Audio/Effects/KerocoAttack.mp3 new file mode 100644 index 00000000..a463efd1 --- /dev/null +++ b/Assets/Audio/Effects/KerocoAttack.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5a605434f5c8efbf38b752ffedd8f5f7be10064f66bb6ffaf358e40294a1fb2 +size 42240 diff --git a/Assets/Audio/Effects/KerocoAttack.mp3.meta b/Assets/Audio/Effects/KerocoAttack.mp3.meta new file mode 100644 index 00000000..6ab0b8af --- /dev/null +++ b/Assets/Audio/Effects/KerocoAttack.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 9adee4b2a70b7614196bb6a4ac0e3eca +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Effects/PlayerWalking.mp3 b/Assets/Audio/Effects/PlayerWalking.mp3 deleted file mode 100644 index ad3eeefb..00000000 --- a/Assets/Audio/Effects/PlayerWalking.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9efb0ca21d180b251fe49fe73cca08091ebeabc29a4fe3ea2d21c5ae41404727 -size 127680 diff --git a/Assets/Audio/Effects/PlayerWalking.wav b/Assets/Audio/Effects/PlayerWalking.wav new file mode 100644 index 00000000..51d35ffc --- /dev/null +++ b/Assets/Audio/Effects/PlayerWalking.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8df1ee4133fc84fc985b3d768c22d167d6eab3cdda7e11231ad21e5afdd555c6 +size 1438600 diff --git a/Assets/Audio/Effects/PlayerWalking.wav.meta b/Assets/Audio/Effects/PlayerWalking.wav.meta new file mode 100644 index 00000000..7fb792df --- /dev/null +++ b/Assets/Audio/Effects/PlayerWalking.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: e3e15cd03d8218442a2109470ddcfbf1 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Effects/Reload.mp3 b/Assets/Audio/Effects/Reload.mp3 new file mode 100644 index 00000000..2727856a --- /dev/null +++ b/Assets/Audio/Effects/Reload.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3cf5150ecdc6647f2090d77d88753cc1fc1a6cabd6fd5322a2730b5c83c0406d +size 43610 diff --git a/Assets/Audio/Effects/Reload.mp3.meta b/Assets/Audio/Effects/Reload.mp3.meta new file mode 100644 index 00000000..2acfed25 --- /dev/null +++ b/Assets/Audio/Effects/Reload.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: e558b838e86de3e41bb7d7fdfd763433 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Effects/StageGateOpen.mp3 b/Assets/Audio/Effects/StageGateOpen.mp3 new file mode 100644 index 00000000..e2ad254a --- /dev/null +++ b/Assets/Audio/Effects/StageGateOpen.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35156067e4fac8446524ae6d1d57380ab256d56888b104338d736f0b70a7a207 +size 178992 diff --git a/Assets/Audio/Effects/StageGateOpen.mp3.meta b/Assets/Audio/Effects/StageGateOpen.mp3.meta new file mode 100644 index 00000000..bd9180a2 --- /dev/null +++ b/Assets/Audio/Effects/StageGateOpen.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 4180cb94f640cb142a68e726710399be +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/InitialStage.unity b/Assets/Scenes/InitialStage.unity index 24ed9672..26af4a05 100644 --- a/Assets/Scenes/InitialStage.unity +++ b/Assets/Scenes/InitialStage.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 1610145832} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_IndirectSpecularColor: {r: 0.10502498, g: 0.13485196, b: 0.1344606, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &4 LightmapSettings: @@ -18982,6 +18982,11 @@ PrefabInstance: propertyPath: gameOverText value: objectReference: {fileID: 417251660} + - target: {fileID: 82616962848050741, guid: 51cde55a2a5a5c3448cd8df1ab6225dd, + type: 3} + propertyPath: FadeOutCanvas + value: + objectReference: {fileID: 1569198931} - target: {fileID: 82616962848050741, guid: 51cde55a2a5a5c3448cd8df1ab6225dd, type: 3} propertyPath: enemiesKilled @@ -27060,6 +27065,169 @@ Transform: type: 3} m_PrefabInstance: {fileID: 236231240} m_PrefabAsset: {fileID: 0} +--- !u!1 &1569198931 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1569198938} + - component: {fileID: 1569198937} + - component: {fileID: 1569198936} + - component: {fileID: 1569198935} + - component: {fileID: 1569198934} + - component: {fileID: 1569198933} + - component: {fileID: 1569198932} + m_Layer: 5 + m_Name: FadeOut + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!95 &1569198932 +Animator: + serializedVersion: 5 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_Enabled: 1 + m_Avatar: {fileID: 0} + m_Controller: {fileID: 9100000, guid: 77d810e151cf1b843b841ae5fc4e3b67, type: 2} + m_CullingMode: 0 + m_UpdateMode: 0 + m_ApplyRootMotion: 0 + m_LinearVelocityBlending: 0 + m_StabilizeFeet: 0 + m_WarningMessage: + m_HasTransformHierarchy: 1 + m_AllowConstantClipSamplingOptimization: 1 + m_KeepAnimatorStateOnDisable: 0 + m_WriteDefaultValuesOnDisable: 0 +--- !u!114 &1569198933 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1569198934 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_CullTransparentMesh: 1 +--- !u!114 &1569198935 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1569198936 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &1569198937 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1569198938 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1569198931} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!1 &1570661766 GameObject: m_ObjectHideFlags: 0 @@ -37121,4 +37289,5 @@ SceneRoots: - {fileID: 673463553} - {fileID: 3430071858454212807} - {fileID: 700541618} + - {fileID: 1569198938} - {fileID: 1433040718} diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index c4c8a5dc..e05543e1 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -5770,7 +5770,7 @@ AudioSource: m_PlayOnAwake: 1 m_Volume: 1 m_Pitch: 1 - Loop: 0 + Loop: 1 Mute: 0 Spatialize: 0 SpatializePostEffects: 0 @@ -6136,6 +6136,134 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1035812643} m_CullTransparentMesh: 1 +--- !u!1 &1065634208 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1065634210} + - component: {fileID: 1065634209} + m_Layer: 0 + m_Name: Player SFX Source + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!82 &1065634209 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1065634208} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + 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!4 &1065634210 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1065634208} + serializedVersion: 2 + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1196416683} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1067131836 GameObject: m_ObjectHideFlags: 0 @@ -7094,6 +7222,8 @@ MonoBehaviour: clip: {fileID: 8300000, guid: 2cdc839e83c059143877eaa41d3af757, type: 3} - name: Stage clip: {fileID: 8300000, guid: ec63382be8c7ec743b171a0dc777d134, type: 3} + - name: Safehouse + clip: {fileID: 8300000, guid: a0d8574371bc61745828d0d989d84525, type: 3} sfxSounds: - name: OceanAmbience clip: {fileID: 8300000, guid: 20b7f9ab362cd9141a1534895361b4b0, type: 3} @@ -7103,8 +7233,20 @@ MonoBehaviour: clip: {fileID: 8300000, guid: b8654be2210e6b747a8e874def97db7b, type: 3} - name: OrbPickUp clip: {fileID: 8300000, guid: a4a9327e98855524c846cc8e2f559e96, type: 3} + - name: Reload + clip: {fileID: 8300000, guid: e558b838e86de3e41bb7d7fdfd763433, type: 3} + - name: GateOpen + clip: {fileID: 8300000, guid: 4180cb94f640cb142a68e726710399be, type: 3} + - name: KerocoAttack + clip: {fileID: 8300000, guid: 9adee4b2a70b7614196bb6a4ac0e3eca, type: 3} + - name: GameOver + clip: {fileID: 8300000, guid: 8d70cf2a6e18357419c92cb875f95d54, type: 3} + playerSFXSounds: + - name: Walk + clip: {fileID: 8300000, guid: e3e15cd03d8218442a2109470ddcfbf1, type: 3} musicSource: {fileID: 1017079008} sfxSource: {fileID: 47066810} + playerSFXSource: {fileID: 1065634209} sfxGlobalVolume: 1 --- !u!4 &1196416683 Transform: @@ -7121,6 +7263,7 @@ Transform: m_Children: - {fileID: 1017079009} - {fileID: 47066811} + - {fileID: 1065634210} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1203143355 diff --git a/Assets/Script/Audio/AudioManager.cs b/Assets/Script/Audio/AudioManager.cs index c5171abd..b99e94e5 100644 --- a/Assets/Script/Audio/AudioManager.cs +++ b/Assets/Script/Audio/AudioManager.cs @@ -7,8 +7,8 @@ public class AudioManager : MonoBehaviour { public static AudioManager instance; - public Sound[] musicSounds, sfxSounds; - public AudioSource musicSource, sfxSource; + public Sound[] musicSounds, sfxSounds, playerSFXSounds; + public AudioSource musicSource, sfxSource, playerSFXSource; public float sfxGlobalVolume = 1f; @@ -147,6 +147,23 @@ public class AudioManager : MonoBehaviour Destroy(tempAudio, s.clip.length + 0.1f); } + public void PlayPlayerSFX(string name) + { + Sound s = Array.Find(playerSFXSounds, sound => sound.name == name); + if (s == null) + { + Debug.LogWarning("Sound: " + name + " not found!"); + return; + } + + playerSFXSource.PlayOneShot(s.clip); + } + + public void StopPlayerSFX() + { + playerSFXSource.Stop(); + } + public void MusicVolume(float volume) { musicSource.volume = volume; @@ -156,5 +173,6 @@ public class AudioManager : MonoBehaviour { sfxGlobalVolume = Mathf.Clamp01(volume); sfxSource.volume = sfxGlobalVolume; + playerSFXSource.volume = sfxGlobalVolume; } } \ No newline at end of file diff --git a/Assets/Script/Bot/Enemy/Slave/SlaveAttackState.cs b/Assets/Script/Bot/Enemy/Slave/SlaveAttackState.cs index 641f3c33..824731ca 100644 --- a/Assets/Script/Bot/Enemy/Slave/SlaveAttackState.cs +++ b/Assets/Script/Bot/Enemy/Slave/SlaveAttackState.cs @@ -15,6 +15,11 @@ public class SlaveAttackState : StateMachineBehaviour player = GameObject.FindGameObjectWithTag("Player").transform; agent = animator.GetComponent<NavMeshAgent>(); GameObject.FindGameObjectWithTag("SlaveHand").gameObject.GetComponent<Collider>().enabled = true; + + if (!player.gameObject.GetComponent<PlayerHealth>().isDead) + { + AudioManager.instance.PlaySoundAtPosition("KerocoAttack", agent.transform.position); + } } override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) diff --git a/Assets/Script/Menu/GameOver.cs b/Assets/Script/Menu/GameOver.cs index 673524f4..27557c71 100644 --- a/Assets/Script/Menu/GameOver.cs +++ b/Assets/Script/Menu/GameOver.cs @@ -24,6 +24,8 @@ public class GameOver : MonoBehaviour public TextMeshProUGUI distance; public TextMeshProUGUI playTime; + public GameObject FadeOutCanvas; + void Update() { gold.text = GlobalPreference.Instance.GetPlayerGold().ToString(); @@ -32,8 +34,20 @@ public class GameOver : MonoBehaviour damageDealt.text = GlobalPreference.Instance.GetDamageDealt().ToString(); - float accuracyValue = (GlobalPreference.Instance.GetBulletHit() / GlobalPreference.Instance.GetBulletShot()) * 100; - string formattedAccuracy = accuracyValue.ToString("F2") + "%"; + float bulletShot = GlobalPreference.Instance.GetBulletShot(); + float bulletHit = GlobalPreference.Instance.GetBulletHit(); + float accuracyValue; + string formattedAccuracy; + if (bulletShot > 0) + { + accuracyValue = (bulletHit / (float)bulletShot) * 100; + formattedAccuracy = accuracyValue.ToString("F2") + "%"; + } + else + { + formattedAccuracy = "0%"; + } + accuracy.text = formattedAccuracy; float distanceInKm = GlobalPreference.Instance.GetDistanceTraveled() / 1000; @@ -48,8 +62,16 @@ public class GameOver : MonoBehaviour playTime.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hours, minutes, seconds); } + public IEnumerator MusicTransition() + { + AudioManager.instance.StopMusic(); + yield return new WaitForSeconds(2f); + AudioManager.instance.PlaySFX("GameOver"); + } + public void StartFade() { + StartCoroutine(MusicTransition()); StartCoroutine(FadeOut()); StartCoroutine(GoToMainMenu()); } @@ -65,7 +87,7 @@ public class GameOver : MonoBehaviour yield return new WaitForSeconds(1f); } - SceneManager.LoadScene(0); + BackToMainMenu(); } private IEnumerator FadeOut() @@ -83,11 +105,19 @@ public class GameOver : MonoBehaviour public void BackToMainMenu() { - SceneManager.LoadScene(0); + FadeOutCanvas.SetActive(true); + StartCoroutine(Delay(0)); } public void ReplayGame() { - SceneManager.LoadScene(1); + FadeOutCanvas.SetActive(true); + StartCoroutine(Delay(1)); + } + + private IEnumerator Delay(int scene) + { + yield return new WaitForSeconds(2); + SceneManager.LoadScene(scene); } } diff --git a/Assets/Script/Menu/StatisticsMenu.cs b/Assets/Script/Menu/StatisticsMenu.cs index 91ecf30c..40275c8d 100644 --- a/Assets/Script/Menu/StatisticsMenu.cs +++ b/Assets/Script/Menu/StatisticsMenu.cs @@ -20,8 +20,19 @@ public class StatisticsMenu : MonoBehaviour damageDealt.text = PlayerPrefs.GetFloat("Damage").ToString(); - float accuracyValue = (PlayerPrefs.GetFloat("BulletHit") / PlayerPrefs.GetFloat("BulletShot")) * 100; - string formattedAccuracy = accuracyValue.ToString("F2") + "%"; + float bulletShot = PlayerPrefs.GetFloat("BulletShot"); + float bulletHit = PlayerPrefs.GetFloat("BulletHit"); + float accuracyValue; + string formattedAccuracy; + if (bulletShot > 0) + { + accuracyValue = (bulletHit / bulletShot) * 100; + formattedAccuracy = accuracyValue.ToString("F2") + "%"; + } + else + { + formattedAccuracy = "0%"; + } accuracy.text = formattedAccuracy; float distanceInKm = PlayerPrefs.GetFloat("Distance") / 1000; diff --git a/Assets/Script/Player/PlayerMotor.cs b/Assets/Script/Player/PlayerMotor.cs index d15bd694..f3658e02 100644 --- a/Assets/Script/Player/PlayerMotor.cs +++ b/Assets/Script/Player/PlayerMotor.cs @@ -14,6 +14,8 @@ public class PlayerMotor : MonoBehaviour private bool isSprint; public float distanceTraveled = 0; + public bool isWalking = false; + private float timeSinceLastStep = 0f; // Start is called before the first frame update void Start() @@ -40,7 +42,22 @@ public class PlayerMotor : MonoBehaviour { DisableSprint(); } - + + if (isWalking) + { + timeSinceLastStep -= Time.deltaTime; + + if (timeSinceLastStep <= 0f) + { + timeSinceLastStep = 8f; + AudioManager.instance.PlayPlayerSFX("Walk"); + } + } + else + { + timeSinceLastStep = 0f; + AudioManager.instance.StopPlayerSFX(); + } } //receive input from inputmanager public void ProcessMove(Vector2 input) @@ -48,6 +65,7 @@ public class PlayerMotor : MonoBehaviour Vector3 moveDirection = Vector3.zero; moveDirection.x = input.x; moveDirection.z = input.y; + isWalking = moveDirection.magnitude > 0; characterController.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime); playerVelocity.y += gravity * Time.deltaTime; if (isGrounded && playerVelocity.y < 0) { diff --git a/Assets/Script/Weapon/GunSystem.cs b/Assets/Script/Weapon/GunSystem.cs index 83bf21a3..f876ccfa 100644 --- a/Assets/Script/Weapon/GunSystem.cs +++ b/Assets/Script/Weapon/GunSystem.cs @@ -207,6 +207,7 @@ public class GunSystem : MonoBehaviour { cam.GetComponentInParent<Animator>().SetTrigger("Reload"); reloading = true; + AudioManager.instance.PlaySFX("Reload"); Invoke("ReloadFinished", reloadTime); } -- GitLab