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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
using System;
using System.Collections;
using UnityEngine;
public class AlignGame : Minigame
{
private Controller myController = new Controller();
public FloatRange YRange = new FloatRange(-0.425f, 0.425f);
public AnimationCurve curve;
public LineRenderer centerline;
public LineRenderer[] guidelines;
public SpriteRenderer engine;
public Collider2D col;
public TextController StatusText;
private float pulseTimer;
public override void Begin(PlayerTask task)
{
base.Begin(task);
float value = AlignGame.FromByte(this.MyNormTask.Data[base.ConsoleId]);
bool flag = AlignGame.IsSuccess(this.MyNormTask.Data[base.ConsoleId]);
Vector3 localPosition = this.col.transform.localPosition;
localPosition.y = this.YRange.Clamp(value);
float num = this.YRange.ReverseLerp(localPosition.y);
localPosition.x = this.curve.Evaluate(num);
this.col.transform.eulerAngles = new Vector3(0f, 0f, Mathf.Lerp(20f, -20f, num));
this.engine.transform.eulerAngles = new Vector3(0f, 0f, Mathf.Lerp(45f, -45f, num));
this.centerline.material.SetColor("_Color", flag ? Color.green : Color.red);
this.engine.color = (flag ? Color.green : Color.red);
this.col.transform.localPosition = localPosition;
this.guidelines[0].enabled = flag;
this.guidelines[1].enabled = flag;
this.StatusText.gameObject.SetActive(flag);
}
public void Update()
{
this.centerline.material.SetTextureOffset("_MainTex", new Vector2(Time.time, 0f));
this.guidelines[0].material.SetTextureOffset("_MainTex", new Vector2(Time.time, 0f));
this.guidelines[1].material.SetTextureOffset("_MainTex", new Vector2(Time.time, 0f));
if (this.MyTask && this.MyNormTask.IsComplete)
{
return;
}
Vector3 localPosition = this.col.transform.localPosition;
bool flag = AlignGame.IsSuccess(this.MyNormTask.Data[base.ConsoleId]);
bool flag2 = AlignGame.IsSuccess(AlignGame.ToByte(localPosition.y));
this.myController.Update();
switch (this.myController.CheckDrag(this.col, false))
{
case DragState.TouchStart:
this.pulseTimer = 0f;
break;
case DragState.Dragging:
if (!flag)
{
Vector2 vector = this.myController.DragPosition - base.transform.position;
float num = this.YRange.ReverseLerp(localPosition.y);
localPosition.y = this.YRange.Clamp(vector.y);
float num2 = this.YRange.ReverseLerp(localPosition.y);
localPosition.x = this.curve.Evaluate(num2);
this.col.transform.eulerAngles = new Vector3(0f, 0f, Mathf.Lerp(20f, -20f, num2));
this.engine.transform.eulerAngles = new Vector3(0f, 0f, Mathf.Lerp(45f, -45f, num2));
this.centerline.material.SetColor("_Color", flag2 ? Color.green : Color.red);
if (Mathf.Abs(num2 - num) > 0.001f)
{
this.pulseTimer += Time.deltaTime * 25f;
int num3 = (int)this.pulseTimer % 3;
if (num3 > 1)
{
if (num3 == 2)
{
this.engine.color = Color.clear;
}
}
else
{
this.engine.color = Color.red;
}
}
else
{
this.engine.color = Color.red;
}
}
break;
case DragState.Released:
if (!flag && flag2)
{
base.StartCoroutine(this.LockEngine());
this.MyNormTask.Data[base.ConsoleId] = AlignGame.ToByte(localPosition.y);
this.MyNormTask.NextStep();
base.StartCoroutine(base.CoStartClose(0.75f));
}
break;
}
this.col.transform.localPosition = localPosition;
}
private IEnumerator LockEngine()
{
int num;
for (int i = 0; i < 3; i = num)
{
this.guidelines[0].enabled = true;
this.guidelines[1].enabled = true;
yield return new WaitForSeconds(0.1f);
this.guidelines[0].enabled = false;
this.guidelines[1].enabled = false;
yield return new WaitForSeconds(0.1f);
num = i + 1;
}
this.StatusText.gameObject.SetActive(true);
Color green = new Color(0f, 0.7f, 0f);
yield return new WaitForLerp(1f, delegate(float t)
{
this.engine.color = Color.Lerp(Color.white, green, t);
});
this.guidelines[0].enabled = true;
this.guidelines[1].enabled = true;
yield break;
}
public static float FromByte(byte b)
{
return (float)b * 0.025f - 3f;
}
public static byte ToByte(float y)
{
return (byte)((y + 3f) / 0.025f);
}
public static bool IsSuccess(byte b)
{
return Mathf.Abs(AlignGame.FromByte(b)) <= 0.05f;
}
}
|