summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ShieldMinigame.cs
blob: 553c5fa2aca37cba965aa39e522c14e57e8fdf97 (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
using System;
using UnityEngine;

public class ShieldMinigame : Minigame
{
	public Color OnColor = Color.white;

	public Color OffColor = Color.red;

	public SpriteRenderer[] Shields;

	public SpriteRenderer Gauge;

	private byte shields;

	public AudioClip ShieldOnSound;

	public AudioClip ShieldOffSound;

	public override void Begin(PlayerTask task)
	{
		base.Begin(task);
		this.shields = this.MyNormTask.Data[0];
		this.UpdateButtons();
	}

	public void ToggleShield(int i)
	{
		if (!this.MyNormTask.IsComplete)
		{
			byte b = (byte)(1 << i);
			this.shields ^= b;
			this.MyNormTask.Data[0] = this.shields;
			if ((this.shields & b) != 0)
			{
				if (Constants.ShouldPlaySfx())
				{
					SoundManager.Instance.PlaySound(this.ShieldOnSound, false, 1f);
				}
			}
			else if (Constants.ShouldPlaySfx())
			{
				SoundManager.Instance.PlaySound(this.ShieldOffSound, false, 1f);
			}
			if (this.shields == 127)
			{
				this.MyNormTask.NextStep();
				base.StartCoroutine(base.CoStartClose(0.75f));
				if (!ShipStatus.Instance.ShieldsImages[0].IsPlaying(null))
				{
					ShipStatus.Instance.StartShields();
					PlayerControl.LocalPlayer.RpcPlayAnimation(1);
				}
			}
		}
	}

	public void FixedUpdate()
	{
		this.UpdateButtons();
	}

	private void UpdateButtons()
	{
		int num = 0;
		for (int i = 0; i < this.Shields.Length; i++)
		{
			bool flag = ((int)this.shields & 1 << i) == 0;
			if (!flag)
			{
				num++;
			}
			this.Shields[i].color = (flag ? this.OffColor : this.OnColor);
		}
		if (this.shields == 127)
		{
			this.Gauge.transform.Rotate(0f, 0f, Time.fixedDeltaTime * 45f);
			this.Gauge.color = new Color(1f, 1f, 1f, 1f);
			return;
		}
		float num2 = Mathf.Lerp(0.1f, 0.5f, (float)num / 6f);
		this.Gauge.color = new Color(1f, num2, num2, 1f);
	}
}