From 134f1deb971b0514a26e04e23926f91983a5497f Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Wed, 13 Mar 2024 11:38:18 +0800 Subject: * move --- PlayerDeath.cs | 125 --------------------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 PlayerDeath.cs (limited to 'PlayerDeath.cs') diff --git a/PlayerDeath.cs b/PlayerDeath.cs deleted file mode 100644 index ec0813a..0000000 --- a/PlayerDeath.cs +++ /dev/null @@ -1,125 +0,0 @@ -using UnityEngine; - -public class PlayerDeath : MonoBehaviour -{ - public bool dead; - - private bool isFrozen; - - public float muscleFunction = 1f; - - public bool terminalState; - - private DamageEffects damageEffects; - - private RagdollHandler ragdoll; - - private Transform hip; - - public float health = 100f; - - public ParticleSystem[] damageParticles; - - private HasControl hasControll; - - private Holding holding; - - private void Start() - { - damageEffects = GetComponent(); - ragdoll = GetComponent(); - hip = GetComponentInChildren().transform; - hasControll = GetComponent(); - holding = GetComponent(); - } - - private void Update() - { - if (health < 100f) - { - health += Time.deltaTime * 10f; - health = Mathf.Clamp(health, -10f, 100f); - } - if (hip.transform.position.y < -10f) - { - Die(); - } - if (terminalState && muscleFunction > 0f) - { - muscleFunction -= Time.deltaTime * 1f; - } - if (muscleFunction < 0f && !isFrozen) - { - FreezeBody(); - } - } - - public void TakeDamage(Vector3 damage, Vector3 hitPoint, Rigidbody hitRig = null) - { - if (hasControll.hasControl) - { - damageEffects.TakeDamage(damage, hitPoint); - } - if (hitPoint != Vector3.zero) - { - for (int i = 0; i < damageParticles.Length; i++) - { - damageParticles[i].transform.rotation = Quaternion.LookRotation(damage); - damageParticles[i].transform.position = hitPoint; - damageParticles[i].Play(); - } - } - health -= damage.magnitude; - if (!(health <= 0f)) - { - return; - } - if ((bool)hitRig) - { - ConfigurableJoint component = hitRig.GetComponent(); - if ((bool)component) - { - Object.Destroy(component); - } - } - Kill(); - } - - public void FreezeBody() - { - isFrozen = true; - Joint[] componentsInChildren = GetComponentsInChildren(); - for (int i = 0; i < componentsInChildren.Length; i++) - { - ConfigurableJoint configurableJoint = (ConfigurableJoint)componentsInChildren[i]; - Rigidbody component = configurableJoint.GetComponent(); - JointDrive angularXDrive = configurableJoint.angularXDrive; - angularXDrive.positionSpring = 5f * component.mass; - angularXDrive.positionDamper = 1f * component.mass; - configurableJoint.angularXDrive = angularXDrive; - configurableJoint.angularYZDrive = angularXDrive; - configurableJoint.SetTargetRotationLocal(configurableJoint.transform.localRotation, configurableJoint.gameObject.GetComponent().startRotationLocal); - } - } - - public void Die() - { - if (!dead) - { - holding.Drop(); - dead = true; - ragdoll.ragdollValue = 0f; - Collider[] componentsInChildren = GetComponentsInChildren(); - foreach (Collider collider in componentsInChildren) - { - collider.material = null; - } - } - } - - public void Kill() - { - terminalState = true; - Die(); - } -} -- cgit v1.1-26-g67d0