summaryrefslogtreecommitdiff
path: root/GameCode/ChargeFeedback.cs
blob: 322fe89e5275c4c50d884eded07d6b4313a22b0f (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
using UnityEngine;

public class ChargeFeedback : MonoBehaviour
{
	private Gun gun;

	public float drag = 1f;

	public float spring = 1f;

	public float angle = 45f;

	public float chargeAngle = 15f;

	private float currentAngle;

	private float velocity;

	public float charge;

	private void Start()
	{
		gun = GetComponentInParent<Gun>();
		gun.AddAttackAction(Shoot);
	}

	private void Update()
	{
		charge = 0f;
		if (!gun.IsReady(0.15f))
		{
			charge = 1f;
		}
		velocity += (charge * chargeAngle - currentAngle) * CappedDeltaTime.time * spring;
		velocity -= velocity * CappedDeltaTime.time * drag;
		currentAngle += CappedDeltaTime.time * velocity;
		base.transform.localEulerAngles = new Vector3(currentAngle, 0f, 0f);
	}

	public void Shoot()
	{
		velocity += (0f - angle) * 1000f * (gun.damage / 55f);
	}
}