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.Instance.GetString(StringNames.ExileTextPP, new object[] { exiled.PlayerName }); } else { this.completeString = DestroyableSingleton.Instance.GetString(StringNames.ExileTextSP, new object[] { exiled.PlayerName }); } } else if (num2 > 1) { this.completeString = DestroyableSingleton.Instance.GetString(StringNames.ExileTextPN, new object[] { exiled.PlayerName }); } else { this.completeString = DestroyableSingleton.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.Instance.GetSkinById(exiled.SkinId).EjectFrame; if (exiled.IsImpostor) { num--; } } else { if (tie) { this.completeString = DestroyableSingleton.Instance.GetString(StringNames.NoExileTie, Array.Empty()); } else { this.completeString = DestroyableSingleton.Instance.GetString(StringNames.NoExileSkip, Array.Empty()); } this.Player.gameObject.SetActive(false); } if (num == 1) { this.ImpostorText.Text = DestroyableSingleton.Instance.GetString(StringNames.ImpostorsRemainS, new object[] { num }); } else { this.ImpostorText.Text = DestroyableSingleton.Instance.GetString(StringNames.ImpostorsRemainP, new object[] { num }); } base.StartCoroutine(this.Animate()); } private IEnumerator Animate() { yield return DestroyableSingleton.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.Instance.CoFadeFullScreen(Color.clear, Color.black, 0.2f); if (this.exiled != null) { PlayerControl @object = this.exiled.Object; if (@object != null) { @object.Exiled(); } } if (DestroyableSingleton.InstanceExists || !ShipStatus.Instance.IsGameOverDueToDeath()) { DestroyableSingleton.Instance.StartCoroutine(DestroyableSingleton.Instance.CoFadeFullScreen(Color.black, Color.clear, 0.2f)); PlayerControl.LocalPlayer.SetKillTimer(PlayerControl.GameOptions.KillCooldown); ShipStatus.Instance.EmergencyCooldown = (float)PlayerControl.GameOptions.EmergencyCooldown; Camera.main.GetComponent().Locked = false; DestroyableSingleton.Instance.SetHudActive(true); } UnityEngine.Object.Destroy(base.gameObject); yield break; } }