From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/RayHitBulletSound.cs | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 GameCode/RayHitBulletSound.cs (limited to 'GameCode/RayHitBulletSound.cs') diff --git a/GameCode/RayHitBulletSound.cs b/GameCode/RayHitBulletSound.cs new file mode 100644 index 0000000..0e3d86c --- /dev/null +++ b/GameCode/RayHitBulletSound.cs @@ -0,0 +1,60 @@ +using Sonigon; +using UnityEngine; + +public class RayHitBulletSound : RayHitEffect +{ + [Header("Sound Settings")] + public bool disableImpact; + + public bool playLocalImpact; + + public SoundEvent soundLocalImpact; + + public bool localImpactVelocityToIntensity; + + private ProjectileHit projectileHit; + + private RayHitReflect rayHitReflect; + + private MoveTransform moveTransform; + + private SoundParameterIntensity soundIntensity = new SoundParameterIntensity(); + + private void Start() + { + projectileHit = GetComponent(); + rayHitReflect = GetComponent(); + moveTransform = GetComponent(); + } + + public override HasToReturn DoHitEffect(HitInfo hit) + { + if (disableImpact) + { + return HasToReturn.canContinue; + } + if (localImpactVelocityToIntensity) + { + soundIntensity.intensity = moveTransform.velocity.magnitude; + } + if (playLocalImpact) + { + if (soundLocalImpact != null && hit.collider != null && hit.collider.tag != "Player") + { + if (localImpactVelocityToIntensity) + { + SoundManager.Instance.PlayAtPosition(soundLocalImpact, SoundManager.Instance.GetTransform(), hit.point, soundIntensity); + } + else + { + SoundManager.Instance.PlayAtPosition(soundLocalImpact, SoundManager.Instance.GetTransform(), hit.point); + } + } + } + else + { + projectileHit.ownPlayer.data.weaponHandler.gun.soundGun.PlayImpact(hit, rayHitReflect); + } + return HasToReturn.canContinue; + } +} -- cgit v1.1-26-g67d0