Exemple #1
0
    public void OnFacebookBind(string szFacebookAccount)
    {
        PlayerPrefs.SetString("logintype", "facebook");
        PlayerPrefs.SetString("user_id", user_id);
        PlayerPrefs.SetString("user_token", user_token);

        SceneManager.instance.ShowLoadingTipPanel(true, GAME_MODE.NONE, () =>
        {
            UITextList.ClearTextList();
            //UIMgr.GetTownBasePanel().Close();
            //UIMgr.instance.Clear(UIMgr.UIType.System);
            UIMgr.ClearUI(true);

            NetworkClient.instance.DisconnectGameServer();//연결 종료
            NetData.instance.InitUserData();
            NetData.instance.ClearCharIdc();

            SceneManager.instance.ActionEvent(_ACTION.GO_LOGIN);
        });

        //option.SaveOptionData();
        //Close();
        option.SaveOptionData();
        base.Close();
    }
Exemple #2
0
    /// <summary> 원래라면 아이디 비밀번호로 로그인 프로토콜 태우고 로그인 아이디 형식이 맞는지 선체크 </summary>
    void CheckLogin()
    {
        string id = IdInput.value;

        if (id.Contains(" ") || string.IsNullOrEmpty(id) || DefaultID.CompareTo(id) == 0)
        {
            //UIMgr.instance.AddPopup(9, id, null, null, null);
            uiMgr.AddPopup(141, 110, 117);
            return;
        }

        if (SelectServerInfo.Id == 0)
        {//서버 목록을 받아오지 못하였다.
            Debug.LogError("server list error");
            uiMgr.AddPopup(141, 293, 117, 75, 0, () => {
                UIMgr.ClearUI();
                TempCoroutine.instance.NextFrame(() => {
                    UIMgr.Open("UIPanel/LoginPanel", false);
                });
            }, () => {//종료
                Application.Quit();
            }, null);
            return;
        }

        ConnectLoginServer(id);
    }
Exemple #3
0
    void OnTableFuction(string key)
    {
        if (key == "logout")
        {
            SceneManager.instance.ShowLoadingTipPanel(true, GAME_MODE.NONE, () => {
                UITextList.ClearTextList();
                UIMgr.ClearUI(true);

                NetworkClient.instance.DisconnectGameServer();//연결 종료
                NetData.instance.InitUserData();
                NetData.instance.ClearCharIdc();

                SceneManager.instance.ActionEvent(_ACTION.GO_LOGIN);
            });
        }
    }
Exemple #4
0
    /// <summary> 로그인화면 </summary>
    void OnClickLogin()
    {
        //UIMgr.ClearAll();

        //iFunClient.instance.TryDisconnect();
        SceneManager.instance.ShowLoadingTipPanel(true, GAME_MODE.NONE, () =>
        {
            UITextList.ClearTextList();
            //UIMgr.GetTownBasePanel().Close();
            //UIMgr.instance.Clear(UIMgr.UIType.System);
            UIMgr.ClearUI(true);

            NetworkClient.instance.DisconnectGameServer();//연결 종료
            NetData.instance.InitUserData();
            NetData.instance.ClearCharIdc();

            SceneManager.instance.ActionEvent(_ACTION.GO_LOGIN);
        });

        //option.SaveOptionData();
        //Close();
        option.SaveOptionData();
        base.Close();
    }
Exemple #5
0
        /// <summary>
        /// 发送消息
        /// 在游戏线程调用
        /// </summary>
        /// <param name="msgId"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool Send(uint msgId, IMessage msg)
        {
            if (Disposed)
            {
                mLogger.LogError(this + "Been dispose", "Send");

                /////////////////////////////////////////////////////
                // 접속끊김
                UIMgr.instance.AddPopup(141, 109, 117, 0, 0, () =>
                {
                    SceneManager.instance.ShowLoadingTipPanel(true, GAME_MODE.NONE, () =>
                    {
                        UIMgr.ClearUI(true);
                        UITextList.ClearTextList();
                        //UIMgr.GetTownBasePanel().Close();
                        //UIMgr.instance.Clear(UIMgr.UIType.System);

                        //NetworkClient.instance.DisconnectGameServer();//연결 종료
                        NetData.instance.InitUserData();
                        NetData.instance.ClearCharIdc();

                        SceneManager.instance.ActionEvent(_ACTION.GO_LOGIN);
                    });
                });
                /////////////////////////////////////////////////////

                return(false);
            }

            if (msg == null)
            {
                mLogger.LogError("msg == null", "Send");
                return(false);
            }

            Socket socket = mSocket;

            if (socket == null)
            {
                mLogger.LogError("socket == null", "Send");
                return(false);
            }

            try
            {
                if (!socket.Connected)
                {
                    mLogger.LogError("socket.Connected == false", "Send");
                    return(false);
                }

                ByteArray writer = mWriter;
                if (writer == null)
                {
                    mWriterBuffer = new byte[mBuffSize];
                    mWriter       = new ByteArray(mWriterBuffer);
                    writer        = mWriter;
                }
                else
                {
                    writer.Reset();
                }

                UInt16 uMsgId = (UInt16)msgId;
                //先占位
                writer.WriteU16(0);
                writer.WriteU16(uMsgId);
                var ms = writer.GetStream();
                msg.WriteTo(ms);
                var len = writer.Position;

                //重写长度
                writer.Position = 0;
                writer.WriteU16((ushort)len);
                writer.Position = len;
                writer.SetLength(len);

                if (SendBeforCallback != null)
                {
                    SendBeforCallback(uMsgId, writer);
                }

                int sendSize = socket.Send(mWriterBuffer, (int)len, SocketFlags.None);

                if (MsgTransferLog)
                {
                    mLogger.LogInfo("send msg, msgId=" + msgId, "Send");
                }

                if (sendSize != writer.Length)
                {
                    mLogger.LogError("sendSize != mWriter.Length", "Send");
                    return(false);
                }
            }
            catch (Exception e)
            {
                mLogger.LogError(e.Message, "Send");
                return(false);
            }

            return(true);
        }
Exemple #6
0
    /// <summary>
    /// 비동기로 해당 씬을 로드하도록 합니다.
    /// </summary>
    /// <param name="callback">로딩 완료후 호출될 함수</param>
    IEnumerator LoadLevelScene(string scenename, System.Action callback, bool noProgress = false)
    {
        yield return(new WaitForEndOfFrame());

        if (!Application.loadedLevelName.Equals("StartScene"))
        {
            UIMgr.ClearUI();
        }

        if (Application.loadedLevelName == scenename)
        {
            Debug.LogWarning("LoadLevel() : 같은 씬(" + scenename + ")을 로드하려고 합니다.");
            yield return(null);
        }
        else
        {
            if (noProgress)
            {
                Application.backgroundLoadingPriority = ThreadPriority.High;
                AsyncOperation async = Application.LoadLevelAsync(scenename);

                while (!async.isDone)
                {
                    yield return(null);
                }
            }
            else
            {
                Application.backgroundLoadingPriority = ThreadPriority.High;

                int displayProgress = 0;
                int toProgress      = 0;

                //Debug.Log("op.progress:" + toProgress);

                AsyncOperation op = Application.LoadLevelAsync(scenename);
                op.allowSceneActivation = false;
                while (op.progress < 0.9f)
                {
                    toProgress = (int)op.progress * 100;

                    //Debug.Log("toProgress:" + toProgress);

                    while (displayProgress < toProgress)
                    {
                        ++displayProgress;
                        //SetLoadingPercentage(displayProgress);

                        if (SceneManager.instance.LoadingTipPanel != null)
                        {
                            float value = (float)displayProgress / 100f;
                            SceneManager.instance.LoadingTipPanel.changeLoadingBar(value);
                        }
                        //Debug.Log("displayProgress:"+displayProgress);
                        yield return(null);
                    }

                    yield return(null);
                }

                toProgress = 100;
                while (displayProgress < toProgress)
                {
                    ++displayProgress;
                    //SetLoadingPercentage(displayProgress);

                    if (SceneManager.instance.LoadingTipPanel != null)
                    {
                        float value = (float)displayProgress / 100f;
                        SceneManager.instance.LoadingTipPanel.changeLoadingBar(value);
                    }

                    //Debug.Log("displayProgress:"+displayProgress);
                    yield return(null);
                }

                yield return(new WaitForEndOfFrame());

                if (!Application.loadedLevelName.Equals("StartScene"))
                {
                    //AtlasMgr.instance.DeleteAllPanelData();
                    //Resources.UnloadUnusedAssets();
                    System.GC.Collect();
                }

                op.allowSceneActivation = true;
            }
        }

        Application.backgroundLoadingPriority = ThreadPriority.BelowNormal;

        if (null != callback)
        {
            callback();
        }
    }
Exemple #7
0
    void LoginProcess()
    {
        string loginType  = PlayerPrefs.GetString("logintype", "none");
        string user_id    = PlayerPrefs.GetString("user_id", "none");
        string user_token = PlayerPrefs.GetString("user_token", "none");

        if (!loginType.Contains("none") && !user_id.Contains("none") && !user_token.Contains("none"))
        {
            //서버에 페이스북으로 로그인 시도
            if (loginType.Contains("facebook"))
            {
                SceneManager.instance.ShowNetProcess("Login");
                NetworkClient.instance.ConnectServer(SelectServerInfo.Ip_1, SelectServerInfo.Port_1, (state) =>
                {
                    switch (state)
                    {
                    case Core.Net.ConnectState.Success:
                        NetworkClient.instance.SendPMsgFacebookCertifyC(user_id, user_token);
                        NetData.instance._Ip = SelectServerInfo.Ip_1;
                        break;

                    case Core.Net.ConnectState.Error:
                        //2번 IP로 재시도
                        NetworkClient.instance.ConnectServer(SelectServerInfo.Ip_2, SelectServerInfo.Port_2, (state2) =>
                        {
                            switch (state2)
                            {
                            case Core.Net.ConnectState.Success:
                                NetworkClient.instance.SendPMsgFacebookCertifyC(user_id, user_token);
                                NetData.instance._Ip = SelectServerInfo.Ip_2;

                                break;

                            case Core.Net.ConnectState.Error:
                                uiMgr.AddPopup(141, 293, 117, 75, 0,
                                               () => {
                                    UIMgr.ClearUI();
                                    TempCoroutine.instance.NextFrame(() => {
                                        UIMgr.Open("UIPanel/LoginPanel", false);
                                    });
                                    //SceneManager.instance.ActionEvent(_ACTION.GO_LOGO);//재접속
                                }, () => {            //종료
                                    //#if !UNITY_EDITOR
                                    Application.Quit();
                                }, null);

                                SceneManager.instance.EndNetProcess("Login");
                                break;

                            case Core.Net.ConnectState.Close:
                                //에러코드
                                SceneManager.instance.EndNetProcess("Login");
                                break;
                            }
                        });

                        break;

                    case Core.Net.ConnectState.Close:
                        //에러코드
                        break;
                    }
                });
            }
        }
        else
        {
            ConnectLoginServer(uuid);
        }
    }
Exemple #8
0
    void ConnectLoginServer(string szMachineKey)
    {
        if (!ClauseToggle.value)
        {
            ClauseCheckPop.SetActive(true);
            return;
        }

        SceneManager.instance.ShowNetProcess("Login");
        NetworkClient.instance.ConnectServer(SelectServerInfo.Ip_1, SelectServerInfo.Port_1, (state) =>
        {
            switch (state)
            {
            case Core.Net.ConnectState.Success:
                NetworkClient.instance.SendPMsgAccountCertifyC((uint)Sw.PLATFORM_TYPE.PLATFORM_TYPE_SELF, szMachineKey, 00, (uint)Sw.CHANNEL_TYPE.CHANNEL_TYPE_SELF, "", "", "", "");
                NetData.instance._Ip = SelectServerInfo.Ip_1;
                break;

            case Core.Net.ConnectState.Error:
                //2번 IP로 재시도
                NetworkClient.instance.ConnectServer(SelectServerInfo.Ip_2, SelectServerInfo.Port_2, (state2) =>
                {
                    switch (state2)
                    {
                    case Core.Net.ConnectState.Success:
                        NetworkClient.instance.SendPMsgAccountCertifyC((uint)Sw.PLATFORM_TYPE.PLATFORM_TYPE_SELF, szMachineKey, 00, (uint)Sw.CHANNEL_TYPE.CHANNEL_TYPE_SELF, "", "", "", "");
                        NetData.instance._Ip = SelectServerInfo.Ip_2;

                        break;

                    case Core.Net.ConnectState.Error:
                        uiMgr.AddPopup(141, 293, 117, 75, 0,
                                       () => {
                            UIMgr.ClearUI();
                            TempCoroutine.instance.NextFrame(() => {
                                UIMgr.Open("UIPanel/LoginPanel", false);
                            });
                            //SceneManager.instance.ActionEvent(_ACTION.GO_LOGO);//재접속
                        }, () => {        //종료
                                          //#if !UNITY_EDITOR
                            Application.Quit();
                        }, null);

                        SceneManager.instance.EndNetProcess("Login");
                        break;

                    case Core.Net.ConnectState.Close:
                        //에러코드
                        SceneManager.instance.EndNetProcess("Login");
                        break;
                    }
                });

                break;

            case Core.Net.ConnectState.Close:
                //에러코드
                break;
            }
        });
    }