Inheritance: global::ProtoBuf.IExtensible
Beispiel #1
0
    public void RequireCreateRole(string strAccount, string strRoleName, int byCareer, int bySex, int nGameID)
    {
        if (strRoleName.Length >= 20 || strRoleName.Length < 1)
        {
            return;
        }

        NFMsg.ReqCreateRole xData = new NFMsg.ReqCreateRole();
        xData.career    = byCareer;
        xData.sex       = bySex;
        xData.noob_name = UnicodeEncoding.Default.GetBytes(strRoleName);
        xData.account   = UnicodeEncoding.Default.GetBytes(strAccount);
        xData.race      = 0;
        xData.game_id   = nGameID;

        MemoryStream stream = new MemoryStream();

        Serializer.Serialize <NFMsg.ReqCreateRole>(stream, xData);

        SendMsg(new NFCoreEx.NFIDENTID(), NFMsg.EGameMsgID.EGMI_REQ_CREATE_ROLE, stream);

        if (NFStart.Instance.bDebugMode)
        {
            NFMsg.AckRoleLiteInfoList xAckBodyData = new NFMsg.AckRoleLiteInfoList();
            NFMsg.RoleLiteInfo        info         = new NFMsg.RoleLiteInfo();

            info.career            = byCareer;
            info.sex               = bySex;
            info.noob_name         = xData.noob_name;
            info.race              = xData.race;
            info.noob_name         = xData.noob_name;
            info.id                = new NFMsg.Ident();
            info.game_id           = 1;
            info.role_level        = 1;
            info.view_record       = xData.account = UnicodeEncoding.Default.GetBytes("");
            info.delete_time       = 1;
            info.reg_time          = 1;
            info.last_offline_time = 1;
            info.last_offline_ip   = 1;
            xAckBodyData.char_data.Add(info);

            MemoryStream xAckBodyStream = new MemoryStream();
            Serializer.Serialize <NFMsg.AckRoleLiteInfoList>(xAckBodyStream, xAckBodyData);

            NFMsg.MsgBase xAckData = new NFMsg.MsgBase();
            xAckData.player_id = info.id;
            xAckData.msg_data  = xAckBodyStream.ToArray();

            MemoryStream xAckAllStream = new MemoryStream();
            Serializer.Serialize <NFMsg.MsgBase>(xAckAllStream, xAckData);

            MsgHead head = new MsgHead();
            head.unMsgID   = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_ROLE_LIST;
            head.unDataLen = (UInt32)xAckAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE;

            xNet.mxBinMsgEvent.OnMessageEvent(head, xAckAllStream.ToArray());
        }
    }
 // Update is called once per frame
 void Update()
 {
     //set name
     if (NFNetController.Instance.aCharList.Count > 0)
     {
         NFMsg.RoleLiteInfo xLiteInfo = (NFMsg.RoleLiteInfo)NFNetController.Instance.aCharList[0];
         SetName(System.Text.Encoding.Default.GetString(xLiteInfo.noob_name));
         SetDetailData("Level " + xLiteInfo.role_level);
     }
 }
Beispiel #3
0
        private void OnRoleClick(int nIndex)
        {
            ArrayList roleList = mRoleList;

            NFMsg.RoleLiteInfo info = (NFMsg.RoleLiteInfo)roleList[nIndex];

            mRoleID   = mHelpModule.PBToNF(info.Id);
            mRoleName = info.NoobName.ToStringUtf8();

            mNetModule.RequireEnterGameServer();
        }
 void OnEntryClick(GameObject go)
 {
     if (NFNetController.Instance.aCharList.Count > 0)
     {
         NFMsg.RoleLiteInfo xLiteInfo = (NFMsg.RoleLiteInfo)NFNetController.Instance.aCharList[0];
         NFrame.NFGUID      xEnterID  = new NFrame.NFGUID();
         xEnterID.nData64 = xLiteInfo.id.index;
         xEnterID.nHead64 = xLiteInfo.id.svrid;
         NFNetController.Instance.mxNetSender.RequireEnterGameServer(xEnterID, NFNetController.Instance.strAccount, System.Text.Encoding.Default.GetString(xLiteInfo.noob_name), NFNetController.Instance.nServerID);
     }
 }
Beispiel #5
0
    private void OnRoleClick(int nIndex)
    {
        ArrayList roleList = mLoginModule.mRoleList;

        NFMsg.RoleLiteInfo info = (NFMsg.RoleLiteInfo)roleList[nIndex];

        mLoginModule.mRoleID   = mHelpModule.PBToNF(info.id);
        mLoginModule.mRoleName = info.noob_name.ToStringUtf8();

        mNetModule.RequireEnterGameServer();
        //mUIModule.CloseAllUI();
    }
Beispiel #6
0
        private void EGMI_ACK_ROLE_LIST(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream);

            NFMsg.AckRoleLiteInfoList xData = NFMsg.AckRoleLiteInfoList.Parser.ParseFrom(xMsg.msg_data);

            Debug.Log("QueryRoleList  SUCCESS : " + xData.char_data.Count);

            mRoleList.Clear();

            for (int i = 0; i < xData.char_data.Count; ++i)
            {
                NFMsg.RoleLiteInfo info = xData.char_data[i];

                Debug.Log("QueryRoleList  SUCCESS : " + info.noob_name.ToStringUtf8());

                mRoleList.Add(info);
            }


            mEventModule.DoEvent((int)NFLoginModule.Event.RoleList);

            //////////////////

            /*
             *          if (mRoleList.Count > 0)
             * {
             *  //NFCSectionManager.Instance.SetGameState(NFCSection.UI_SECTION_STATE.UISS_ROLEHALL);
             *
             *                  NFMsg.RoleLiteInfo xLiteInfo = (NFMsg.RoleLiteInfo)mRoleList[0];
             *  NFGUID xEnterID = new NFGUID();
             *  xEnterID.nData64 = xLiteInfo.id.index;
             *  xEnterID.nHead64 = xLiteInfo.id.svrid;
             *
             *                  mNetModule.RequireEnterGameServer(xEnterID, mAccount, xLiteInfo.noob_name.ToStringUtf8(), mServerID);
             *
             *  //mxNetController.mPlayerState = NFNetController.PLAYER_STATE.E_PLAYER_WAITING_TO_GAME;
             *
             *  Debug.Log("Selected role :" + xLiteInfo.noob_name.ToStringUtf8());
             * }
             * else
             * {
             *  //NFCSectionManager.Instance.SetGameState(NFCSection.UI_SECTION_STATE.UISS_CREATEHALL);
             *                  RequireCreateRole( mAccount, 0, 0, mServerID);
             *  Debug.Log("No Role!, require to create a new role! ");
             * }
             */
        }
Beispiel #7
0
        private void OnRoleList(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream);

            NFMsg.AckRoleLiteInfoList xData = NFMsg.AckRoleLiteInfoList.Parser.ParseFrom(xMsg.msg_data);

            Debug.Log("QueryRoleList  SUCCESS");
            mRoleList.Clear();
            for (int i = 0; i < xData.char_data.Count; ++i)
            {
                NFMsg.RoleLiteInfo info = xData.char_data[i];
                mRoleList.Add(info);
            }

            mEventModule.DoEvent((int)Event.RoleList);
        }
Beispiel #8
0
        // 接收消息
        private void OnRoleList(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = new NFMsg.MsgBase();
            xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream);

            NFMsg.AckRoleLiteInfoList xData = new NFMsg.AckRoleLiteInfoList();
            xData = Serializer.Deserialize <NFMsg.AckRoleLiteInfoList>(new MemoryStream(xMsg.msg_data));

            Debug.Log("QueryRoleList  SUCCESS");
            mRoleList.Clear();
            for (int i = 0; i < xData.char_data.Count; ++i)
            {
                NFMsg.RoleLiteInfo info = xData.char_data[i];
                mRoleList.Add(info);
            }

            DoEvent((int)Event.RoleList);
        }
Beispiel #9
0
        public void RequireEnterGameServer(int nRoleIndex)
        {
            m_nRoleIndex = nRoleIndex;
            Debug.Log("RequireEnterGameServer:" + nRoleIndex);
            NFMsg.RoleLiteInfo       info  = (NFMsg.RoleLiteInfo)mRoleList[nRoleIndex];
            NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer();
            xData.name    = info.noob_name;
            xData.account = ByteString.CopyFromUtf8(mLoginModule.mAccount);
            xData.game_id = mLoginModule.mServerID;
            xData.id      = info.id;
            MemoryStream stream = new MemoryStream();

            xData.WriteTo(stream);

            mRoleID             = mHelpModule.PBToNF(info.id);
            mNetModule.mOwnerID = mRoleID;

            mNetModule.SendToServerByPB(NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream);
        }
Beispiel #10
0
        public void RequireEnterGameServer(int nRoleIndex)
        {
            m_nRoleIndex = nRoleIndex;
            Debug.Log("RequireEnterGameServer:" + nRoleIndex);
            NFMsg.RoleLiteInfo       info  = (NFMsg.RoleLiteInfo)mRoleList[nRoleIndex];
            NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer();
            xData.name    = info.noob_name;
            xData.account = UnicodeEncoding.Default.GetBytes(NFCLoginLogic.Instance().mAccount);
            xData.game_id = NFCLoginLogic.Instance().mServerID;
            xData.id      = info.id;
            MemoryStream stream = new MemoryStream();

            Serializer.Serialize <NFMsg.ReqEnterGameServer>(stream, xData);

            mRoleID = PBToNF(info.id);
            NFCNetLogic.Instance().mOwnerID = mRoleID;

            NFCNetLogic.Instance().SendToServerByPB(NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream);
        }
Beispiel #11
0
        private void EGMI_ACK_ROLE_LIST(NFMsg.MsgBase xMsg)
        {
            NFMsg.AckRoleLiteInfoList xData = new NFMsg.AckRoleLiteInfoList();
            xData = mxSerializer.Deserialize(new MemoryStream(xMsg.msg_data), null, typeof(NFMsg.AckRoleLiteInfoList)) as NFMsg.AckRoleLiteInfoList;


            mxNetController.aCharList.Clear();

            for (int i = 0; i < xData.char_data.Count; ++i)
            {
                NFMsg.RoleLiteInfo info = xData.char_data[i];

                Debug.Log("QueryRoleList  SUCCESS : " + System.Text.Encoding.Default.GetString(info.noob_name));

                mxNetController.aCharList.Add(info);
            }

            //////////////////
            if (mxNetController.aCharList.Count > 0)
            {
                //NFCSectionManager.Instance.SetGameState(NFCSection.UI_SECTION_STATE.UISS_ROLEHALL);

                NFMsg.RoleLiteInfo xLiteInfo = (NFMsg.RoleLiteInfo)NFNetController.Instance.aCharList[0];
                NFrame.NFGUID      xEnterID  = new NFrame.NFGUID();
                xEnterID.nData64 = xLiteInfo.id.index;
                xEnterID.nHead64 = xLiteInfo.id.svrid;
                mxNetController.mxNetSender.RequireEnterGameServer(xEnterID, mxNetController.strAccount, System.Text.Encoding.Default.GetString(xLiteInfo.noob_name), mxNetController.nServerID);

                mxNetController.mPlayerState = NFNetController.PLAYER_STATE.E_PLAYER_WAITING_TO_GAME;

                Debug.Log("Selected role :" + System.Text.Encoding.Default.GetString(xLiteInfo.noob_name));
            }
            else
            {
                NFCSectionManager.Instance.SetGameState(NFCSection.UI_SECTION_STATE.UISS_CREATEHALL);

                Debug.Log("No Role!, require to create a new role! ");
            }
        }
Beispiel #12
0
        private void EGMI_ACK_ROLE_LIST(MsgHead head, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = new NFMsg.MsgBase();
            xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream);

            NFMsg.AckRoleLiteInfoList xData = new NFMsg.AckRoleLiteInfoList();
            xData = Serializer.Deserialize <NFMsg.AckRoleLiteInfoList>(new MemoryStream(xMsg.msg_data));

            aCharList.Clear();
            for (int i = 0; i < xData.char_data.Count; ++i)
            {
                NFMsg.RoleLiteInfo info = xData.char_data[i];
                aCharList.Add(info);
            }

            if (NFNet.PLAYER_STATE.E_HAS_PLAYER_ROLELIST != mNet.mPlayerState)
            {
                //NFCRenderInterface.Instance.LoadScene("SelectScene");
            }

            mNet.mPlayerState = NFNet.PLAYER_STATE.E_HAS_PLAYER_ROLELIST;
        }
Beispiel #13
0
    void OnGUI()
    {
        if (null != mxNetFocus)
        {
            mxNetFocus.Update();
            mxNetFocus.OnGUI(1024, 768);
        }

        if (null != mxNetFocus)
        {
            switch (mxNetFocus.mPlayerState)
            {
            case NFNet.PLAYER_STATE.E_NONE:
            {
                if (strTargetIP.Length > 0)
                {
                    mxNetFocus.StartConnect(strTargetIP, nPort);
                    mxNetFocus.mPlayerState = NFNet.PLAYER_STATE.E_WAITING_PLAYER_LOGIN;
                }
            }

            break;

            case NFNet.PLAYER_STATE.E_WAITING_PLAYER_LOGIN:
            {
                if (mxNetFocus.strKey.Length > 0)
                {
                    mxNetFocus.mPlayerState = NFNet.PLAYER_STATE.E_HAS_PLAYER_GATE;
                }
                else
                {
                    mxNetFocus.strAccount  = GUI.TextField(new Rect(10, 10, 150, 50), mxNetFocus.strAccount);
                    mxNetFocus.strPassword = GUI.TextField(new Rect(10, 100, 150, 50), mxNetFocus.strPassword);
                    if (GUI.Button(new Rect(10, 200, 150, 50), "Login"))
                    {
                        mxNetFocus.mxSendLogic.LoginPB(mxNetFocus.strAccount, mxNetFocus.strPassword, "");
                    }
                }
            }
            break;

            case NFNet.PLAYER_STATE.E_HAS_PLAYER_LOGIN:
            {
                int nHeight = 50;
                for (int i = 0; i < mxNetFocus.mxListener.aWorldList.Count; ++i)
                {
                    ServerInfo xInfo = (ServerInfo)mxNetFocus.mxListener.aWorldList[i];
                    if (GUI.Button(new Rect(10, i * nHeight, 150, nHeight), System.Text.Encoding.Default.GetString(xInfo.name)))
                    {
                        NFStart.Instance.GetFocusNet().nServerID = xInfo.server_id;
                        mxNetFocus.mxSendLogic.RequireConnectWorld(xInfo.server_id);
                    }
                }
            }
            break;

            case NFNet.PLAYER_STATE.E_WAITING_PLAYER_TO_GATE:
            {
                string strWorpdIP  = NFStart.Instance.GetFocusNet().strWorldIP;
                string strWorpdKey = NFStart.Instance.GetFocusNet().strKey;
                string strAccount  = NFStart.Instance.GetFocusNet().strKey;
                int    nPort       = NFStart.Instance.GetFocusNet().nWorldPort;

                NFNet xNet = new NFNet();
                xNet.strWorldIP = strWorpdIP;
                xNet.strKey     = strWorpdKey;
                xNet.strAccount = strAccount;
                xNet.nWorldPort = nPort;

                xNet.mPlayerState = NFNet.PLAYER_STATE.E_START_CONNECT_TO_GATE;
                xNet.StartConnect(xNet.strWorldIP, nPort);
                NFStart.Instance.SetFocusNet(xNet);
            }
            break;

            case NFNet.PLAYER_STATE.E_HAS_PLAYER_GATE:
            {
                NFStart.Instance.GetFocusNet().mxSendLogic.RequireVerifyWorldKey(NFStart.Instance.GetFocusNet().strAccount, NFStart.Instance.GetFocusNet().strKey);
                NFStart.Instance.GetFocusNet().mPlayerState = NFNet.PLAYER_STATE.E_WATING_VERIFY;
            }
            break;

            case NFNet.PLAYER_STATE.E_HAS_VERIFY:
            {
                int nWidth = 200;
                for (int i = 0; i < mxNetFocus.mxListener.aServerList.Count; ++i)
                {
                    ServerInfo xInfo = (ServerInfo)mxNetFocus.mxListener.aServerList[i];
                    if (GUI.Button(new Rect(nWidth, i * 50, 150, 50), System.Text.Encoding.Default.GetString(xInfo.name)))
                    {
                        NFStart.Instance.GetFocusNet().nServerID = xInfo.server_id;
                        NFStart.Instance.GetFocusSender().RequireSelectServer(xInfo.server_id);
                    }
                }
            }
            break;

            case NFNet.PLAYER_STATE.E_HAS_PLAYER_ROLELIST:
            {
                if (mxNetFocus.mxListener.aCharList.Count > 0)
                {
                    for (int i = 0; i < mxNetFocus.mxListener.aCharList.Count; ++i)
                    {
                        NFMsg.RoleLiteInfo xLiteInfo = (NFMsg.RoleLiteInfo)mxNetFocus.mxListener.aCharList[i];
                        if (GUI.Button(new Rect(200, i * 50, 150, 50), System.Text.Encoding.Default.GetString(xLiteInfo.noob_name)))
                        {
                            mxNetFocus.strRoleName = System.Text.Encoding.Default.GetString(xLiteInfo.noob_name);
                            NFStart.Instance.GetFocusNet().nMainRoleID = NFTCPClient.NFCoreExListener.PBToNF(xLiteInfo.id);
                            mxNetFocus.mxSendLogic.RequireEnterGameServer(NFStart.Instance.GetFocusNet().nMainRoleID, mxNetFocus.strAccount, mxNetFocus.strRoleName, mxNetFocus.nServerID);
                        }
                    }
                }
                else
                {
                    mxNetFocus.strRoleName = GUI.TextField(new Rect(10, 10, 150, 50), mxNetFocus.strRoleName);
                    if (GUI.Button(new Rect(10, 200, 150, 50), "CreateRole"))
                    {
                        mxNetFocus.mxSendLogic.RequireCreateRole(mxNetFocus.strAccount, mxNetFocus.strRoleName, 0, 0, mxNetFocus.nServerID);
                    }
                }
            }
            break;

            case NFNet.PLAYER_STATE.E_PLAYER_GAMEING:
                //NFCSectionManager.Instance.SetGameState(NFCSectionManager.UI_SECTION_STATE.UISS_GAMEING);
                break;

            default:
                break;
            }
        }
        else
        {
            mxNetFocus = new NFNet();
        }
    }
    public void RequireCreateRole(string strAccount, string strRoleName, int byCareer, int bySex, int nGameID)
    {
        if (strRoleName.Length >= 20 || strRoleName.Length < 1)
        {
            return;
        }

        NFMsg.ReqCreateRole xData = new NFMsg.ReqCreateRole();
        xData.career = byCareer;
        xData.sex = bySex;
        xData.noob_name = UnicodeEncoding.Default.GetBytes(strRoleName);
        xData.account = UnicodeEncoding.Default.GetBytes(strAccount);
        xData.race = 0;
        xData.game_id = nGameID;

        MemoryStream stream = new MemoryStream();
        Serializer.Serialize<NFMsg.ReqCreateRole>(stream, xData);

        SendMsg(new NFCoreEx.NFIDENTID(), NFMsg.EGameMsgID.EGMI_REQ_CREATE_ROLE, stream);

        if (NFStart.Instance.bDebugMode)
        {
            NFMsg.AckRoleLiteInfoList xAckBodyData = new NFMsg.AckRoleLiteInfoList();
            NFMsg.RoleLiteInfo info = new NFMsg.RoleLiteInfo();

            info.career = byCareer;
            info.sex = bySex;
            info.noob_name = xData.noob_name;
            info.race = xData.race;
            info.noob_name = xData.noob_name;
            info.id = new NFMsg.Ident();
            info.game_id = 1;
            info.role_level = 1;
            info.view_record = xData.account = UnicodeEncoding.Default.GetBytes("");
            info.delete_time = 1;
            info.reg_time = 1;
            info.last_offline_time = 1;
            info.last_offline_ip = 1;
            xAckBodyData.char_data.Add(info);

            MemoryStream xAckBodyStream = new MemoryStream();
            Serializer.Serialize<NFMsg.AckRoleLiteInfoList>(xAckBodyStream, xAckBodyData);

            NFMsg.MsgBase xAckData = new NFMsg.MsgBase();
            xAckData.player_id = info.id;
            xAckData.msg_data = xAckBodyStream.ToArray();

            MemoryStream xAckAllStream = new MemoryStream();
            Serializer.Serialize<NFMsg.MsgBase>(xAckAllStream, xAckData);

            MsgHead head = new MsgHead();
            head.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_ROLE_LIST;
            head.unDataLen = (UInt32)xAckAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE;

            xNet.mxBinMsgEvent.OnMessageEvent(head, xAckAllStream.ToArray());
        }
    }