Example #1
0
        public void SetInfo(GameInfoPacket gameInfo, GamesListView owner)
        {
            if (gameNameText)
            {
                gameNameText.text = gameInfo.Name;
            }

            if (gameAddressText)
            {
                gameAddressText.text = gameInfo.Address;
            }

            if (gameRegionText)
            {
                string region = string.IsNullOrEmpty(gameInfo.Region) ? "International" : gameInfo.Region;
                gameRegionText.text = $"Region: <color=yellow>{region}</color>";
            }

            if (gamePlayersText)
            {
                string maxPleyers = gameInfo.MaxPlayers <= 0 ? "∞" : gameInfo.MaxPlayers.ToString();
                gamePlayersText.text = $"Players: <color=yellow>{gameInfo.OnlinePlayers} / {maxPleyers}</color>";
            }

            if (connectButton)
            {
                connectButton.AddOnClickListener(() => {
                    owner.StartGame(gameInfo);
                });
            }
        }
        protected override void OnBeforeClientConnectedToServer()
        {
            DestroyUnwanted();

            // Set cliet mode
            Msf.Client.Rooms.ForceClientMode = true;

            // Set MSF global options
            Msf.Options.Set(MsfDictKeys.autoStartRoomClient, true);
            Msf.Options.Set(MsfDictKeys.offlineSceneName, SceneManager.GetActiveScene().name);

            mainView          = ViewsManager.GetView <MainView>("MainView");
            createNewRoomView = ViewsManager.GetView <CreateNewRoomView>("CreateNewRoomView");
            gamesListView     = ViewsManager.GetView <GamesListView>("GamesListView");

            if (!Msf.Client.Auth.IsSignedIn)
            {
                Msf.Events.Invoke(EventKeys.showLoadingInfo, "Signing in... Please wait!");
            }
            else
            {
                Msf.Events.Invoke(EventKeys.hideLoadingInfo);
            }

            if (Connection.IsConnected)
            {
                OnClientConnectedToServer();
            }
            else
            {
                FindObjectOfType <ClientToMasterConnector>()?.StartConnection();
            }
        }