summaryrefslogtreecommitdiff
path: root/MovementHandler.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-13 11:38:18 +0800
committerchai <215380520@qq.com>2024-03-13 11:38:18 +0800
commit134f1deb971b0514a26e04e23926f91983a5497f (patch)
treed790681bb000c07abae9f557a7d0ef2442fac467 /MovementHandler.cs
parent6ce8b9e22fc13be34b442c7b6af48b42cd44275a (diff)
* move
Diffstat (limited to 'MovementHandler.cs')
-rw-r--r--MovementHandler.cs85
1 files changed, 0 insertions, 85 deletions
diff --git a/MovementHandler.cs b/MovementHandler.cs
deleted file mode 100644
index 22795f7..0000000
--- a/MovementHandler.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System.Collections;
-using UnityEngine;
-
-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;
- }
- }
-}