diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/TrickShot.cs |
+ init
Diffstat (limited to 'GameCode/TrickShot.cs')
-rw-r--r-- | GameCode/TrickShot.cs | 87 |
1 files changed, 87 insertions, 0 deletions
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<ScaleTrailFromDamage>(); + } + + private void Start() + { + projectileHit = GetComponentInParent<ProjectileHit>(); + move = GetComponentInParent<MoveTransform>(); + 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(); + } + } +} |