Beispiel #1
0
        protected virtual void OnJoinLobbyClick(GameInfoPacket packet)
        {
            var loadingPromise = Msf.Events.FireWithPromise(Msf.EventNames.ShowLoading, "Joining lobby");

            Msf.Client.Lobbies.JoinLobby(packet.Id, (lobby, error) => {
                loadingPromise.Finish();

                if (lobby == null)
                {
                    Msf.Events.Fire(Msf.EventNames.ShowDialogBox, DialogBoxData.CreateError(error));
                    return;
                }

                // Hide this window
                gameObject.SetActive(false);

                var lobbyUi = FindObjectOfType <LobbyUi>();

                if (lobbyUi == null && MsfUi.Instance != null)
                {
                    lobbyUi = MsfUi.Instance.LobbyUi;
                }

                if (lobbyUi == null)
                {
                    Logs.Error("Couldn't find appropriate UI element to display lobby data in the scene. " +
                               "Override OnJoinLobbyClick method, if you want to handle this differently");
                    return;
                }

                lobbyUi.gameObject.SetActive(true);
                lobby.SetListener(lobbyUi);
            });
        }
        /// <summary>
        /// Test sign in callback
        /// </summary>
        /// <param name="accountInfo"></param>
        /// <param name="error"></param>
        private void SignInCallback(AccountInfoPacket accountInfo, string error)
        {
            if (accountInfo == null)
            {
                logger.Error(error);
                return;
            }

            logger.Debug($"Signed in successfully as {accountInfo.Username}");
            logger.Debug("Finding games...");

            Msf.Client.Matchmaker.FindGames((games) =>
            {
                if (games.Count == 0)
                {
                    logger.Error("No test game found");
                    return;
                }

                logger.Debug($"Found {games.Count} games");

                // Get first game fromlist
                GameInfoPacket firstGame = games.First();

                // Let's try to get access data for room we want to connect to
                GetRoomAccess(firstGame.Id);
            });
        }
Beispiel #3
0
        public void Setup(GameInfoPacket data)
        {
            RawData = data;
            IsLobby = data.Type == GameInfoType.Lobby;
            SetIsSelected(false);
            Name.text = data.Name;
            GameId    = data.Id;
            LockImage.SetActive(data.IsPasswordProtected);

            if (data.MaxPlayers > 0)
            {
                Online.text = string.Format("{0}/{1}", data.OnlinePlayers, data.MaxPlayers);
            }
            else
            {
                Online.text = data.OnlinePlayers.ToString();
            }

            MapName.text = data.Properties.ContainsKey(MsfDictKeys.MapName)
                ? data.Properties[MsfDictKeys.MapName] : UnknownMapName;
        }
Beispiel #4
0
        protected virtual void OnJoinLobbyClick(GameInfoPacket packet)
        {
            client.GetPlugin <LobbyPlugin>().JoinLobby(packet.Id, (lobby) =>
            {
                UnityMainThreadDispatcher.Instance().Enqueue(() =>
                {
                    // Hide this window
                    gameObject.SetActive(false);

                    if (LobbyUi == null)
                    {
                        Debug.Log("Couldn't find appropriate UI element to display lobby data in the scene. " +
                                  "Override OnJoinLobbyClick method, if you want to handle this differently");
                        return;
                    }

                    lobby.SetListener(LobbyUi);

                    LobbyUi.gameObject.SetActive(true);
                });
            }, Debug.Log);
        }
        public void Setup(GameInfoPacket data, Action doubleClickAction = null)
        {
            RawData   = data;
            IsLobby   = data.infoType == GameInfoType.Lobby;
            roomType  = data.infoType;
            Name.text = data.Name;
            GameId    = data.Id;
            initBackgroundColor(data.infoType);
            this.doubleClickAction = doubleClickAction;


            if (data.MaxPlayers > 0)
            {
                Online.text = string.Format("{0}/{1}", data.OnlinePlayers, data.MaxPlayers);
            }
            else
            {
                Online.text = data.OnlinePlayers.ToString();
            }

            MapName.text = data.Properties.ContainsKey(MsfDictKeys.MapName)
                ? data.Properties[MsfDictKeys.MapName] : UnknownMapName;
        }