summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ShieldMinigame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/ShieldMinigame.cs')
-rw-r--r--Client/Assembly-CSharp/ShieldMinigame.cs84
1 files changed, 84 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/ShieldMinigame.cs b/Client/Assembly-CSharp/ShieldMinigame.cs
new file mode 100644
index 0000000..553c5fa
--- /dev/null
+++ b/Client/Assembly-CSharp/ShieldMinigame.cs
@@ -0,0 +1,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);
+ }
+}