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/TrickShot.cs | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 GameCode/TrickShot.cs (limited to 'GameCode/TrickShot.cs') diff --git a/GameCode/TrickShot.cs b/GameCode/TrickShot.cs new file mode 100644 index 0000000..cdb0b0e --- /dev/null +++ b/GameCode/TrickShot.cs @@ -0,0 +1,87 @@ +using Sonigon; +using UnityEngine; + +public class TrickShot : MonoBehaviour +{ + [Header("Sound")] + public SoundEvent soundGrowExplosion; + + public SoundEvent soundGrowWail; + + private bool soundGrowExplosionPlayed; + + private bool soundGrowWailPlayed; + + private SoundParameterIntensity soundIntensity = new SoundParameterIntensity(0f); + + [Header("Settings")] + public float muiltiplier = 1f; + + public float removeAt = 30f; + + private ProjectileHit projectileHit; + + private MoveTransform move; + + private ScaleTrailFromDamage trail; + + private float lastDistanceTravelled; + + private void Awake() + { + trail = base.transform.root.GetComponentInChildren(); + } + + private void Start() + { + projectileHit = GetComponentInParent(); + move = GetComponentInParent(); + if (projectileHit != null) + { + if (soundGrowExplosion != null) + { + projectileHit.AddHitActionWithData(SoundPlayGrowExplosion); + } + if (soundGrowWail != null) + { + soundGrowWailPlayed = true; + SoundManager.Instance.Play(soundGrowWail, projectileHit.ownPlayer.transform); + } + } + } + + public void SoundPlayGrowExplosion(HitInfo hit) + { + if (!soundGrowExplosionPlayed) + { + soundGrowExplosionPlayed = true; + if (soundGrowExplosion != null) + { + SoundManager.Instance.PlayAtPosition(soundGrowExplosion, projectileHit.ownPlayer.transform, hit.point, soundIntensity); + } + if (soundGrowWailPlayed) + { + SoundManager.Instance.Stop(soundGrowWail, projectileHit.ownPlayer.transform); + } + } + } + + private void Update() + { + if (move.distanceTravelled > removeAt) + { + Object.Destroy(this); + return; + } + soundIntensity.intensity = move.distanceTravelled / removeAt; + float num = move.distanceTravelled - lastDistanceTravelled; + lastDistanceTravelled = move.distanceTravelled; + float num2 = 1f + num * TimeHandler.deltaTime * base.transform.localScale.x * muiltiplier; + projectileHit.damage *= num2; + projectileHit.shake *= num2; + if ((bool)trail) + { + trail.Rescale(); + } + } +} -- cgit v1.1-26-g67d0