summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/EmergencyMinigame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/EmergencyMinigame.cs')
-rw-r--r--Client/Assembly-CSharp/EmergencyMinigame.cs120
1 files changed, 120 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/EmergencyMinigame.cs b/Client/Assembly-CSharp/EmergencyMinigame.cs
new file mode 100644
index 0000000..5b6bff6
--- /dev/null
+++ b/Client/Assembly-CSharp/EmergencyMinigame.cs
@@ -0,0 +1,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;
+ }
+}