summaryrefslogtreecommitdiff
path: root/GameCode/ProjectileAudio.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-11-02 11:51:31 +0800
committerchai <215380520@qq.com>2023-11-02 11:51:31 +0800
commit7f493f682503f5186308de7b8f74b5b49233cfe4 (patch)
tree8a91e2056bc79788ee4735dce88b8d516ba12beb /GameCode/ProjectileAudio.cs
+init
Diffstat (limited to 'GameCode/ProjectileAudio.cs')
-rw-r--r--GameCode/ProjectileAudio.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/GameCode/ProjectileAudio.cs b/GameCode/ProjectileAudio.cs
new file mode 100644
index 0000000..7390613
--- /dev/null
+++ b/GameCode/ProjectileAudio.cs
@@ -0,0 +1,37 @@
+using UnityEngine;
+
+public class ProjectileAudio : MonoBehaviour
+{
+ public enum ProjectileType
+ {
+ Catapult
+ }
+
+ public AimbotProjectile target;
+
+ public AudioSource aSource;
+
+ public ProjectileType projectile;
+
+ public float pitchrange = 0.2f;
+
+ private void Start()
+ {
+ if (target != null)
+ {
+ target.onHit.AddListener(PlayImpact);
+ }
+ if (projectile == ProjectileType.Catapult)
+ {
+ aSource.clip = ThronefallAudioManager.Instance.audioContent.CatapultImpact.GetRandomClip();
+ }
+ aSource.pitch = Random.Range(1f - pitchrange, 1f + pitchrange);
+ }
+
+ private void PlayImpact()
+ {
+ aSource.Play();
+ aSource.transform.parent = null;
+ Object.Destroy(aSource.gameObject, aSource.clip.length);
+ }
+}