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/RayHitReflect.cs | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 GameCode/RayHitReflect.cs (limited to 'GameCode/RayHitReflect.cs') diff --git a/GameCode/RayHitReflect.cs b/GameCode/RayHitReflect.cs new file mode 100644 index 0000000..182aa73 --- /dev/null +++ b/GameCode/RayHitReflect.cs @@ -0,0 +1,61 @@ +using System; +using UnityEngine; + +public class RayHitReflect : RayHitEffect +{ + private MoveTransform move; + + private ProjectileHit projHit; + + public int reflects = 1; + + public float speedM = 1f; + + public float dmgM = 1f; + + [HideInInspector] + public float timeOfBounce = -10000f; + + public Action reflectAction; + + private void Start() + { + move = GetComponent(); + projHit = GetComponent(); + } + + public override HasToReturn DoHitEffect(HitInfo hit) + { + if ((bool)hit.transform && (bool)hit.transform.GetComponent()) + { + reflects -= 10; + } + if (reflects <= 0) + { + return HasToReturn.canContinue; + } + if (reflectAction != null) + { + reflectAction(hit); + } + move.velocity = Vector2.Reflect(move.velocity, hit.normal); + move.velocity *= speedM; + projHit.damage *= dmgM; + projHit.shake *= dmgM; + if (dmgM > 1f) + { + float num = dmgM - 1f; + num *= 0.6f; + dmgM = num + 1f; + ScaleTrailFromDamage componentInChildren = GetComponentInChildren(); + if ((bool)componentInChildren) + { + componentInChildren.Rescale(); + } + } + timeOfBounce = Time.time; + base.transform.position = (Vector3)hit.point + move.velocity.normalized * 0.1f; + reflects--; + return HasToReturn.hasToReturn; + } +} -- cgit v1.1-26-g67d0