예제 #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();
    }
    //< 화면이 꺼졌다 켜졌을경우 처리
//#if !UNITY_EDITOR && UNITY_ANDROID
    public void OnApplicationPause(bool type)
    {
        if (type)
        {
            PlayerPrefs.SetString("OnApplicationPauseTime", dateTimeToUnixTime(System.DateTime.Now).ToString());
        }
        else
        {
            NativeHelper.instance.DisableNavUI();

            System.DateTime EndTime = UnixTimeToDateTime(uint.Parse(PlayerPrefs.GetString("OnApplicationPauseTime", "0")));
            EndTime = EndTime.AddMinutes(5);
            long tick = (EndTime - System.DateTime.Now).Ticks;
            if (tick <= 0)
            {
                if (instance.CurrState() != _STATE.LOGIN && SceneManager.instance.CurrState() != _STATE.START /*&& SceneManager.instance.CurrState() != _STATE.GAMEREADY*/)
                {
                    string msg   = _LowDataMgr.instance.GetStringCommon(1021);
                    string title = _LowDataMgr.instance.GetStringCommon(141);
                    string ok    = _LowDataMgr.instance.GetStringCommon(117);
                    AddPopup(0, msg, title, ok, null, null, () => {
                        ShowLoadingTipPanel(true, GAME_MODE.NONE, () =>
                        {
                            UITextList.ClearTextList();
                            NetData.instance.InitUserData();
                            NetData.instance.ClearCharIdc();

                            ActionEvent(_ACTION.GO_LOGIN);
                        });
                    }, null, null);
                    //UIMgr.instance.OpenPopup("게임을 장시간 플레이하지 않아,\n타이틀로 돌아갑니다.", () =>
                    //{
                    //SceneManager.instance.ActionEvent(_ACTION.GO_LOGIN);
                    //}, false);
                }
            }
        }

#if UNITY_ANDROID
        Object[] objects = GameObject.FindObjectsOfType(typeof(SkinnedMeshRenderer));
        foreach (SkinnedMeshRenderer s in objects)
        {
            s.sharedMesh.vertices = s.sharedMesh.vertices;
            s.sharedMesh.colors   = s.sharedMesh.colors;
            s.sharedMesh.colors32 = s.sharedMesh.colors32;
            s.sharedMesh.uv       = s.sharedMesh.uv;
        }
#endif
    }
예제 #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);
            });
        }
    }
예제 #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();
    }
예제 #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);
        }