From 315fc01f197abd77d7f5febd0177329ecbd6afcb Mon Sep 17 00:00:00 2001 From: hanifmz07 <13521157@std.stei.itb.ac.id> Date: Sat, 11 May 2024 15:02:43 +0700 Subject: [PATCH] fix: fix out of ammo and king audio --- .../Assets/Audio/Sound/background_horror.mp3 | 3 ++ .../Audio/Sound/background_horror.mp3.meta | 23 +++++++++++++ .../Assets/Audio/Sound/possessed_laugh.mp3 | 3 ++ .../Audio/Sound/possessed_laugh.mp3.meta | 23 +++++++++++++ .../Assets/Audio/Sound/screech.mp3 | 3 ++ .../Assets/Audio/Sound/screech.mp3.meta | 23 +++++++++++++ .../Assets/Code/Scripts/Gun/GunSystem.cs | 4 ++- .../Assets/Code/Scripts/Mobs/KingBehaviour.cs | 33 +++++++++++++++++++ 8 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3 create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3.meta create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3 create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3.meta create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3 create mode 100644 IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3.meta diff --git a/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3 b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3 new file mode 100644 index 00000000..fb90c7d3 --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c129a21521f2e0212b847cb880547f28d96d30af8d2aa8b19387ba326fff603c +size 2498560 diff --git a/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3.meta b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3.meta new file mode 100644 index 00000000..ce53d2bc --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/background_horror.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: ea2d51c544565a141b2077540e1b5697 +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/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3 b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3 new file mode 100644 index 00000000..499ae287 --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb196fcd5b4be7e393cd7b8c321030fbc30792528059928c56861506491ad4e6 +size 97440 diff --git a/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3.meta b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3.meta new file mode 100644 index 00000000..0f7abe42 --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/possessed_laugh.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 6e56d32c9c87b7e43827cc1e6019cebd +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/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3 b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3 new file mode 100644 index 00000000..e0d93db1 --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41cb0611a603a6c2db5ba6fe985f237febc0a1e257783456edb3f6cffd7ed0e5 +size 302400 diff --git a/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3.meta b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3.meta new file mode 100644 index 00000000..7f8a54ab --- /dev/null +++ b/IF3210-2024-Unity-AFK/Assets/Audio/Sound/screech.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 7d0f696c9bca0d844b9cbf0f4227ad01 +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/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/GunSystem.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/GunSystem.cs index 1e41dd70..efc31fc8 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/GunSystem.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Gun/GunSystem.cs @@ -80,8 +80,10 @@ public class GunSystem : BaseWeaponController Shoot(); } - if (bulletsLeft <= 0 && shooting && !reloading) ; + if (bulletsLeft <= 0 && shooting && !reloading) + { PlayOutOfAmmo(); + } } private void PlayOutOfAmmo() diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KingBehaviour.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KingBehaviour.cs index a16b56c3..2aa70c6d 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KingBehaviour.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/Mobs/KingBehaviour.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; +using UnityEngine.UIElements; public class KingBehaviour : MonoBehaviour { @@ -38,6 +39,10 @@ public class KingBehaviour : MonoBehaviour public GunSystemMobs gunSystem; + public AudioClip backgroundMusic; + public AudioClip screechAudio; + public AudioClip laughAudio; + private bool audioChange = true; // Start is called before the first frame update void Start() @@ -51,6 +56,9 @@ public class KingBehaviour : MonoBehaviour kingAnimator.SetBool(attackAnimation, true); movementController = GetComponent<CharacterController>(); StartCoroutine(SpawnKeroco()); + + StartCoroutine(PlayBackgroundAudio()); + StartCoroutine(PlayMobAudio()); } // Update is called once per frame @@ -234,6 +242,31 @@ public class KingBehaviour : MonoBehaviour } } + IEnumerator PlayMobAudio() + { + while (true) + { + if (audioChange) + { + AudioManagerScript.Instance.PlaySFX(screechAudio); + } else + { + AudioManagerScript.Instance.PlaySFX(laughAudio); + } + audioChange = !audioChange; + yield return new WaitForSeconds(30.0f); + } + } + + IEnumerator PlayBackgroundAudio() + { + while (true) + { + AudioManagerScript.Instance.PlaySFX(backgroundMusic); + yield return new WaitForSeconds(85.0f); + } + } + private void OnDestroy() { enemyController.GetComponent<OrbController>().DropOrb(this.transform); -- GitLab