summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/MatchMakerGameButton.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/MatchMakerGameButton.cs')
-rw-r--r--Client/Assembly-CSharp/MatchMakerGameButton.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/MatchMakerGameButton.cs b/Client/Assembly-CSharp/MatchMakerGameButton.cs
new file mode 100644
index 0000000..64be6de
--- /dev/null
+++ b/Client/Assembly-CSharp/MatchMakerGameButton.cs
@@ -0,0 +1,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);
+ }
+}