summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/MatchMakerGameButton.cs
blob: 64be6deb3b989e5fbda31024a9e62b759d570dca (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
using System;
using System.Collections;
using InnerNet;
using PowerTools;
using UnityEngine;

public class MatchMakerGameButton : PoolableBehavior, IConnectButton
{
	public TextRenderer NameText;

	public TextRenderer PlayerCountText;

	public TextRenderer ImpostorCountText;

	public SpriteAnim connectIcon;

	public AnimationClip connectClip;

	public GameListing myListing;

	public void OnClick()
	{
		if (!DestroyableSingleton<MatchMaker>.Instance.Connecting(this))
		{
			return;
		}
		AmongUsClient.Instance.GameMode = GameModes.OnlineGame;
		AmongUsClient.Instance.OnlineScene = "OnlineGame";
		AmongUsClient.Instance.GameId = this.myListing.GameId;
		AmongUsClient.Instance.JoinGame();
		base.StartCoroutine(this.ConnectForFindGame());
	}

	private IEnumerator ConnectForFindGame()
	{
		yield return EndGameManager.WaitWithTimeout(() => AmongUsClient.Instance.ClientId >= 0 || AmongUsClient.Instance.LastDisconnectReason > DisconnectReasons.ExitGame);
		DestroyableSingleton<MatchMaker>.Instance.NotConnecting();
		yield break;
	}

	public void StartIcon()
	{
		this.connectIcon.Play(this.connectClip, 1f);
	}

	public void StopIcon()
	{
		this.connectIcon.Stop();
		this.connectIcon.GetComponent<SpriteRenderer>().sprite = null;
	}

	public void SetGame(GameListing gameListing)
	{
		this.myListing = gameListing;
		this.NameText.Text = this.myListing.HostName;
		this.ImpostorCountText.Text = this.myListing.ImpostorCount.ToString();
		this.PlayerCountText.Text = string.Format("{0}/{1}", this.myListing.PlayerCount, this.myListing.MaxPlayers);
	}
}