Пример #1
0
        private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionState state)
        {
            switch (state.CurrentStage)
            {
            case MultiplayerSessionConnectionStage.ESTABLISHING_SERVER_POLICY:
                Log.InGame("Requesting session policy information...");
                break;

            case MultiplayerSessionConnectionStage.AWAITING_RESERVATION_CREDENTIALS:
                if (multiplayerSession.SessionPolicy.RequiresServerPassword)
                {
                    Log.InGame("Waiting for Server Password Input...");
                    showingPasswordWindow = true;
                    shouldFocus           = true;
                }
                Log.InGame("Waiting for user input...");
                RightSideMainMenu.OpenGroup("Join Server");
                FocusPlayerNameTextbox();
                break;

            case MultiplayerSessionConnectionStage.SESSION_RESERVED:
                Log.InGame("Launching game...");
                multiplayerSession.ConnectionStateChanged -= SessionConnectionStateChangedHandler;
                preferencesManager.Save();

#pragma warning disable CS0618 // God Damn it UWE...
                IEnumerator startNewGame = (IEnumerator)uGUI_MainMenu.main.ReflectionCall("StartNewGame", false, false, GameMode.Survival);
#pragma warning restore CS0618 // God damn it UWE...
                StartCoroutine(startNewGame);
                LoadingScreenVersionText.Initialize();

                break;

            case MultiplayerSessionConnectionStage.SESSION_RESERVATION_REJECTED:
                Log.InGame("Reservation rejected...");

                MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;

                string reservationRejectionNotification = reservationState.Describe();

                NotifyUser(
                    reservationRejectionNotification,
                    () =>
                {
                    multiplayerSession.Disconnect();
                    multiplayerSession.Connect(ServerIp, ServerPort);
                });
                break;

            case MultiplayerSessionConnectionStage.DISCONNECTED:
                Log.Info("Disconnected from server");
                break;
            }
        }
Пример #2
0
        private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionState state)
        {
            switch (state.CurrentStage)
            {
            case MultiplayerSessionConnectionStage.EstablishingServerPolicy:
                Log.InGame("Requesting session policy information...");
                break;

            case MultiplayerSessionConnectionStage.AwaitingReservationCredentials:
                Log.InGame("Waiting for User Input...");

                RightSideMainMenu.OpenGroup("Join Server");
                FocusPlayerNameTextbox();

                break;

            case MultiplayerSessionConnectionStage.SessionReserved:
                Log.InGame("Launching game...");

                multiplayerSession.ConnectionStateChanged -= SessionConnectionStateChangedHandler;
                preferencesManager.Save();

#pragma warning disable CS0618 // God Damn it UWE...
                IEnumerator startNewGame = (IEnumerator)uGUI_MainMenu.main.ReflectionCall("StartNewGame", false, false, GameMode.Survival);
#pragma warning restore CS0618 // God damn it UWE...
                StartCoroutine(startNewGame);

                break;

            case MultiplayerSessionConnectionStage.SessionReservationRejected:
                Log.InGame("Reservation rejected...");

                MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;

                string reservationRejectionNotification = reservationState.Describe();

                NotifyUser(
                    reservationRejectionNotification,
                    () =>
                {
                    multiplayerSession.Disconnect();
                    multiplayerSession.Connect(ServerIp, ServerPort);
                });

                break;

            case MultiplayerSessionConnectionStage.Disconnected:
                Log.Info("Disconnected from server");
                break;
            }
        }
Пример #3
0
        private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionState state)
        {
            switch (state.CurrentStage)
            {
            case MultiplayerSessionConnectionStage.EstablishingServerPolicy:
                Log.InGame("Запрос информации о политике сеанса...");
                break;

            case MultiplayerSessionConnectionStage.AwaitingReservationCredentials:
                Log.InGame("Ожидание ввода пользователя...");

                RightSideMainMenu.OpenGroup("Join Server");
                FocusPlayerNameTextbox();

                break;

            case MultiplayerSessionConnectionStage.SessionReserved:
                Log.InGame("Запуск игры...");

                multiplayerSession.ConnectionStateChanged -= SessionConnectionStateChangedHandler;
                preferencesManager.Save();

                IEnumerator startNewGame = (IEnumerator)uGUI_MainMenu.main.ReflectionCall("StartNewGame", false, false, GameMode.Survival);
                StartCoroutine(startNewGame);

                break;

            case MultiplayerSessionConnectionStage.SessionReservationRejected:
                Log.InGame("Резервирование отклонено...");

                MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;

                string reservationRejectionNotification = reservationState.Describe();

                NotifyUser(
                    reservationRejectionNotification,
                    () =>
                {
                    multiplayerSession.Disconnect();
                    multiplayerSession.Connect(ServerIp, serverPort);
                });

                break;

            case MultiplayerSessionConnectionStage.Disconnected:
                Log.Info("Отключен от сервера");
                break;
            }
        }
Пример #4
0
        private void SessionConnectionStateChangedHandler(IMultiplayerSessionConnectionState state)
        {
            switch (state.CurrentStage)
            {
            case MultiplayerSessionConnectionStage.EstablishingServerPolicy:
                Log.InGame("Requesting session policy information...");
                break;

            case MultiplayerSessionConnectionStage.AwaitingReservationCredentials:
                Log.InGame("Waiting for User Input...");

                RightSideMainMenu.OpenGroup("Join Server");
                FocusPlayerNameTextbox();

                break;

            case MultiplayerSessionConnectionStage.SessionReserved:
                Log.InGame("Launching game...");

                multiplayerSession.ConnectionStateChanged -= SessionConnectionStateChangedHandler;
                preferencesManager.Save();
                StartCoroutine(LaunchSession());

                break;

            case MultiplayerSessionConnectionStage.SessionReservationRejected:
                Log.InGame("Reservation rejected...");

                MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;

                string reservationRejectionNotification = reservationState.Describe();

                NotifyUser(
                    reservationRejectionNotification,
                    () =>
                {
                    multiplayerSession.Disconnect();
                    multiplayerSession.Connect(ServerIp);
                });

                break;

            case MultiplayerSessionConnectionStage.Disconnected:
                Log.Info("Disconnected from server");
                break;
            }
        }
Пример #5
0
        private void RenderUnableToJoinDialog(int windowId)
        {
            Event e = Event.current;

            if (e.isKey)
            {
                switch (e.keyCode)
                {
                case KeyCode.Return:
                    joiningServer         = true;
                    notifyingUnableToJoin = false;
                    break;

                case KeyCode.Escape:
                    joiningServer         = true;
                    notifyingUnableToJoin = false;
                    break;
                }
            }

            GUISkinUtils.RenderWithSkin(GetGUISkin("dialogs.server.rejected", 490), () =>
            {
                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        MultiplayerSessionReservationState reservationState = multiplayerSession.Reservation.ReservationState;
                        string reservationStateDescription = reservationState.Describe();

                        GUILayout.Label(reservationStateDescription);
                    }

                    if (GUILayout.Button("OK"))
                    {
                        notifyingUnableToJoin = false;
                        multiplayerSession.Disconnect();
                        multiplayerSession.Connect(ServerIp);
                    }
                }
            });
        }