summaryrefslogtreecommitdiff
path: root/Standing.cs
blob: 616221573a36a3067d20668d9e3d1f3480406d52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
		}
	}
}