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/RayHitBash.cs | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 GameCode/RayHitBash.cs (limited to 'GameCode/RayHitBash.cs') diff --git a/GameCode/RayHitBash.cs b/GameCode/RayHitBash.cs new file mode 100644 index 0000000..e56603e --- /dev/null +++ b/GameCode/RayHitBash.cs @@ -0,0 +1,80 @@ +using UnityEngine; + +public class RayHitBash : RayHitEffect +{ + public float triggerChancePerTenDamage = 0.1f; + + public float baseTriggerChance = 0.2f; + + [Space(15f)] + public float stunMultiplier = 1f; + + public float stunTimePerTenDamage = 0.1f; + + public float baseStunTime = 1f; + + public bool cannotPermaStun; + + [Space(15f)] + public float stunTimeThreshold = 0.2f; + + public float stunTimeExponent = 1f; + + public float multiplierPerTenMeterTravelled; + + private MoveTransform move; + + private float multiplier = 1f; + + private void Start() + { + move = GetComponentInParent(); + multiplier = base.transform.localScale.x; + } + + public override HasToReturn DoHitEffect(HitInfo hit) + { + if (!hit.transform) + { + return HasToReturn.canContinue; + } + StunHandler component = hit.transform.GetComponent(); + if ((bool)component) + { + ProjectileHit componentInParent = GetComponentInParent(); + float num = 25f; + if ((bool)componentInParent) + { + num = componentInParent.damage; + } + float num2 = triggerChancePerTenDamage * num * 0.1f; + num2 += baseTriggerChance; + if (Random.value < num2) + { + float num3 = baseStunTime + stunTimePerTenDamage * num * 0.1f; + SetMultiplier(); + num3 *= stunMultiplier; + num3 = Mathf.Pow(num3, stunTimeExponent); + num3 *= multiplier; + if (cannotPermaStun) + { + num3 = Mathf.Clamp(num3, 0f, GetComponentInParent().spawner.data.weaponHandler.gun.attackSpeed * GetComponentInParent().spawner.data.stats.attackSpeedMultiplier + 0.3f); + } + if (num3 > stunTimeThreshold) + { + component.AddStun(num3); + } + } + } + return HasToReturn.canContinue; + } + + private void SetMultiplier() + { + float distanceTravelled = move.distanceTravelled; + if (multiplierPerTenMeterTravelled != 0f) + { + stunMultiplier = distanceTravelled * multiplierPerTenMeterTravelled * 0.1f; + } + } +} -- cgit v1.1-26-g67d0