using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class IntroCutscene : MonoBehaviour { public static IntroCutscene Instance; public TextRenderer Title; public TextRenderer ImpostorText; public PoolablePlayer PlayerPrefab; public MeshRenderer BackgroundBar; public MeshRenderer Foreground; public FloatRange ForegroundRadius; public SpriteRenderer FrontMost; public AudioClip IntroStinger; public float BaseY = -0.25f; public IEnumerator CoBegin(List yourTeam, bool isImpostor) { SoundManager.Instance.PlaySound(this.IntroStinger, false, 1f); if (!isImpostor) { this.BeginCrewmate(yourTeam); } else { this.BeginImpostor(yourTeam); } Color c = this.Title.Color; Color fade = Color.black; Color impColor = Color.white; Vector3 titlePos = this.Title.transform.localPosition; float timer = 0f; while (timer < 3f) { timer += Time.deltaTime; float num = Mathf.Min(1f, timer / 3f); this.Foreground.material.SetFloat("_Rad", this.ForegroundRadius.ExpOutLerp(num * 2f)); fade.a = Mathf.Lerp(1f, 0f, num * 3f); this.FrontMost.color = fade; c.a = Mathf.Clamp(FloatRange.ExpOutLerp(num, 0f, 1f), 0f, 1f); this.Title.Color = c; impColor.a = Mathf.Lerp(0f, 1f, (num - 0.3f) * 3f); this.ImpostorText.Color = impColor; titlePos.y = 2.7f - num * 0.3f; this.Title.transform.localPosition = titlePos; yield return null; } timer = 0f; while (timer < 1f) { timer += Time.deltaTime; float num2 = timer / 1f; fade.a = Mathf.Lerp(0f, 1f, num2 * 3f); this.FrontMost.color = fade; yield return null; } UnityEngine.Object.Destroy(base.gameObject); yield break; } private void BeginCrewmate(List yourTeam) { Vector3 position = this.BackgroundBar.transform.position; position.y -= 0.25f; this.BackgroundBar.transform.position = position; int adjustedNumImpostors = PlayerControl.GameOptions.GetAdjustedNumImpostors(GameData.Instance.PlayerCount); if (adjustedNumImpostors == 1) { this.ImpostorText.Text = DestroyableSingleton.Instance.GetString(StringNames.NumImpostorsS, Array.Empty()); } else { this.ImpostorText.Text = DestroyableSingleton.Instance.GetString(StringNames.NumImpostorsP, new object[] { adjustedNumImpostors }); } this.BackgroundBar.material.SetColor("_Color", Palette.CrewmateBlue); this.Title.Text = DestroyableSingleton.Instance.GetString(StringNames.Crewmate, Array.Empty()); this.Title.Color = Palette.CrewmateBlue; for (int i = 0; i < yourTeam.Count; i++) { PlayerControl playerControl = yourTeam[i]; if (playerControl) { GameData.PlayerInfo data = playerControl.Data; if (data != null) { int num = (i % 2 == 0) ? -1 : 1; int num2 = (i + 1) / 2; float num3 = ((i == 0) ? 1.2f : 1f) - (float)num2 * 0.12f; float num4 = 1f - (float)num2 * 0.08f; float num5 = (float)((i == 0) ? -8 : -1); PoolablePlayer poolablePlayer = UnityEngine.Object.Instantiate(this.PlayerPrefab, base.transform); poolablePlayer.name = data.PlayerName + "Dummy"; poolablePlayer.SetFlipX(i % 2 == 0); poolablePlayer.transform.localPosition = new Vector3(0.8f * (float)num * (float)num2 * num4, this.BaseY - 0.25f + (float)num2 * 0.1f, num5 + (float)num2 * 0.01f) * 1.5f; Vector3 localScale = new Vector3(num3, num3, num3) * 1.5f; poolablePlayer.transform.localScale = localScale; PlayerControl.SetPlayerMaterialColors((int)data.ColorId, poolablePlayer.Body); DestroyableSingleton.Instance.SetSkin(poolablePlayer.SkinSlot, data.SkinId); PlayerControl.SetHatImage(data.HatId, poolablePlayer.HatSlot); PlayerControl.SetPetImage(data.PetId, (int)data.ColorId, poolablePlayer.PetSlot); poolablePlayer.NameText.gameObject.SetActive(false); } } } } private void BeginImpostor(List yourTeam) { this.ImpostorText.gameObject.SetActive(false); this.Title.Text = DestroyableSingleton.Instance.GetString(StringNames.Impostor, Array.Empty()); this.Title.Color = Palette.ImpostorRed; for (int i = 0; i < yourTeam.Count; i++) { PlayerControl playerControl = yourTeam[i]; if (playerControl) { GameData.PlayerInfo data = playerControl.Data; if (data != null) { int num = (i % 2 == 0) ? -1 : 1; int num2 = (i + 1) / 2; float num3 = 1f - (float)num2 * 0.075f; float num4 = 1f - (float)num2 * 0.035f; float num5 = (float)((i == 0) ? -8 : -1); PoolablePlayer poolablePlayer = UnityEngine.Object.Instantiate(this.PlayerPrefab, base.transform); poolablePlayer.transform.localPosition = new Vector3((float)(num * num2) * num4, this.BaseY + (float)num2 * 0.15f, num5 + (float)num2 * 0.01f) * 1.5f; Vector3 vector = new Vector3(num3, num3, num3) * 1.5f; poolablePlayer.transform.localScale = vector; poolablePlayer.SetFlipX(i % 2 == 1); PlayerControl.SetPlayerMaterialColors((int)data.ColorId, poolablePlayer.Body); DestroyableSingleton.Instance.SetSkin(poolablePlayer.SkinSlot, data.SkinId); PlayerControl.SetHatImage(data.HatId, poolablePlayer.HatSlot); PlayerControl.SetPetImage(data.PetId, (int)data.ColorId, poolablePlayer.PetSlot); TextRenderer nameText = poolablePlayer.NameText; nameText.Text = data.PlayerName; nameText.transform.localScale = vector.Inv(); } } } } }