private void OnPropertyInt(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectPropertyInt propertyData = new NFMsg.ObjectPropertyInt(); propertyData = Serializer.Deserialize <NFMsg.ObjectPropertyInt>(new MemoryStream(xMsg.msg_data)); NFIObject go = NFCKernelModule.Instance().GetObject(PBToNF(propertyData.player_id)); NFIPropertyManager propertyManager = go.GetPropertyManager(); for (int i = 0; i < propertyData.property_list.Count; i++) { NFIProperty property = propertyManager.GetProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name)); if (null == property) { NFIDataList varList = new NFCDataList(); varList.AddInt(0); property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name), varList); } property.SetInt(propertyData.property_list[i].data); } }
///////////////////////////////////////////////////////////////////// private void EGMI_ACK_PROPERTY_INT(int id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ObjectPropertyInt xData = NFMsg.ObjectPropertyInt.Parser.ParseFrom(xMsg.MsgData); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(xData.PlayerId)); if (go == null) { return; } NFIPropertyManager propertyManager = go.GetPropertyManager(); for (int i = 0; i < xData.PropertyList.Count; i++) { string name = xData.PropertyList[i].PropertyName.ToStringUtf8(); Int64 data = xData.PropertyList[i].Data; NFIProperty property = propertyManager.GetProperty(name); if (null == property) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT); property = propertyManager.AddProperty(name, var); } property.SetInt(data); } }
///////////////////////////////////////////////////////////////////// private void EGMI_ACK_PROPERTY_INT(NFMsg.MsgBase xMsg) { NFMsg.ObjectPropertyInt xData = new NFMsg.ObjectPropertyInt(); xData = mxSerializer.Deserialize(new MemoryStream(xMsg.msg_data), null, typeof(NFMsg.ObjectPropertyInt)) as NFMsg.ObjectPropertyInt; NFIObject go = NFCKernelModule.Instance.GetObject(NFNetController.PBToNF(xData.player_id)); if (go == null) { return; } NFIPropertyManager propertyManager = go.GetPropertyManager(); for (int i = 0; i < xData.property_list.Count; i++) { NFIProperty property = propertyManager.GetProperty(System.Text.Encoding.Default.GetString(xData.property_list[i].property_name)); if (null == property) { NFDataList varList = new NFDataList(); varList.AddInt(0); property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(xData.property_list[i].property_name), varList); } property.SetInt(xData.property_list[i].data); } }
////////////////////////////////////修改自身属性 public void RequirePropertyInt(NFGUID objectID, string strPropertyName, int newVar) { NFMsg.ObjectPropertyInt xData = new NFMsg.ObjectPropertyInt(); xData.PlayerId = mHelpModule.NFToPB(objectID); NFMsg.PropertyInt xPropertyInt = new NFMsg.PropertyInt(); xPropertyInt.PropertyName = ByteString.CopyFromUtf8(strPropertyName); xPropertyInt.Data = newVar; xData.PropertyList.Add(xPropertyInt); mxBody.SetLength(0); xData.WriteTo(mxBody); Debug.Log("send upload int"); SendMsg((int)NFMsg.EGameMsgID.AckPropertyInt, mxBody); }
public void RequirePropertyInt(NFrame.NFGUID objectID, string strPropertyName, NFIDataList.TData newVar) { NFMsg.ObjectPropertyInt xData = new NFMsg.ObjectPropertyInt(); xData.player_id = NFBinarySendLogic.NFToPB(objectID); NFMsg.PropertyInt xPropertyInt = new NFMsg.PropertyInt(); xPropertyInt.property_name = System.Text.Encoding.Default.GetBytes(strPropertyName); xPropertyInt.data = newVar.IntVal(); xData.property_list.Add(xPropertyInt); MemoryStream stream = new MemoryStream(); Serializer.Serialize <NFMsg.ObjectPropertyInt>(stream, xData); Debug.Log("send upload int"); SendMsg(objectID, NFMsg.EGameMsgID.EGMI_ACK_PROPERTY_INT, stream); }
////////////////////////////////////修改自身属性 public void RequirePropertyInt(NFrame.NFGUID objectID, string strPropertyName, NFDataList.TData newVar) { NFMsg.ObjectPropertyInt xData = new NFMsg.ObjectPropertyInt(); xData.player_id = NFNetController.NFToPB(objectID); NFMsg.PropertyInt xPropertyInt = new NFMsg.PropertyInt(); xPropertyInt.property_name = System.Text.Encoding.Default.GetBytes(strPropertyName); xPropertyInt.data = newVar.IntVal(); xData.property_list.Add(xPropertyInt); mxBody.SetLength(0); mxSerializer.Serialize(mxBody, xData); Debug.Log("send upload int"); SendMsg(objectID, NFMsg.EGameMsgID.EGMI_ACK_PROPERTY_INT, mxBody); }
///////////////////////////////////////////////////////////////////// private void OnPropertyInt(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ObjectPropertyInt propertyData = NFMsg.ObjectPropertyInt.Parser.ParseFrom(xMsg.msg_data); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(propertyData.player_id)); NFIPropertyManager propertyManager = go.GetPropertyManager(); for (int i = 0; i < propertyData.property_list.Count; i++) { NFIProperty property = propertyManager.GetProperty(propertyData.property_list[i].property_name.ToStringUtf8()); if (null == property) { NFDataList varList = new NFDataList(); varList.AddInt(0); property = propertyManager.AddProperty(propertyData.property_list[i].property_name.ToStringUtf8(), varList); } property.SetInt(propertyData.property_list[i].data); } }
///////////////////////////////////////////////////////////////////// private void EGMI_ACK_PROPERTY_INT(MsgHead head, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize<NFMsg.MsgBase>(stream); NFMsg.ObjectPropertyInt propertyData = new NFMsg.ObjectPropertyInt(); propertyData = Serializer.Deserialize<NFMsg.ObjectPropertyInt>(new MemoryStream(xMsg.msg_data)); NFIObject go = NFCKernelModule.Instance.GetObject(PBToNF(propertyData.player_id)); NFIPropertyManager propertyManager = go.GetPropertyManager(); for(int i = 0; i < propertyData.property_list.Count; i++) { NFIProperty property = propertyManager.GetProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name)); if(null == property) { NFIDataList varList = new NFCDataList(); varList.AddInt(0); property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name), varList); } property.SetInt(propertyData.property_list[i].data); } }
public void RequireEnterGameServer(NFCoreEx.NFIDENTID objectID, string strAccount, string strRoleName, int nServerID) { NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer(); xData.name = UnicodeEncoding.Default.GetBytes(strRoleName); xData.account = UnicodeEncoding.Default.GetBytes(strAccount); xData.game_id = nServerID; xData.id = NFToPB(objectID); MemoryStream stream = new MemoryStream(); Serializer.Serialize<NFMsg.ReqEnterGameServer>(stream, xData); SendMsg(objectID, NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream); if (NFStart.Instance.bDebugMode) { //EGMI_ACK_OBJECT_ENTRY //property //EGMI_ACK_SWAP_SCENE //EGMI_ACK_OBJECT_ENTRY //property float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; NFIElement xElement = NFCElementManager.Instance.GetElement("1"); if (null != xElement) { string strRelivePos = xElement.QueryString("RelivePos"); string[] sArray = strRelivePos.Split(';'); if (sArray.Length > 0) { sArray = sArray[0].Split(','); } if (sArray.Length == 3) { fX = float.Parse(sArray[0]); fY = float.Parse(sArray[1]); fZ = float.Parse(sArray[2]); } } ///////////////////////////////////////////// //mainplayer NFMsg.AckPlayerEntryList xAckMainBodyData = new NFMsg.AckPlayerEntryList(); NFMsg.PlayerEntryInfo xInfo = new NFMsg.PlayerEntryInfo(); NFMsg.Ident xID = new NFMsg.Ident(); xInfo.object_guid = xID; xInfo.x = fX; xInfo.y = fY; xInfo.z = fZ; xInfo.career_type = 1; xInfo.player_state = 1; xInfo.config_id = UnicodeEncoding.Default.GetBytes(""); xInfo.scene_id = 1; xInfo.class_id = UnicodeEncoding.Default.GetBytes("Player"); xAckMainBodyData.object_list.Add(xInfo); MemoryStream xAckMianPlayerBodyStream = new MemoryStream(); Serializer.Serialize<NFMsg.AckPlayerEntryList>(xAckMianPlayerBodyStream, xAckMainBodyData); NFMsg.MsgBase xAckMianPlayerData = new NFMsg.MsgBase(); xAckMianPlayerData.player_id = xID; xAckMianPlayerData.msg_data = xAckMianPlayerBodyStream.ToArray(); MemoryStream xAckAllStream = new MemoryStream(); Serializer.Serialize<NFMsg.MsgBase>(xAckAllStream, xAckMianPlayerData); MsgHead head = new MsgHead(); head.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_OBJECT_ENTRY; head.unDataLen = (UInt32)xAckAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(head, xAckAllStream.ToArray()); ///////////////////////////////////////////// //property NFMsg.ObjectPropertyInt propertyData = new NFMsg.ObjectPropertyInt(); PropertyInt xPropertyInt = new PropertyInt(); xPropertyInt.property_name = UnicodeEncoding.Default.GetBytes("MOVE_SPEED"); xPropertyInt.data = 50000; propertyData.property_list.Add(xPropertyInt); propertyData.player_id = xID; MemoryStream xAckPropertyIntStream = new MemoryStream(); Serializer.Serialize<NFMsg.ObjectPropertyInt>(xAckPropertyIntStream, propertyData); NFMsg.MsgBase xPropertyIntMsg = new NFMsg.MsgBase(); xPropertyIntMsg.player_id = xID; xPropertyIntMsg.msg_data = xAckPropertyIntStream.ToArray(); MemoryStream xAckPropertyIntAllStream = new MemoryStream(); Serializer.Serialize<NFMsg.MsgBase>(xAckPropertyIntAllStream, xPropertyIntMsg); MsgHead xAckPropertyhead = new MsgHead(); xAckPropertyhead.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_PROPERTY_INT; xAckPropertyhead.unDataLen = (UInt32)xAckPropertyIntAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(xAckPropertyhead, xAckPropertyIntAllStream.ToArray()); ///////////////////////////////////////////// xNet.mPlayerState = NFNet.PLAYER_STATE.E_PLAYER_GAMEING; //NFCRenderInterface.Instance.LoadScene(1, fX, fY, fZ); ///////////////////////////////////////////// //npc NFMsg.AckPlayerEntryList xAckNPCBodyData = new NFMsg.AckPlayerEntryList(); for (int i = 0; i < 5; ++i) { NFMsg.PlayerEntryInfo xNPCInfo = new NFMsg.PlayerEntryInfo(); NFMsg.Ident xNPCID = new NFMsg.Ident(); xNPCID.index = i + 10000; xNPCInfo.object_guid = xNPCID; xNPCInfo.x = fX + i; xNPCInfo.y = fY; xNPCInfo.z = fZ + i; xNPCInfo.career_type = 1; xNPCInfo.player_state = 1; xNPCInfo.config_id = UnicodeEncoding.Default.GetBytes(""); xNPCInfo.scene_id = 1; xNPCInfo.class_id = UnicodeEncoding.Default.GetBytes("Player"); xAckNPCBodyData.object_list.Add(xNPCInfo); } MemoryStream xAckNPCBodyStream = new MemoryStream(); Serializer.Serialize<NFMsg.AckPlayerEntryList>(xAckNPCBodyStream, xAckNPCBodyData); NFMsg.MsgBase xAckNPCrData = new NFMsg.MsgBase(); xAckNPCrData.player_id = xID; xAckNPCrData.msg_data = xAckNPCBodyStream.ToArray(); MemoryStream xAckAllNPCStream = new MemoryStream(); Serializer.Serialize<NFMsg.MsgBase>(xAckAllNPCStream, xAckNPCrData); MsgHead xNPCHead = new MsgHead(); xNPCHead.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_OBJECT_ENTRY; xNPCHead.unDataLen = (UInt32)xAckAllNPCStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(xNPCHead, xAckAllNPCStream.ToArray()); ////////////////////////////////////////////// } }
public void RequirePropertyInt(NFrame.NFGUID objectID, string strPropertyName, NFIDataList.TData newVar) { NFMsg.ObjectPropertyInt xData = new NFMsg.ObjectPropertyInt(); xData.player_id = NFBinarySendLogic.NFToPB(objectID); NFMsg.PropertyInt xPropertyInt = new NFMsg.PropertyInt(); xPropertyInt.property_name = System.Text.Encoding.Default.GetBytes(strPropertyName); xPropertyInt.data = newVar.IntVal(); xData.property_list.Add(xPropertyInt); MemoryStream stream = new MemoryStream(); Serializer.Serialize<NFMsg.ObjectPropertyInt>(stream, xData); Debug.Log("send upload int"); SendMsg(objectID, NFMsg.EGameMsgID.EGMI_ACK_PROPERTY_INT, stream); }
public void RequireEnterGameServer(NFCoreEx.NFIDENTID objectID, string strAccount, string strRoleName, int nServerID) { NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer(); xData.name = UnicodeEncoding.Default.GetBytes(strRoleName); xData.account = UnicodeEncoding.Default.GetBytes(strAccount); xData.game_id = nServerID; xData.id = NFToPB(objectID); MemoryStream stream = new MemoryStream(); Serializer.Serialize <NFMsg.ReqEnterGameServer>(stream, xData); SendMsg(objectID, NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream); if (NFStart.Instance.bDebugMode) { //EGMI_ACK_OBJECT_ENTRY //property //EGMI_ACK_SWAP_SCENE //EGMI_ACK_OBJECT_ENTRY //property float fX = 0.0f; float fY = 0.0f; float fZ = 0.0f; NFIElement xElement = NFCElementManager.Instance.GetElement("1"); if (null != xElement) { string strRelivePos = xElement.QueryString("RelivePos"); string[] sArray = strRelivePos.Split(';'); if (sArray.Length > 0) { sArray = sArray[0].Split(','); } if (sArray.Length == 3) { fX = float.Parse(sArray[0]); fY = float.Parse(sArray[1]); fZ = float.Parse(sArray[2]); } } ///////////////////////////////////////////// //mainplayer NFMsg.AckPlayerEntryList xAckMainBodyData = new NFMsg.AckPlayerEntryList(); NFMsg.PlayerEntryInfo xInfo = new NFMsg.PlayerEntryInfo(); NFMsg.Ident xID = new NFMsg.Ident(); xInfo.object_guid = xID; xInfo.x = fX; xInfo.y = fY; xInfo.z = fZ; xInfo.career_type = 1; xInfo.player_state = 1; xInfo.config_id = UnicodeEncoding.Default.GetBytes(""); xInfo.scene_id = 1; xInfo.class_id = UnicodeEncoding.Default.GetBytes("Player"); xAckMainBodyData.object_list.Add(xInfo); MemoryStream xAckMianPlayerBodyStream = new MemoryStream(); Serializer.Serialize <NFMsg.AckPlayerEntryList>(xAckMianPlayerBodyStream, xAckMainBodyData); NFMsg.MsgBase xAckMianPlayerData = new NFMsg.MsgBase(); xAckMianPlayerData.player_id = xID; xAckMianPlayerData.msg_data = xAckMianPlayerBodyStream.ToArray(); MemoryStream xAckAllStream = new MemoryStream(); Serializer.Serialize <NFMsg.MsgBase>(xAckAllStream, xAckMianPlayerData); MsgHead head = new MsgHead(); head.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_OBJECT_ENTRY; head.unDataLen = (UInt32)xAckAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(head, xAckAllStream.ToArray()); ///////////////////////////////////////////// //property NFMsg.ObjectPropertyInt propertyData = new NFMsg.ObjectPropertyInt(); PropertyInt xPropertyInt = new PropertyInt(); xPropertyInt.property_name = UnicodeEncoding.Default.GetBytes("MOVE_SPEED"); xPropertyInt.data = 50000; propertyData.property_list.Add(xPropertyInt); propertyData.player_id = xID; MemoryStream xAckPropertyIntStream = new MemoryStream(); Serializer.Serialize <NFMsg.ObjectPropertyInt>(xAckPropertyIntStream, propertyData); NFMsg.MsgBase xPropertyIntMsg = new NFMsg.MsgBase(); xPropertyIntMsg.player_id = xID; xPropertyIntMsg.msg_data = xAckPropertyIntStream.ToArray(); MemoryStream xAckPropertyIntAllStream = new MemoryStream(); Serializer.Serialize <NFMsg.MsgBase>(xAckPropertyIntAllStream, xPropertyIntMsg); MsgHead xAckPropertyhead = new MsgHead(); xAckPropertyhead.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_PROPERTY_INT; xAckPropertyhead.unDataLen = (UInt32)xAckPropertyIntAllStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(xAckPropertyhead, xAckPropertyIntAllStream.ToArray()); ///////////////////////////////////////////// xNet.mPlayerState = NFNet.PLAYER_STATE.E_PLAYER_GAMEING; //NFCRenderInterface.Instance.LoadScene(1, fX, fY, fZ); ///////////////////////////////////////////// //npc NFMsg.AckPlayerEntryList xAckNPCBodyData = new NFMsg.AckPlayerEntryList(); for (int i = 0; i < 5; ++i) { NFMsg.PlayerEntryInfo xNPCInfo = new NFMsg.PlayerEntryInfo(); NFMsg.Ident xNPCID = new NFMsg.Ident(); xNPCID.index = i + 10000; xNPCInfo.object_guid = xNPCID; xNPCInfo.x = fX + i; xNPCInfo.y = fY; xNPCInfo.z = fZ + i; xNPCInfo.career_type = 1; xNPCInfo.player_state = 1; xNPCInfo.config_id = UnicodeEncoding.Default.GetBytes(""); xNPCInfo.scene_id = 1; xNPCInfo.class_id = UnicodeEncoding.Default.GetBytes("Player"); xAckNPCBodyData.object_list.Add(xNPCInfo); } MemoryStream xAckNPCBodyStream = new MemoryStream(); Serializer.Serialize <NFMsg.AckPlayerEntryList>(xAckNPCBodyStream, xAckNPCBodyData); NFMsg.MsgBase xAckNPCrData = new NFMsg.MsgBase(); xAckNPCrData.player_id = xID; xAckNPCrData.msg_data = xAckNPCBodyStream.ToArray(); MemoryStream xAckAllNPCStream = new MemoryStream(); Serializer.Serialize <NFMsg.MsgBase>(xAckAllNPCStream, xAckNPCrData); MsgHead xNPCHead = new MsgHead(); xNPCHead.unMsgID = (UInt16)NFMsg.EGameMsgID.EGMI_ACK_OBJECT_ENTRY; xNPCHead.unDataLen = (UInt32)xAckAllNPCStream.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; xNet.mxBinMsgEvent.OnMessageEvent(xNPCHead, xAckAllNPCStream.ToArray()); ////////////////////////////////////////////// } }