summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/SweepMinigame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/SweepMinigame.cs')
-rw-r--r--Client/Assembly-CSharp/SweepMinigame.cs123
1 files changed, 123 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/SweepMinigame.cs b/Client/Assembly-CSharp/SweepMinigame.cs
new file mode 100644
index 0000000..6499a3f
--- /dev/null
+++ b/Client/Assembly-CSharp/SweepMinigame.cs
@@ -0,0 +1,123 @@
+using System;
+using UnityEngine;
+
+public class SweepMinigame : Minigame
+{
+ public SpriteRenderer[] Spinners;
+
+ public SpriteRenderer[] Shadows;
+
+ public SpriteRenderer[] Lights;
+
+ public HorizontalGauge[] Gauges;
+
+ private int spinnerIdx;
+
+ private float timer;
+
+ public float SpinRate = 45f;
+
+ private float initialTimer;
+
+ public AudioClip SpinningSound;
+
+ public AudioClip AcceptSound;
+
+ public AudioClip RejectSound;
+
+ public override void Begin(PlayerTask task)
+ {
+ base.Begin(task);
+ this.ResetGauges();
+ if (Constants.ShouldPlaySfx())
+ {
+ SoundManager.Instance.PlaySound(this.SpinningSound, true, 1f);
+ }
+ }
+
+ public override void Close()
+ {
+ SoundManager.Instance.StopSound(this.SpinningSound);
+ base.Close();
+ }
+
+ public void FixedUpdate()
+ {
+ float num = Mathf.Clamp(2f - this.timer / 30f, 1f, 2f);
+ this.timer += Time.fixedDeltaTime * num;
+ if (this.spinnerIdx < this.Spinners.Length)
+ {
+ float num2 = this.CalcXPerc();
+ this.Gauges[this.spinnerIdx].Value = ((num2 < 13f) ? 0.9f : 0.1f);
+ Quaternion localRotation = Quaternion.Euler(0f, 0f, this.timer * this.SpinRate);
+ this.Spinners[this.spinnerIdx].transform.localRotation = localRotation;
+ this.Shadows[this.spinnerIdx].transform.localRotation = localRotation;
+ this.Lights[this.spinnerIdx].enabled = (num2 < 13f);
+ }
+ for (int i = 0; i < this.Gauges.Length; i++)
+ {
+ HorizontalGauge horizontalGauge = this.Gauges[i];
+ if (i < this.spinnerIdx)
+ {
+ horizontalGauge.Value = 0.95f;
+ }
+ if (i > this.spinnerIdx)
+ {
+ horizontalGauge.Value = 0.05f;
+ }
+ horizontalGauge.Value += (Mathf.PerlinNoise((float)i, Time.time * 51f) - 0.5f) * 0.025f;
+ }
+ }
+
+ private float CalcXPerc()
+ {
+ int num = (int)(this.timer * this.SpinRate) % 360;
+ return (float)Mathf.Min(360 - num, num);
+ }
+
+ public void HitButton(int i)
+ {
+ if (i != this.spinnerIdx)
+ {
+ return;
+ }
+ if (this.CalcXPerc() < 13f)
+ {
+ if (Constants.ShouldPlaySfx())
+ {
+ SoundManager.Instance.PlaySound(this.AcceptSound, false, 1f);
+ }
+ this.Spinners[this.spinnerIdx].transform.localRotation = Quaternion.identity;
+ this.Shadows[this.spinnerIdx].transform.localRotation = Quaternion.identity;
+ this.spinnerIdx++;
+ this.timer = this.initialTimer;
+ if (this.spinnerIdx >= this.Gauges.Length)
+ {
+ this.MyNormTask.NextStep();
+ base.StartCoroutine(base.CoStartClose(0.75f));
+ return;
+ }
+ }
+ else
+ {
+ if (Constants.ShouldPlaySfx())
+ {
+ SoundManager.Instance.PlaySound(this.RejectSound, false, 1f);
+ }
+ this.ResetGauges();
+ }
+ }
+
+ private void ResetGauges()
+ {
+ this.spinnerIdx = 0;
+ this.timer = FloatRange.Next(1f, 3f);
+ this.initialTimer = this.timer;
+ for (int i = 0; i < this.Gauges.Length; i++)
+ {
+ this.Lights[i].enabled = false;
+ this.Spinners[i].transform.localRotation = Quaternion.Euler(0f, 0f, this.timer * this.SpinRate);
+ this.Shadows[i].transform.localRotation = Quaternion.Euler(0f, 0f, this.timer * this.SpinRate);
+ }
+ }
+}