summaryrefslogtreecommitdiff
path: root/Standing.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-13 11:00:58 +0800
committerchai <215380520@qq.com>2024-03-13 11:00:58 +0800
commit6ce8b9e22fc13be34b442c7b6af48b42cd44275a (patch)
treeb38119d2acf0a982cb67e381f146924b9bfc3b3f /Standing.cs
+init
Diffstat (limited to 'Standing.cs')
-rw-r--r--Standing.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Standing.cs b/Standing.cs
new file mode 100644
index 0000000..6162215
--- /dev/null
+++ b/Standing.cs
@@ -0,0 +1,55 @@
+using UnityEngine;
+
+public class Standing : MonoBehaviour
+{
+ public RigidbodyMovment[] rigsToLift;
+
+ public AnimationCurve[] animationLiftCurves;
+
+ private StandingDataHandler standingData;
+
+ private AnimationHandler animationHandler;
+
+ public float offset;
+
+ private PlayerDeath death;
+
+ private Strength str;
+
+ private float muscleMultiplier = 1f;
+
+ private float legAngleMultiplier;
+
+ private MovementDataHandler moveData;
+
+ private void Start()
+ {
+ death = GetComponent<PlayerDeath>();
+ str = GetComponent<Strength>();
+ standingData = GetComponent<StandingDataHandler>();
+ moveData = GetComponent<MovementDataHandler>();
+ animationHandler = GetComponent<AnimationHandler>();
+ }
+
+ private void FixedUpdate()
+ {
+ if (!death.dead)
+ {
+ muscleMultiplier = str.strength;
+ if (standingData.isGrounded)
+ {
+ Stand(animationLiftCurves[animationHandler.animationState]);
+ }
+ }
+ }
+
+ private void Stand(AnimationCurve curve)
+ {
+ legAngleMultiplier = 1f;
+ RigidbodyMovment[] array = rigsToLift;
+ foreach (RigidbodyMovment rigidbodyMovment in array)
+ {
+ rigidbodyMovment.rig.AddForce(Vector3.up * muscleMultiplier * rigidbodyMovment.force * legAngleMultiplier * curve.Evaluate(standingData.distanceToGround + offset + moveData.slopeVelocityStrenght * -0.2f), ForceMode.Acceleration);
+ }
+ }
+}