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/ScaleTrailFromDamage.cs | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 GameCode/ScaleTrailFromDamage.cs (limited to 'GameCode/ScaleTrailFromDamage.cs') diff --git a/GameCode/ScaleTrailFromDamage.cs b/GameCode/ScaleTrailFromDamage.cs new file mode 100644 index 0000000..ffe41a8 --- /dev/null +++ b/GameCode/ScaleTrailFromDamage.cs @@ -0,0 +1,61 @@ +using UnityEngine; + +public class ScaleTrailFromDamage : MonoBehaviour +{ + private float startWidth; + + private float startTime; + + private void Start() + { + float num = 55f; + ProjectileHit componentInParent = GetComponentInParent(); + GetComponentInParent(); + if ((bool)componentInParent) + { + num = componentInParent.damage; + } + TrailRenderer componentInChildren = GetComponentInChildren(); + startWidth = componentInChildren.widthMultiplier; + startTime = componentInChildren.time; + if ((bool)componentInChildren) + { + componentInChildren.widthMultiplier *= (1f + num / 55f) / 2f; + componentInChildren.time *= Mathf.Clamp((1f + num / 55f) / 2f, 0f, 25f); + if (num > 100f) + { + componentInChildren.numCapVertices = 5; + } + if (num > 500f) + { + componentInChildren.numCapVertices = 10; + } + } + } + + public void Rescale() + { + float num = 55f; + ProjectileHit componentInParent = GetComponentInParent(); + RayCastTrail componentInParent2 = GetComponentInParent(); + if ((bool)componentInParent) + { + num = componentInParent.damage; + } + TrailRenderer componentInChildren = GetComponentInChildren(); + if ((bool)componentInChildren) + { + _ = componentInParent2.extraSize; + componentInChildren.widthMultiplier = startWidth * ((1f + num / 55f) / 2f); + componentInChildren.time = startTime * Mathf.Clamp((1f + num / 55f) / 2f, 0f, 25f); + if (num > 100f) + { + componentInChildren.numCapVertices = 5; + } + if (num > 100f) + { + componentInChildren.numCapVertices = 10; + } + } + } +} -- cgit v1.1-26-g67d0