summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/IntroCutscene.cs
blob: 3271c11572760ad68ed4adfce534fc409651d316 (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
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<PlayerControl> 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<PlayerControl> 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<TranslationController>.Instance.GetString(StringNames.NumImpostorsS, Array.Empty<object>());
		}
		else
		{
			this.ImpostorText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.NumImpostorsP, new object[]
			{
				adjustedNumImpostors
			});
		}
		this.BackgroundBar.material.SetColor("_Color", Palette.CrewmateBlue);
		this.Title.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Crewmate, Array.Empty<object>());
		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<PoolablePlayer>(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<HatManager>.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<PlayerControl> yourTeam)
	{
		this.ImpostorText.gameObject.SetActive(false);
		this.Title.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Impostor, Array.Empty<object>());
		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<PoolablePlayer>(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<HatManager>.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();
				}
			}
		}
	}
}