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
|
using System;
using UnityEngine;
public class TuneRadioMinigame : Minigame
{
public RadioWaveBehaviour actualSignal;
public DialBehaviour dial;
public SpriteRenderer redLight;
public SpriteRenderer greenLight;
public float Tolerance = 0.1f;
public float targetAngle;
public bool finished;
private float steadyTimer;
public AudioClip StaticSound;
public AudioClip RadioSound;
public override void Begin(PlayerTask task)
{
base.Begin(task);
this.targetAngle = this.dial.DialRange.Next();
if (Constants.ShouldPlaySfx())
{
SoundManager.Instance.PlayDynamicSound("CommsRadio", this.RadioSound, true, new DynamicSound.GetDynamicsFunction(this.GetRadioVolume), true);
SoundManager.Instance.PlayDynamicSound("RadioStatic", this.StaticSound, true, new DynamicSound.GetDynamicsFunction(this.GetStaticVolume), true);
}
}
private void GetRadioVolume(AudioSource player, float dt)
{
player.volume = 1f - this.actualSignal.NoiseLevel;
}
private void GetStaticVolume(AudioSource player, float dt)
{
player.volume = this.actualSignal.NoiseLevel;
}
public void Update()
{
if (this.finished)
{
return;
}
float f = Mathf.Abs((this.targetAngle - this.dial.Value) / this.dial.DialRange.Width) * 2f;
this.actualSignal.NoiseLevel = Mathf.Clamp(Mathf.Sqrt(f), 0f, 1f);
if (this.actualSignal.NoiseLevel <= this.Tolerance)
{
this.redLight.color = new Color(0.35f, 0f, 0f);
if (!this.dial.Engaged)
{
this.FinishGame();
return;
}
this.steadyTimer += Time.deltaTime;
if (this.steadyTimer > 1.5f)
{
this.FinishGame();
return;
}
}
else
{
this.redLight.color = new Color(1f, 0f, 0f);
this.steadyTimer = 0f;
}
}
private void FinishGame()
{
this.greenLight.color = Color.green;
this.finished = true;
this.dial.enabled = false;
this.dial.SetValue(this.targetAngle);
this.actualSignal.NoiseLevel = 0f;
if (PlayerControl.LocalPlayer)
{
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 0);
}
base.StartCoroutine(base.CoStartClose(0.75f));
try
{
((SabotageTask)this.MyTask).MarkContributed();
}
catch
{
}
}
public override void Close()
{
SoundManager.Instance.StopSound(this.StaticSound);
SoundManager.Instance.StopSound(this.RadioSound);
base.Close();
}
}
|