summaryrefslogtreecommitdiff
path: root/_ActiveRagdoll/Player
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-16 12:39:34 +0800
committerchai <215380520@qq.com>2024-03-16 12:39:34 +0800
commit793c4eae324d394f19a8bac66a803bf03a67ae9d (patch)
tree629b5d87bdf0fd004b1950e42e2427bc884f1059 /_ActiveRagdoll/Player
parent3f53966a0fdc96f1e32d7d5f930c5cac6d4dfb29 (diff)
*misc
Diffstat (limited to '_ActiveRagdoll/Player')
-rw-r--r--_ActiveRagdoll/Player/AnimationHandler.cs15
-rw-r--r--_ActiveRagdoll/Player/MovementDataHandler.cs92
-rw-r--r--_ActiveRagdoll/Player/MovementHandler.cs86
-rw-r--r--_ActiveRagdoll/Player/PickupHandler.cs64
4 files changed, 0 insertions, 257 deletions
diff --git a/_ActiveRagdoll/Player/AnimationHandler.cs b/_ActiveRagdoll/Player/AnimationHandler.cs
deleted file mode 100644
index 382b3a5..0000000
--- a/_ActiveRagdoll/Player/AnimationHandler.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using UnityEngine;
-
-//Player AnimationHandler 记录当前动作状态编号
-public class AnimationHandler : MonoBehaviour
-{
- public int animationState;
-
- private void Start()
- {
- }
-
- private void Update()
- {
- }
-}
diff --git a/_ActiveRagdoll/Player/MovementDataHandler.cs b/_ActiveRagdoll/Player/MovementDataHandler.cs
deleted file mode 100644
index 18d43f5..0000000
--- a/_ActiveRagdoll/Player/MovementDataHandler.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using UnityEngine;
-
-public class MovementDataHandler : MonoBehaviour
-{
- [HideInInspector]
- public Vector3 groundedForward;
-
- [HideInInspector]
- public Vector3 right;
-
- [HideInInspector]
- public Vector3 left;
-
- [HideInInspector]
- public Vector3 groundedBack;
-
- private Transform hip;
-
- private Transform torso;
-
- public Transform rotationTarget;
-
- [HideInInspector]
- public float slopeStrenght;
-
- public float slopeVelocityStrenght;
-
- [HideInInspector]
- public float sinceJump = 1f;
-
- [HideInInspector]
- public Vector3 groundNormal;
-
- private InputHandler inputHandler;
-
- private Transform leftKnee;
-
- private Transform rightKnee;
-
- private void Start()
- {
- inputHandler = GetComponent<InputHandler>();
- hip = GetComponentInChildren<Hip>().transform;
- torso = GetComponentInChildren<Torso>().transform;
- if (!rotationTarget)
- {
- rotationTarget = GetComponentInChildren<RotationTarget>().transform;
- }
- KneeLeft componentInChildren = GetComponentInChildren<KneeLeft>();
- if ((bool)componentInChildren)
- {
- leftKnee = componentInChildren.transform;
- }
- KneeRight componentInChildren2 = GetComponentInChildren<KneeRight>();
- if ((bool)componentInChildren2)
- {
- rightKnee = componentInChildren2.transform;
- }
- }
-
- private void Update()
- {
- sinceJump += Time.deltaTime;
- groundedForward = rotationTarget.forward;
- groundedForward.y = slopeStrenght * 1f;
- groundedForward = groundedForward.normalized;
- groundedBack = -groundedForward;
- right = rotationTarget.right;
- left = -rotationTarget.right;
- slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f);
- Debug.DrawLine(hip.position, hip.position + groundedForward * 10f);
- }
-
- public void SetSlope(Vector3 normal)
- {
- groundNormal = normal;
- slopeStrenght = Vector3.Cross(rotationTarget.right, normal).y;
- Vector3 lhs = Vector3.Cross(Vector3.up, inputHandler.inputMovementDirection);
- slopeVelocityStrenght = Vector3.Cross(lhs, normal).y;
- }
-
- public float GetSmallestLegAngle()
- {
- float num = Vector3.Angle(leftKnee.forward, Vector3.down);
- float num2 = Vector3.Angle(rightKnee.forward, Vector3.down);
- if (num < num2)
- {
- return num;
- }
- return num2;
- }
-}
diff --git a/_ActiveRagdoll/Player/MovementHandler.cs b/_ActiveRagdoll/Player/MovementHandler.cs
deleted file mode 100644
index 4579efc..0000000
--- a/_ActiveRagdoll/Player/MovementHandler.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Collections;
-using UnityEngine;
-
-//Player MovementHandler 控制移动、跳跃
-public class MovementHandler : MonoBehaviour
-{
- private InputHandler inputHandler;
-
- public float friction = 0.9f;
-
- public Vector3 movementVector;
-
- public float[] animationForceAmounts;
-
- private AnimationHandler animationHandler;
-
- private RigidbodyHolder allRigs;
-
- public AnimationCurve jumpCurve;
-
- public float jumpForce;
-
- private StandingDataHandler standingData;
-
- private MovementDataHandler data;
-
- private PlayerDeath death;
-
- [HideInInspector]
- public float multiplier = 1f;
-
- private WobbleShake wobbleShake;
-
- private void Start()
- {
- wobbleShake = GetComponentInChildren<WobbleShake>();
- death = GetComponent<PlayerDeath>();
- standingData = GetComponent<StandingDataHandler>();
- inputHandler = GetComponent<InputHandler>();
- animationHandler = GetComponent<AnimationHandler>();
- allRigs = GetComponent<RigidbodyHolder>();
- data = GetComponent<MovementDataHandler>();
- }
-
- private void FixedUpdate()
- {
- if (!death.dead)
- {
- data.sinceJump += Time.fixedDeltaTime;
- movementVector += inputHandler.inputMovementDirection * animationForceAmounts[animationHandler.animationState];
- movementVector *= friction;
- for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
- {
- allRigs.GetAllRigs()[i].AddForce(movementVector * multiplier, ForceMode.Acceleration);
- }
- }
- }
-
- public void Jump()
- {
- if (!(data.sinceJump < 0.5f) && !(standingData.sinceGrounded > 0.3f))
- {
- data.sinceJump = 0f;
- StartCoroutine(AddJumpForce());
- wobbleShake.AddShake(Vector3.up * 2f, 0.8f);
- }
- }
-
- private IEnumerator AddJumpForce()
- {
- float counter = 0f;
- for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
- {
- allRigs.GetAllRigs()[i].velocity = new Vector3(allRigs.GetAllRigs()[i].velocity.x, 0f, allRigs.GetAllRigs()[i].velocity.z);
- }
- while (counter < jumpCurve.keys[jumpCurve.length - 1].time && !death.dead)
- {
- counter += Time.deltaTime;
- for (int j = 0; j < allRigs.GetAllRigs().Length; j++)
- {
- allRigs.GetAllRigs()[j].AddForce(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration);
- }
- yield return null;
- }
- }
-}
diff --git a/_ActiveRagdoll/Player/PickupHandler.cs b/_ActiveRagdoll/Player/PickupHandler.cs
deleted file mode 100644
index 6a3a249..0000000
--- a/_ActiveRagdoll/Player/PickupHandler.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using UnityEngine;
-
-//Player PickupHandler 捡武器
-public class PickupHandler : MonoBehaviour
-{
- public Pickup setWeapon;
-
- public Pickup setWeapon2;
-
- private WeaponHandler weaponHandler;
-
- private Holding holding; // holding动作
-
- private float counter;
-
- private void Start()
- {
- weaponHandler = GetComponent<WeaponHandler>();
- holding = GetComponent<Holding>();
- if ((bool)setWeapon)
- {
- PickUp(setWeapon);
- }
- if ((bool)setWeapon2)
- {
- PickUp2(setWeapon2);
- }
- }
-
- private void Update()
- {
- counter += Time.deltaTime;
- }
-
- public void PickUp(Pickup objectToPickUp)
- {
- if (!(counter < 1f))
- {
- counter = 0f;
- holding.Drop();
- Weapon component = objectToPickUp.GetComponent<Weapon>();
- Gun component2 = component.GetComponent<Gun>();
- weaponHandler.SetGun(component2, mainHand: true);
- bool hasOffHand = false;
- if ((bool)setWeapon2)
- {
- hasOffHand = true;
- }
- HoldableObject component3 = component.GetComponent<HoldableObject>();
- component3.holder = base.transform;
- holding.StartHolding(component3, hasOffHand);
- }
- }
-
- public void PickUp2(Pickup objectToPickUp)
- {
- Weapon component = objectToPickUp.GetComponent<Weapon>();
- Gun component2 = component.GetComponent<Gun>();
- weaponHandler.SetGun(component2, mainHand: false);
- HoldableObject component3 = component.GetComponent<HoldableObject>();
- component3.holder = base.transform;
- holding.StartHolding(component3, hasOffHand: true);
- }
-}