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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
using System;
using System.Collections;
using System.Text;
using UnityEngine;
public class MedScanMinigame : Minigame
{
private static readonly string[] ColorNames = new string[]
{
"Red",
"Blue",
"Green",
"Pink",
"Orange",
"Yellow",
"Black",
"White",
"Purple",
"Brown",
"Cyan",
"Lime"
};
private static readonly string[] BloodTypes = new string[]
{
"O-",
"A-",
"B-",
"AB-",
"O+",
"A+",
"B+",
"AB+"
};
public TextRenderer text;
public TextRenderer charStats;
public HorizontalGauge gauge;
private MedScanSystem medscan;
public float ScanDuration = 10f;
public float ScanTimer;
private string completeString;
public AudioClip ScanSound;
public AudioClip TextSound;
private Coroutine walking;
private MedScanMinigame.PositionState state;
private enum PositionState
{
None,
WalkingToPad,
WalkingToOffset
}
public override void Begin(PlayerTask task)
{
base.Begin(task);
this.medscan = (ShipStatus.Instance.Systems[SystemTypes.MedBay] as MedScanSystem);
this.gauge.Value = 0f;
base.transform.position = new Vector3(100f, 0f, 0f);
GameData.PlayerInfo data = PlayerControl.LocalPlayer.Data;
int playerId = (int)data.PlayerId;
int colorId = (int)data.ColorId;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("ID: ");
stringBuilder.Append(MedScanMinigame.ColorNames[colorId].Substring(0, 3).ToUpperInvariant());
stringBuilder.Append("P" + playerId);
stringBuilder.Append(new string(' ', 8));
stringBuilder.Append("HT: 3' 6\"");
stringBuilder.Append(new string(' ', 8));
stringBuilder.Append("WT: 92lb");
stringBuilder.AppendLine();
stringBuilder.Append("C: ");
stringBuilder.Append(MedScanMinigame.ColorNames[colorId].PadRight(17));
stringBuilder.Append("BT: ");
stringBuilder.Append(MedScanMinigame.BloodTypes[playerId * 3 % MedScanMinigame.BloodTypes.Length]);
this.completeString = stringBuilder.ToString();
this.charStats.Text = string.Empty;
ShipStatus.Instance.RpcRepairSystem(SystemTypes.MedBay, playerId | 128);
this.walking = base.StartCoroutine(this.WalkToOffset());
}
private IEnumerator WalkToOffset()
{
this.state = MedScanMinigame.PositionState.WalkingToOffset;
PlayerPhysics myPhysics = PlayerControl.LocalPlayer.MyPhysics;
Vector2 vector = ShipStatus.Instance.MedScanner.transform.position;
Vector2 a = Vector2.left.Rotate((float)(PlayerControl.LocalPlayer.PlayerId * 36));
vector += a / 2f;
Camera.main.GetComponent<FollowerCamera>().Locked = false;
yield return myPhysics.WalkPlayerTo(vector, 0.001f);
yield return new WaitForSeconds(0.1f);
Camera.main.GetComponent<FollowerCamera>().Locked = true;
this.walking = null;
yield break;
}
private IEnumerator WalkToPad()
{
this.state = MedScanMinigame.PositionState.WalkingToPad;
PlayerPhysics myPhysics = PlayerControl.LocalPlayer.MyPhysics;
Vector2 worldPos = ShipStatus.Instance.MedScanner.transform.position;
worldPos.x += 0.14f;
worldPos.y += 0.1f;
Camera.main.GetComponent<FollowerCamera>().Locked = false;
yield return myPhysics.WalkPlayerTo(worldPos, 0.001f);
yield return new WaitForSeconds(0.1f);
Camera.main.GetComponent<FollowerCamera>().Locked = true;
this.walking = null;
yield break;
}
private void FixedUpdate()
{
if (this.MyNormTask.IsComplete)
{
return;
}
byte playerId = PlayerControl.LocalPlayer.PlayerId;
if (this.medscan.CurrentUser != playerId)
{
if (this.medscan.CurrentUser == 255)
{
this.text.Text = "Scan requested";
return;
}
GameData.PlayerInfo playerById = GameData.Instance.GetPlayerById(this.medscan.CurrentUser);
this.text.Text = "Waiting for " + playerById.PlayerName;
return;
}
else
{
if (this.state != MedScanMinigame.PositionState.WalkingToPad)
{
if (this.walking != null)
{
base.StopCoroutine(this.walking);
}
this.walking = base.StartCoroutine(this.WalkToPad());
return;
}
if (this.walking != null)
{
return;
}
if (this.ScanTimer == 0f)
{
PlayerControl.LocalPlayer.RpcSetScanner(true);
SoundManager.Instance.PlaySound(this.ScanSound, false, 1f);
}
this.ScanTimer += Time.fixedDeltaTime;
this.gauge.Value = this.ScanTimer / this.ScanDuration;
int num = (int)(Mathf.Min(1f, this.ScanTimer / this.ScanDuration * 1.25f) * (float)this.completeString.Length);
if (num > this.charStats.Text.Length)
{
this.charStats.Text = this.completeString.Substring(0, num);
if (this.completeString[num - 1] != ' ')
{
SoundManager.Instance.PlaySoundImmediate(this.TextSound, false, 0.7f, 0.3f);
}
}
if (this.ScanTimer >= this.ScanDuration)
{
PlayerControl.LocalPlayer.RpcSetScanner(false);
this.text.Text = "Scan complete";
this.MyNormTask.NextStep();
ShipStatus.Instance.RpcRepairSystem(SystemTypes.MedBay, (int)(playerId | 64));
base.StartCoroutine(base.CoStartClose(0.75f));
return;
}
this.text.Text = "Scan complete in: " + (int)(this.ScanDuration - this.ScanTimer);
return;
}
}
public override void Close()
{
base.StopAllCoroutines();
byte playerId = PlayerControl.LocalPlayer.PlayerId;
SoundManager.Instance.StopSound(this.TextSound);
SoundManager.Instance.StopSound(this.ScanSound);
PlayerControl.LocalPlayer.RpcSetScanner(false);
ShipStatus.Instance.RpcRepairSystem(SystemTypes.MedBay, (int)(playerId | 64));
Camera.main.GetComponent<FollowerCamera>().Locked = false;
base.Close();
}
}
|