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.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.Instance.NotConnecting(); yield break; } public void StartIcon() { this.connectIcon.Play(this.connectClip, 1f); } public void StopIcon() { this.connectIcon.Stop(); this.connectIcon.GetComponent().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); } }