summaryrefslogtreecommitdiff
path: root/GameCode/RayHitReflect.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/RayHitReflect.cs
+ init
Diffstat (limited to 'GameCode/RayHitReflect.cs')
-rw-r--r--GameCode/RayHitReflect.cs61
1 files changed, 61 insertions, 0 deletions
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<HitInfo> reflectAction;
+
+ private void Start()
+ {
+ move = GetComponent<MoveTransform>();
+ projHit = GetComponent<ProjectileHit>();
+ }
+
+ public override HasToReturn DoHitEffect(HitInfo hit)
+ {
+ if ((bool)hit.transform && (bool)hit.transform.GetComponent<Player>())
+ {
+ 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<ScaleTrailFromDamage>();
+ if ((bool)componentInChildren)
+ {
+ componentInChildren.Rescale();
+ }
+ }
+ timeOfBounce = Time.time;
+ base.transform.position = (Vector3)hit.point + move.velocity.normalized * 0.1f;
+ reflects--;
+ return HasToReturn.hasToReturn;
+ }
+}