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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Assets.CoreScripts;
using InnerNet;
using UnityEngine;
public class EndGameManager : DestroyableSingleton<EndGameManager>
{
public TextRenderer WinText;
public MeshRenderer BackgroundBar;
public MeshRenderer Foreground;
public FloatRange ForegroundRadius;
public SpriteRenderer FrontMost;
public PoolablePlayer PlayerPrefab;
public Sprite GhostSprite;
public SpriteRenderer PlayAgainButton;
public SpriteRenderer ExitButton;
public AudioClip DisconnectStinger;
public AudioClip CrewStinger;
public AudioClip ImpostorStinger;
public float BaseY = -0.25f;
private float stingerTime;
public void Start()
{
if (TempData.showAd && !SaveManager.BoughtNoAds)
{
AdPlayer.RequestInterstitial();
}
this.SetEverythingUp();
base.StartCoroutine(this.CoBegin());
base.Invoke("ShowButtons", 1.1f);
}
private void ShowButtons()
{
this.FrontMost.gameObject.SetActive(false);
this.PlayAgainButton.gameObject.SetActive(true);
this.ExitButton.gameObject.SetActive(true);
}
private void SetEverythingUp()
{
StatsManager instance = StatsManager.Instance;
uint gamesFinished = instance.GamesFinished;
instance.GamesFinished = gamesFinished + 1U;
bool flag = TempData.DidHumansWin(TempData.EndReason);
if (TempData.EndReason == GameOverReason.ImpostorDisconnect)
{
StatsManager.Instance.AddDrawReason(TempData.EndReason);
this.WinText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.ImpostorDisconnected, Array.Empty<object>());
SoundManager.Instance.PlaySound(this.DisconnectStinger, false, 1f);
}
else if (TempData.EndReason == GameOverReason.HumansDisconnect)
{
StatsManager.Instance.AddDrawReason(TempData.EndReason);
this.WinText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.CrewmatesDisconnected, Array.Empty<object>());
SoundManager.Instance.PlaySound(this.DisconnectStinger, false, 1f);
}
else
{
if (TempData.winners.Any((WinningPlayerData h) => h.IsYou))
{
StatsManager.Instance.AddWinReason(TempData.EndReason);
this.WinText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Victory, Array.Empty<object>());
this.BackgroundBar.material.SetColor("_Color", Palette.CrewmateBlue);
WinningPlayerData winningPlayerData = TempData.winners.FirstOrDefault((WinningPlayerData h) => h.IsYou);
if (winningPlayerData != null)
{
DestroyableSingleton<Telemetry>.Instance.WonGame(winningPlayerData.ColorId, winningPlayerData.HatId);
}
}
else
{
StatsManager.Instance.AddLoseReason(TempData.EndReason);
this.WinText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.Defeat, Array.Empty<object>());
this.WinText.Color = Color.red;
}
if (flag)
{
SoundManager.Instance.PlayDynamicSound("Stinger", this.CrewStinger, false, new DynamicSound.GetDynamicsFunction(this.GetStingerVol), false);
}
else
{
SoundManager.Instance.PlayDynamicSound("Stinger", this.ImpostorStinger, false, new DynamicSound.GetDynamicsFunction(this.GetStingerVol), false);
}
}
List<WinningPlayerData> list = TempData.winners.OrderBy(delegate(WinningPlayerData b)
{
if (!b.IsYou)
{
return 0;
}
return -1;
}).ToList<WinningPlayerData>();
for (int i = 0; i < list.Count; i++)
{
WinningPlayerData winningPlayerData2 = list[i];
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(0.8f * (float)num * (float)num2 * num4, this.BaseY - 0.25f + (float)num2 * 0.1f, num5 + (float)num2 * 0.01f) * 1.25f;
Vector3 vector = new Vector3(num3, num3, num3) * 1.25f;
poolablePlayer.transform.localScale = vector;
if (winningPlayerData2.IsDead)
{
poolablePlayer.Body.sprite = this.GhostSprite;
poolablePlayer.SetDeadFlipX(i % 2 != 0);
}
else
{
poolablePlayer.SetFlipX(i % 2 == 0);
}
if (!winningPlayerData2.IsDead)
{
DestroyableSingleton<HatManager>.Instance.SetSkin(poolablePlayer.SkinSlot, winningPlayerData2.SkinId);
}
else
{
poolablePlayer.HatSlot.color = new Color(1f, 1f, 1f, 0.5f);
}
PlayerControl.SetPlayerMaterialColors(winningPlayerData2.ColorId, poolablePlayer.Body);
PlayerControl.SetHatImage(winningPlayerData2.HatId, poolablePlayer.HatSlot);
PlayerControl.SetPetImage(winningPlayerData2.PetId, winningPlayerData2.ColorId, poolablePlayer.PetSlot);
if (flag)
{
poolablePlayer.NameText.gameObject.SetActive(false);
}
else
{
poolablePlayer.NameText.Text = winningPlayerData2.Name;
if (winningPlayerData2.IsImpostor)
{
poolablePlayer.NameText.Color = Palette.ImpostorRed;
}
poolablePlayer.NameText.transform.localScale = vector.Inv();
}
}
}
private void GetStingerVol(AudioSource source, float dt)
{
this.stingerTime += dt * 0.75f;
source.volume = Mathf.Clamp(1f / this.stingerTime, 0f, 1f);
}
public IEnumerator CoBegin()
{
Color c = this.WinText.Color;
Color fade = Color.black;
Color white = Color.white;
Vector3 titlePos = this.WinText.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.WinText.Color = c;
titlePos.y = 2.7f - num * 0.3f;
this.WinText.transform.localPosition = titlePos;
yield return null;
}
this.FrontMost.gameObject.SetActive(false);
yield break;
}
public void NextGame()
{
this.PlayAgainButton.gameObject.SetActive(false);
this.ExitButton.gameObject.SetActive(false);
if (TempData.showAd && !SaveManager.BoughtNoAds)
{
TempData.showAd = false;
AdPlayer.ShowInterstitial(this, true);
return;
}
base.StartCoroutine(this.CoJoinGame());
}
public IEnumerator CoJoinGame()
{
AmongUsClient.Instance.JoinGame();
yield return EndGameManager.WaitWithTimeout(() => AmongUsClient.Instance.ClientId >= 0);
if (AmongUsClient.Instance.ClientId < 0)
{
AmongUsClient.Instance.ExitGame(AmongUsClient.Instance.LastDisconnectReason);
}
yield break;
}
public void Exit()
{
this.PlayAgainButton.gameObject.SetActive(false);
this.ExitButton.gameObject.SetActive(false);
if (TempData.showAd && !SaveManager.BoughtNoAds)
{
TempData.showAd = false;
AdPlayer.ShowInterstitial(this, false);
return;
}
AmongUsClient.Instance.ExitGame(DisconnectReasons.ExitGame);
}
public static IEnumerator WaitWithTimeout(Func<bool> success)
{
float timer = 0f;
while (timer < 5f && !success())
{
yield return null;
timer += Time.deltaTime;
}
yield break;
}
}
|