Beispiel #1
0
        private void JoinSelectedLobby()
        {
            var selectedRow = m_gamesTable.SelectedRow;

            if (selectedRow == null)
            {
                return;
            }

            Lobby selectedLobby = (Lobby)selectedRow.UserData;
            bool  isBattle      = MyMultiplayerLobby.GetLobbyBattle(selectedLobby);

            if (MyFakes.ENABLE_BATTLE_SYSTEM && isBattle)
            {
                MyJoinGameHelper.JoinBattleGame(selectedLobby);
            }
            else
            {
                MyJoinGameHelper.JoinGame(selectedLobby);
            }
        }
        public static void JoinGame(Lobby lobby, bool requestData = true)
        {
            // Data not received
            if (requestData && String.IsNullOrEmpty(lobby.GetLobbyData(MyMultiplayer.AppVersionTag)))
            {
                var helper = new MyLobbyHelper(lobby);
                helper.OnSuccess += (l) => JoinGame(l, false);
                if (helper.RequestData())
                {
                    return;
                }
            }

            if (!JoinGameTest(lobby))
            {
                return;
            }

            if (MyMultiplayerLobby.GetLobbyScenario(lobby))
            {
                MyJoinGameHelper.JoinScenarioGame(lobby.LobbyId);
            }
            else if (MyFakes.ENABLE_BATTLE_SYSTEM && MyMultiplayerLobby.GetLobbyBattle(lobby))
            {
                bool canBeJoined = MyMultiplayerLobby.GetLobbyBattleCanBeJoined(lobby);
                // Check also valid faction ids in battle lobby.
                long faction1Id = MyMultiplayerLobby.GetLobbyBattleFaction1Id(lobby);
                long faction2Id = MyMultiplayerLobby.GetLobbyBattleFaction2Id(lobby);

                if (canBeJoined && faction1Id != 0 && faction2Id != 0)
                {
                    MyJoinGameHelper.JoinBattleGame(lobby.LobbyId);
                }
            }
            else
            {
                JoinGame(lobby.LobbyId);
            }
        }