blob: 4013635aed903bfb719b4d3ffbe847568a05509b (
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
|
using System;
using UnityEngine;
public class SwitchMinigame : Minigame
{
public Color OnColor = Color.green;
public Color OffColor = new Color(0.1f, 0.3f, 0.1f);
private ShipStatus ship;
public SpriteRenderer[] switches;
public SpriteRenderer[] lights;
public RadioWaveBehaviour top;
public HorizontalGauge middle;
public FlatWaveBehaviour bottom;
public override void Begin(PlayerTask task)
{
this.ship = UnityEngine.Object.FindObjectOfType<ShipStatus>();
SwitchSystem switchSystem = this.ship.Systems[SystemTypes.Electrical] as SwitchSystem;
for (int i = 0; i < this.switches.Length; i++)
{
byte b = (byte)(1 << i);
int num = (int)(switchSystem.ActualSwitches & b);
this.lights[i].color = ((num == (int)(switchSystem.ExpectedSwitches & b)) ? this.OnColor : this.OffColor);
this.switches[i].flipY = (num >> i == 0);
}
}
public void FixedUpdate()
{
if (this.amClosing != Minigame.CloseState.None)
{
return;
}
int num = 0;
SwitchSystem switchSystem = this.ship.Systems[SystemTypes.Electrical] as SwitchSystem;
for (int i = 0; i < this.switches.Length; i++)
{
byte b = (byte)(1 << i);
int num2 = (int)(switchSystem.ActualSwitches & b);
if (num2 == (int)(switchSystem.ExpectedSwitches & b))
{
num++;
this.lights[i].color = this.OnColor;
}
else
{
this.lights[i].color = this.OffColor;
}
this.switches[i].flipY = (num2 >> i == 0);
}
float num3 = (float)num / (float)this.switches.Length;
this.bottom.Center = 0.47f * num3;
this.top.NoiseLevel = 1f - num3;
this.middle.Value = switchSystem.Level + (Mathf.PerlinNoise(0f, Time.time * 51f) - 0.5f) * 0.04f;
if (num == this.switches.Length)
{
base.StartCoroutine(base.CoStartClose(0.5f));
}
}
public void FlipSwitch(int switchIdx)
{
if (this.amClosing != Minigame.CloseState.None)
{
return;
}
int num = 0;
SwitchSystem switchSystem = this.ship.Systems[SystemTypes.Electrical] as SwitchSystem;
for (int i = 0; i < this.switches.Length; i++)
{
byte b = (byte)(1 << i);
if ((switchSystem.ActualSwitches & b) == (switchSystem.ExpectedSwitches & b))
{
num++;
}
}
if (num == this.switches.Length)
{
return;
}
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Electrical, (int)((byte)switchIdx));
try
{
((SabotageTask)this.MyTask).MarkContributed();
}
catch
{
}
}
}
|