summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/UnlockManifoldsMinigame.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-12-30 20:59:04 +0800
committerchai <chaifix@163.com>2020-12-30 20:59:04 +0800
commite9ea621b93fbb58d9edfca8375918791637bbd52 (patch)
tree19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/UnlockManifoldsMinigame.cs
+init
Diffstat (limited to 'Client/Assembly-CSharp/UnlockManifoldsMinigame.cs')
-rw-r--r--Client/Assembly-CSharp/UnlockManifoldsMinigame.cs100
1 files changed, 100 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/UnlockManifoldsMinigame.cs b/Client/Assembly-CSharp/UnlockManifoldsMinigame.cs
new file mode 100644
index 0000000..16f6269
--- /dev/null
+++ b/Client/Assembly-CSharp/UnlockManifoldsMinigame.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections;
+using System.Linq;
+using UnityEngine;
+
+public class UnlockManifoldsMinigame : Minigame
+{
+ public SpriteRenderer[] Buttons;
+
+ public byte SystemId;
+
+ private int buttonCounter;
+
+ private bool animating;
+
+ public AudioClip PressButtonSound;
+
+ public AudioClip FailSound;
+
+ public override void Begin(PlayerTask task)
+ {
+ base.Begin(task);
+ int num = 2;
+ int num2 = this.Buttons.Length / num;
+ float[] array = FloatRange.SpreadToEdges(-1.7f, 1.7f, num2).ToArray<float>();
+ float[] array2 = FloatRange.SpreadToEdges(-0.43f, 0.43f, num).ToArray<float>();
+ SpriteRenderer[] array3 = this.Buttons.ToArray<SpriteRenderer>();
+ array3.Shuffle<SpriteRenderer>();
+ for (int i = 0; i < num2; i++)
+ {
+ for (int j = 0; j < num; j++)
+ {
+ int num3 = i + j * num2;
+ array3[num3].transform.localPosition = new Vector3(array[i], array2[j], 0f);
+ }
+ }
+ }
+
+ public void HitButton(int idx)
+ {
+ if (this.MyNormTask.IsComplete)
+ {
+ return;
+ }
+ if (this.animating)
+ {
+ return;
+ }
+ if (Constants.ShouldPlaySfx())
+ {
+ SoundManager.Instance.PlaySound(this.PressButtonSound, false, 1f).pitch = Mathf.Lerp(0.5f, 1.5f, (float)idx / 10f);
+ }
+ if (idx == this.buttonCounter)
+ {
+ this.Buttons[idx].color = Color.green;
+ this.buttonCounter++;
+ if (this.buttonCounter == this.Buttons.Length)
+ {
+ this.MyNormTask.NextStep();
+ base.StartCoroutine(base.CoStartClose(0.75f));
+ return;
+ }
+ }
+ else
+ {
+ this.buttonCounter = 0;
+ base.StartCoroutine(this.ResetAll());
+ }
+ }
+
+ private IEnumerator ResetAll()
+ {
+ if (Constants.ShouldPlaySfx())
+ {
+ SoundManager.Instance.PlaySound(this.FailSound, false, 1f);
+ }
+ this.animating = true;
+ for (int i = 0; i < this.Buttons.Length; i++)
+ {
+ this.Buttons[i].color = Color.red;
+ }
+ yield return new WaitForSeconds(0.25f);
+ for (int j = 0; j < this.Buttons.Length; j++)
+ {
+ this.Buttons[j].color = Color.white;
+ }
+ yield return new WaitForSeconds(0.25f);
+ for (int k = 0; k < this.Buttons.Length; k++)
+ {
+ this.Buttons[k].color = Color.red;
+ }
+ yield return new WaitForSeconds(0.25f);
+ for (int l = 0; l < this.Buttons.Length; l++)
+ {
+ this.Buttons[l].color = Color.white;
+ }
+ this.animating = false;
+ yield break;
+ }
+}