summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/UnlockManifoldsMinigame.cs
blob: 16f62694038f33fc5f4d0d0e1f9bcd0e66bfb009 (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
99
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;
	}
}