summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ExileController.cs
blob: 4a52a4d161b54cf013041ac5ef2c50955055eecd (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
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
using System;
using System.Collections;
using System.Linq;
using UnityEngine;

public class ExileController : MonoBehaviour
{
	public static ExileController Instance;

	public TextRenderer ImpostorText;

	public TextRenderer Text;

	public SpriteRenderer Player;

	public SpriteRenderer PlayerHat;

	public SpriteRenderer PlayerSkin;

	public AnimationCurve LerpCurve;

	public float Duration = 7f;

	public AudioClip TextSound;

	private string completeString = string.Empty;

	private GameData.PlayerInfo exiled;

	public void Begin(GameData.PlayerInfo exiled, bool tie)
	{
		ExileController.Instance = this;
		this.exiled = exiled;
		this.Text.gameObject.SetActive(false);
		this.Text.Text = string.Empty;
		int num = GameData.Instance.AllPlayers.Count((GameData.PlayerInfo p) => p.IsImpostor && !p.IsDead && !p.Disconnected);
		if (exiled != null)
		{
			int num2 = GameData.Instance.AllPlayers.Count((GameData.PlayerInfo p) => p.IsImpostor);
			if (exiled.IsImpostor)
			{
				if (num2 > 1)
				{
					this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ExileTextPP, new object[]
					{
						exiled.PlayerName
					});
				}
				else
				{
					this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ExileTextSP, new object[]
					{
						exiled.PlayerName
					});
				}
			}
			else if (num2 > 1)
			{
				this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ExileTextPN, new object[]
				{
					exiled.PlayerName
				});
			}
			else
			{
				this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ExileTextSN, new object[]
				{
					exiled.PlayerName
				});
			}
			PlayerControl.SetPlayerMaterialColors((int)exiled.ColorId, this.Player);
			PlayerControl.SetHatImage(exiled.HatId, this.PlayerHat);
			this.PlayerSkin.sprite = DestroyableSingleton<HatManager>.Instance.GetSkinById(exiled.SkinId).EjectFrame;
			if (exiled.IsImpostor)
			{
				num--;
			}
		}
		else
		{
			if (tie)
			{
				this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.NoExileTie, Array.Empty<object>());
			}
			else
			{
				this.completeString = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.NoExileSkip, Array.Empty<object>());
			}
			this.Player.gameObject.SetActive(false);
		}
		if (num == 1)
		{
			this.ImpostorText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ImpostorsRemainS, new object[]
			{
				num
			});
		}
		else
		{
			this.ImpostorText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ImpostorsRemainP, new object[]
			{
				num
			});
		}
		base.StartCoroutine(this.Animate());
	}

	private IEnumerator Animate()
	{
		yield return DestroyableSingleton<HudManager>.Instance.CoFadeFullScreen(Color.black, Color.clear, 0.2f);
		yield return new WaitForSeconds(1f);
		float d = Camera.main.orthographicSize * Camera.main.aspect + 1f;
		Vector2 left = Vector2.left * d;
		Vector2 right = Vector2.right * d;
		for (float t = 0f; t <= this.Duration; t += Time.deltaTime)
		{
			float num = t / this.Duration;
			this.Player.transform.localPosition = Vector2.Lerp(left, right, this.LerpCurve.Evaluate(num));
			float z = (t + 0.75f) * 25f / Mathf.Exp(t * 0.75f + 1f);
			this.Player.transform.Rotate(new Vector3(0f, 0f, z));
			if (num >= 0.3f)
			{
				int num2 = (int)(Mathf.Min(1f, (num - 0.3f) / 0.3f) * (float)this.completeString.Length);
				if (num2 > this.Text.Text.Length)
				{
					this.Text.Text = this.completeString.Substring(0, num2);
					this.Text.gameObject.SetActive(true);
					if (this.completeString[num2 - 1] != ' ')
					{
						SoundManager.Instance.PlaySoundImmediate(this.TextSound, false, 0.8f, 1f);
					}
				}
			}
			yield return null;
		}
		this.Text.Text = this.completeString;
		this.ImpostorText.gameObject.SetActive(true);
		yield return Effects.Bloop(0f, this.ImpostorText.transform, 0.5f);
		yield return new WaitForSeconds(0.5f);
		yield return DestroyableSingleton<HudManager>.Instance.CoFadeFullScreen(Color.clear, Color.black, 0.2f);
		if (this.exiled != null)
		{
			PlayerControl @object = this.exiled.Object;
			if (@object != null)
			{
				@object.Exiled();
			}
		}
		if (DestroyableSingleton<TutorialManager>.InstanceExists || !ShipStatus.Instance.IsGameOverDueToDeath())
		{
			DestroyableSingleton<HudManager>.Instance.StartCoroutine(DestroyableSingleton<HudManager>.Instance.CoFadeFullScreen(Color.black, Color.clear, 0.2f));
			PlayerControl.LocalPlayer.SetKillTimer(PlayerControl.GameOptions.KillCooldown);
			ShipStatus.Instance.EmergencyCooldown = (float)PlayerControl.GameOptions.EmergencyCooldown;
			Camera.main.GetComponent<FollowerCamera>().Locked = false;
			DestroyableSingleton<HudManager>.Instance.SetHudActive(true);
		}
		UnityEngine.Object.Destroy(base.gameObject);
		yield break;
	}
}