コード例 #1
0
        protected virtual void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> args)
        {
            m_progress.IsVisible = false;
            if (args.NewValue)
            {
                if (m_remoteGameServer.HasError(error))
                {
                    m_notification.ShowError(error);
                }
            }
            else
            {
                if (m_remoteGameServer.HasError(error))
                {
                    m_notification.ShowError(error);
                }
                else
                {
                    m_notification.ShowError("You are offline. Server is not connected.", m_connectionButton.gameObject);
                }
            }

            if (args.NewValue != args.OldValue)
            {
                Dependencies.RemoteGameServer.CancelRequests();
                Dependencies.LocalGameServer.CancelRequests();

                m_navigation.ClearHistory();
                m_navigation.Navigate("LoginMenu4Players");
            }
        }
コード例 #2
0
        private void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> args)
        {
            m_progress.IsVisible = false;

            for (int i = 0; i < m_playerMenu.Length; ++i)
            {
                m_playerMenu[i].Player = null;
            }

            if (args.NewValue)
            {
                if (m_remoteGameServer.HasError(error))
                {
                    m_notification.ShowError(error);
                }
                else
                {
                    GetPlayers();
                }
            }
            else
            {
                if (m_remoteGameServer.HasError(error))
                {
                    m_notification.ShowError(error);
                }
                else
                {
                    m_notification.ShowError("You are offline. Server is not connected.", m_connectButton.gameObject);

                    GetPlayers();
                }
            }
        }
コード例 #3
0
        private void OnGameServerReconnected(Error error, ValueChangedArgs <bool> payload)
        {
            if (!m_gameServer.IsConnected)
            {
                bool wasConnected = payload.OldValue;
                if (wasConnected)
                {
                    m_gameServerReconnectAttempts = GameConstants.ReconnectAttemptsCount;
                }

                if (m_gameServerReconnectAttempts > 0)
                {
                    Debug.LogWarning("GameServer is not connected. Trying to reconnect. Attempt = " + ((GameConstants.ReconnectAttemptsCount - m_gameServerReconnectAttempts) + 1));
                    m_gameServer.Connect();
                    m_gameServerReconnectAttempts--;
                }
                else
                {
                    m_notification.ShowError("Unable to connect to GameServer");
                }
            }
        }
コード例 #4
0
        private void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> payload)
        {
            m_gameServer = Dependencies.GameServer;

            TestGameInitArgs gameInitArgs = Dependencies.State.GetValue <TestGameInitArgs>("Battlehub.VoxelGame.TestGameInitArgs");

            if (gameInitArgs == null)
            {
                gameInitArgs = new TestGameInitArgs();
            }
            Dependencies.State.SetValue("Battlehub.VoxelGame.TestGameInitArgs", null);

            bool isConnected = false;

            if (m_remoteGameServer != null)
            {
                m_remoteGameServer.ConnectionStateChanged -= OnConnectionStateChanged;
                isConnected = m_remoteGameServer.IsConnected;
            }

            TestGameInit.Init(gameInitArgs.MapName, gameInitArgs.PlayersCount, gameInitArgs.BotsCount, isConnected, () =>
            {
            }, initError => m_notification.ShowError(initError));
        }
コード例 #5
0
 private void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> args)
 {
     UpdateButtonState();
 }
コード例 #6
0
        private void OnConnectionStateChanged(Error error, ValueChangedArgs <bool> args)
        {
            if (args.NewValue)
            {
                if (HasError(error))
                {
                    Error(error);
                    return;
                }

                if (m_isInitialized)
                {
                    m_matchServer.GetState(m_gSettings.ClientId, (getStateError, players, localPlayers, abilities, tasks, taskTemplates, assignmentGroups, room, mapRoot) =>
                    {
                        if (m_matchServer.HasError(getStateError))
                        {
                            ReconnectFailed(getStateError);
                            return;
                        }

                        if (Reconnected != null)
                        {
                            Reconnected(getStateError, players, localPlayers, abilities, tasks, taskTemplates, assignmentGroups, room, mapRoot);
                        }

                        enabled = true;
                    });

                    // Debug.LogWarning("RECONNECT IS NOT TESTED");
                    // enabled = true;
                    // m_startTime = Time.realtimeSinceStartup;
                }
                else
                {
                    if (ReadyToStart != null)
                    {
                        ReadyToStart(error);
                    }
                }
            }
            else
            {
                enabled = false;

                m_cmdQueue.Clear();

                if (m_isInitialized)
                {
                    bool wasConnected = args.OldValue;
                    if (wasConnected)
                    {
                        if (Stopped != null)
                        {
                            Stopped(error);
                        }
                    }
                    else
                    {
                        if (ReconnectFailed != null)
                        {
                            ReconnectFailed(new Error(StatusCode.OK));
                        }
                    }
                }
                else
                {
                    if (Stopped != null)
                    {
                        Stopped(error);
                    }
                }
            }
        }
コード例 #7
0
 private void OnRemoteGameServerConnectionStateChanged(Error error, ValueChangedArgs <bool> payload)
 {
     Dependencies.RemoteGameServer.ConnectionStateChanged -= OnRemoteGameServerConnectionStateChanged;
     Init();
 }