Ejemplo n.º 1
0
        public void Update()
        {
            if (!bReconnect)
            {
                return;
            }

            // 连接上了
            if (netClientThread != null && netClientThread.IsConnectted())
            {
                bReconnect = false;
                Clear();

                ReqReconnect();

                return;
            }

            SpecialCondition();


            //if (AutoReconnectCount > 0)//自动重连自次数内
            //{
            //    if (ReconnectTime > ReconnectTimeGap)//超过单次重连时间
            //    {
            //        ReconnectTime = 0;
            //        AutoReconnectCount--;
            //        if (AutoReconnectCount > 0)
            //        {
            //            LogMgr.UnityError(string.Format("auto reconnect time:{0}th", AutoReconnectCount));
            //            NetLogicGame.Instance.connectGame(netClientThread.m_serverIP, (short)netClientThread.m_serverPort);
            //        }
            //    }
            //    else if (ReconnectTime == 0f)
            //    {
            //        LogMgr.UnityError(string.Format("auto reconnect time:{0}th", AutoReconnectCount));
            //        ReconnectTime = 0;
            //        NetLogicGame.Instance.connectGame(netClientThread.m_serverIP, (short)netClientThread.m_serverPort);
            //    }
            //}
            //else if (!IsShowReconnectedDialog)
            //{
            //    IsShowReconnectedDialog = true;
            //    MainPanelMgr.Instance.HideDialog("UIWaitDialog");
            //    UITips.ShowTipsDialog("重新连接", "您已经掉线,是否重新连接?", "重新连接", onBtnReconnect, "返回登录", RequestToLogin);
            //}
            if (isLoadScene)
            {
                disconnectInLoad = true;
            }
            else if (!IsTipsDialogShow() && !NetLogicGame.Instance.IsCrossLinking)
            {
                if (needShowNotice)
                {
                    IsShowReconnectedDialog = true;
                    UITips.ShowTipSinginDlg("提示", "您已经断开连接,请重新登录", RequestToLogin);
                }
                else
                {
                    RequestToLogin();
                }
            }

            float deltaTime = Time.time - passTime;

            ReconnectTime     += deltaTime;
            DisconnectionTime += deltaTime;
            PressButtonTime   += deltaTime;
            passTime           = Time.time;
        }