summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/RefuelStage.cs
blob: 41b64dccf9af5caca50468122acb1a0db54a347f (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using UnityEngine;

public class RefuelStage : MonoBehaviour
{
	public NormalPlayerTask MyNormTask { get; set; }

	public float RefuelDuration = 5f;

	private Color darkRed = new Color32(90, 0, 0, byte.MaxValue);

	private Color red = new Color32(byte.MaxValue, 58, 0, byte.MaxValue);

	private Color green = Color.green;

	public SpriteRenderer redLight;

	public SpriteRenderer greenLight;

	public VerticalGauge srcGauge;

	public VerticalGauge destGauge;

	public AudioClip RefuelSound;

	private float timer;

	private bool isDown;

	private bool complete;

	public void Begin()
	{
		this.timer = (float)this.MyNormTask.Data[0] / 255f;
	}

	public void FixedUpdate()
	{
		if (this.complete)
		{
			return;
		}
		if (this.isDown && this.timer < 1f)
		{
			this.timer += Time.fixedDeltaTime / this.RefuelDuration;
			this.MyNormTask.Data[0] = (byte)Mathf.Min(255f, this.timer * 255f);
			if (this.timer >= 1f)
			{
				this.complete = true;
				this.greenLight.color = this.green;
				this.redLight.color = this.darkRed;
				this.MyNormTask.Data[0] = 0;
				byte[] data = this.MyNormTask.Data;
				int num = 1;
				data[num] += 1;
				if (this.MyNormTask.Data[1] % 2 == 0)
				{
					this.MyNormTask.NextStep();
				}
				this.MyNormTask.UpdateArrow();
			}
		}
		this.destGauge.value = this.timer;
		if (this.srcGauge)
		{
			this.srcGauge.value = 1f - this.timer;
		}
	}

	public void Refuel()
	{
		if (this.complete)
		{
			base.transform.parent.GetComponent<Minigame>().Close();
			return;
		}
		this.isDown = !this.isDown;
		this.redLight.color = (this.isDown ? this.red : this.darkRed);
		if (this.isDown)
		{
			if (Constants.ShouldPlaySfx())
			{
				SoundManager.Instance.PlayDynamicSound("Refuel", this.RefuelSound, true, new DynamicSound.GetDynamicsFunction(this.GetRefuelDynamics), true);
				return;
			}
		}
		else
		{
			SoundManager.Instance.StopSound(this.RefuelSound);
		}
	}

	private void GetRefuelDynamics(AudioSource player, float dt)
	{
		player.volume = 1f;
		player.pitch = Mathf.Lerp(0.75f, 1.25f, this.timer);
	}
}