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
|
using System;
using System.Collections;
using System.Linq;
using UnityEngine;
public class EmergencyMinigame : Minigame
{
public SpriteRenderer ClosedLid;
public SpriteRenderer OpenLid;
public Transform meetingButton;
public TextRenderer StatusText;
public TextRenderer NumberText;
public bool ButtonActive = true;
public AudioClip ButtonSound;
private int state;
public const int MinEmergencyTime = 15;
public override void Begin(PlayerTask task)
{
base.Begin(task);
this.Update();
}
public void Update()
{
if (ShipStatus.Instance.Timer < 15f || ShipStatus.Instance.EmergencyCooldown > 0f)
{
int num = Mathf.CeilToInt(15f - ShipStatus.Instance.Timer);
num = Mathf.Max(Mathf.CeilToInt(ShipStatus.Instance.EmergencyCooldown), num);
this.ButtonActive = false;
this.StatusText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EmergencyNotReady, Array.Empty<object>());
this.NumberText.Text = num + "s";
this.ClosedLid.gameObject.SetActive(true);
this.OpenLid.gameObject.SetActive(false);
return;
}
if (!PlayerControl.LocalPlayer.myTasks.Any(new Func<PlayerTask, bool>(PlayerTask.TaskIsEmergency)))
{
if (this.state == 1)
{
return;
}
this.state = 1;
int remainingEmergencies = PlayerControl.LocalPlayer.RemainingEmergencies;
this.StatusText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EmergencyCount, new object[]
{
PlayerControl.LocalPlayer.Data.PlayerName
});
this.NumberText.Text = remainingEmergencies.ToString();
this.ButtonActive = (remainingEmergencies > 0);
this.ClosedLid.gameObject.SetActive(!this.ButtonActive);
this.OpenLid.gameObject.SetActive(this.ButtonActive);
return;
}
else
{
if (this.state == 2)
{
return;
}
this.state = 2;
this.ButtonActive = false;
this.StatusText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EmergencyDuringCrisis, Array.Empty<object>());
this.NumberText.Text = string.Empty;
this.ClosedLid.gameObject.SetActive(true);
this.OpenLid.gameObject.SetActive(false);
return;
}
}
public void CallMeeting()
{
if (!PlayerControl.LocalPlayer.myTasks.Any(new Func<PlayerTask, bool>(PlayerTask.TaskIsEmergency)) && PlayerControl.LocalPlayer.RemainingEmergencies > 0 && this.ButtonActive)
{
this.StatusText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EmergencyRequested, Array.Empty<object>());
if (Constants.ShouldPlaySfx())
{
SoundManager.Instance.PlaySound(this.ButtonSound, false, 1f);
}
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
this.ButtonActive = false;
}
}
private float easeOutElastic(float t)
{
float num = 0.3f;
return Mathf.Pow(2f, -10f * t) * Mathf.Sin((t - num / 4f) * 6.2831855f / num) + 1f;
}
protected override IEnumerator CoAnimateOpen()
{
for (float timer = 0f; timer < 0.2f; timer += Time.deltaTime)
{
float t = timer / 0.2f;
base.transform.localPosition = new Vector3(0f, Mathf.SmoothStep(-8f, 0f, t), -50f);
yield return null;
}
base.transform.localPosition = new Vector3(0f, 0f, -50f);
Vector3 meetingPos = this.meetingButton.localPosition;
for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime)
{
float num = timer / 0.1f;
meetingPos.y = Mathf.Sin(3.1415927f * num) * 1f / (num * 5f + 4f) - 0.882f;
this.meetingButton.localPosition = meetingPos;
yield return null;
}
meetingPos.y = -0.882f;
this.meetingButton.localPosition = meetingPos;
yield break;
}
}
|