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); } }
public override bool SetPropertyInt(string strPropertyName, Int64 nValue) { NFIProperty property = mPropertyManager.GetProperty(strPropertyName); if (null == property) { NFIDataList valueList = new NFCDataList(); valueList.AddInt(0); property = mPropertyManager.AddProperty(strPropertyName, valueList); } property.SetInt(nValue); return(true); }
// 接收消息 private void OnLoginProcess(UInt16 id, MemoryStream stream) { Debug.Log("OnLoginProcess1"); NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); Debug.Log("OnLoginProcess2"); NFMsg.AckEventResult xData = new NFMsg.AckEventResult(); xData = Serializer.Deserialize <NFMsg.AckEventResult>(new MemoryStream(xMsg.msg_data)); Debug.Log("OnLoginProcess3"); if (EGameEventCode.EGEC_ACCOUNT_SUCCESS == xData.event_code) { Debug.Log("Login SUCCESS"); DoEvent((int)Event.LoginSuccess); } else { Debug.Log("Login Faild,Code: " + xData.event_code); NFCDataList varList = new NFCDataList(); varList.AddInt((Int64)xData.event_code); DoEvent((int)Event.LoginFailure); } }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = NFCKernelModule.Instance().GetObject(self); NFIRecordManager xRecordManager = go.GetRecordManager(); Hashtable recordVecDesc = new Hashtable(); Hashtable recordVecData = new Hashtable(); for (int k = 0; k < xAddStruct.record_int_list.Count; ++k) { NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k]; if (addIntStruct.col >= 0) { recordVecDesc[addIntStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_INT; recordVecData[addIntStruct.col] = addIntStruct.data; } } for (int k = 0; k < xAddStruct.record_float_list.Count; ++k) { NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k]; if (addFloatStruct.col >= 0) { recordVecDesc[addFloatStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_FLOAT; recordVecData[addFloatStruct.col] = addFloatStruct.data; } } for (int k = 0; k < xAddStruct.record_string_list.Count; ++k) { NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k]; if (addStringStruct.col >= 0) { recordVecDesc[addStringStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_STRING; recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data); } } for (int k = 0; k < xAddStruct.record_object_list.Count; ++k) { NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_OBJECT; recordVecData[addObjectStruct.col] = PBToNF(addObjectStruct.data); } } NFIDataList varListDesc = new NFCDataList(); NFIDataList varListData = new NFCDataList(); for (int m = 0; m < recordVecDesc.Count; m++) { if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m)) { NFIDataList.VARIANT_TYPE nType = (NFIDataList.VARIANT_TYPE)recordVecDesc[m]; switch (nType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { varListDesc.AddInt(0); varListData.AddInt((Int64)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { varListDesc.AddFloat(0.0f); varListData.AddFloat((float)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { varListDesc.AddString(""); varListData.AddString((string)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { varListDesc.AddObject(new NFGUID()); varListData.AddObject((NFGUID)recordVecData[m]); } break; default: break; } } else { //报错 //Debug.LogException(i); } } NFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc); } xRecord.AddRow(xAddStruct.row, varListData); }
private void LoadInstanceElement(NFILogicClass xLogicClass) { string strLogicPath = mstrRootPath; strLogicPath += xLogicClass.GetInstance(); XmlDocument xmldoc = new XmlDocument(); if (xLogicClass.GetEncrypt()) { /////////////////////////////////////////////////////////////////////////////////////// StreamReader cepherReader = new StreamReader(strLogicPath);; string strContent = cepherReader.ReadToEnd(); cepherReader.Close(); byte[] data = Convert.FromBase64String(strContent); string res = System.Text.ASCIIEncoding.Default.GetString(data); xmldoc.LoadXml(res); ///////////////////////////////////////////////////////////////// } else { xmldoc.Load(strLogicPath); } XmlNode xRoot = xmldoc.SelectSingleNode("XML"); XmlNodeList xNodeList = xRoot.SelectNodes("Object"); for (int i = 0; i < xNodeList.Count; ++i) { //NFCLog.Instance.Log("Class:" + xLogicClass.GetName()); XmlNode xNodeClass = xNodeList.Item(i); XmlAttribute strID = xNodeClass.Attributes["Id"]; //NFCLog.Instance.Log("ClassID:" + strID.Value); NFIElement xElement = GetElement(strID.Value); if (null == xElement) { xElement = new NFCElement(); AddElement(strID.Value, xElement); xLogicClass.AddConfigName(strID.Value); XmlAttributeCollection xCollection = xNodeClass.Attributes; for (int j = 0; j < xCollection.Count; ++j) { XmlAttribute xAttribute = xCollection[j]; NFIProperty xProperty = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name); if (null != xProperty) { NFIDataList.VARIANT_TYPE eType = xProperty.GetType(); switch (eType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFIDataList xValue = new NFCDataList(); xValue.AddInt(int.Parse(xAttribute.Value)); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFIDataList xValue = new NFCDataList(); xValue.AddFloat(float.Parse(xAttribute.Value)); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFIDataList xValue = new NFCDataList(); xValue.AddString(xAttribute.Value); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFIDataList xValue = new NFCDataList(); xValue.AddObject(new NFGUID(0, int.Parse(xAttribute.Value))); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; default: break; } } } } } }
private void OnObjectPropertyEntry(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.MultiObjectPropertyList xMultiObjectPropertyList = new NFMsg.MultiObjectPropertyList(); xMultiObjectPropertyList = Serializer.Deserialize <NFMsg.MultiObjectPropertyList>(new MemoryStream(xMsg.msg_data)); for (int i = 0; i < xMultiObjectPropertyList.multi_player_property.Count; i++) { NFMsg.ObjectPropertyList xPropertyData = xMultiObjectPropertyList.multi_player_property[i]; NFIObject go = NFCKernelModule.Instance().GetObject(PBToNF(xPropertyData.player_id)); NFIPropertyManager xPropertyManager = go.GetPropertyManager(); for (int j = 0; j < xPropertyData.property_int_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xPropertyData.property_int_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFIDataList varList = new NFCDataList(); varList.AddInt(0); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetInt(xPropertyData.property_int_list[j].data); } for (int j = 0; j < xPropertyData.property_float_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xPropertyData.property_float_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFIDataList varList = new NFCDataList(); varList.AddFloat(0); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetFloat(xPropertyData.property_float_list[j].data); } for (int j = 0; j < xPropertyData.property_string_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xPropertyData.property_string_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFIDataList varList = new NFCDataList(); varList.AddString(""); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetString(System.Text.Encoding.Default.GetString(xPropertyData.property_string_list[j].data)); } for (int j = 0; j < xPropertyData.property_object_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xPropertyData.property_object_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFIDataList varList = new NFCDataList(); varList.AddObject(new NFGUID()); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetObject(PBToNF(xPropertyData.property_object_list[j].data)); } } }
public override NFIObject CreateObject(NFGUID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, NFIDataList arg) { if (!mhtObject.ContainsKey(self)) { NFIObject xNewObject = new NFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex); mhtObject.Add(self, xNewObject); NFCDataList varConfigID = new NFCDataList(); varConfigID.AddString(strConfigIndex); xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID); NFCDataList varConfigClass = new NFCDataList(); varConfigClass.AddString(strClassName); xNewObject.GetPropertyManager().AddProperty("ClassName", varConfigClass); if (arg.Count() % 2 == 0) { for (int i = 0; i < arg.Count() - 1; i += 2) { string strPropertyName = arg.StringVal(i); NFIDataList.VARIANT_TYPE eType = arg.GetType(i + 1); switch (eType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddInt(arg.IntVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddFloat(arg.FloatVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFIDataList xDataList = new NFCDataList(); xDataList.AddString(arg.StringVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFIDataList xDataList = new NFCDataList(); xDataList.AddObject(arg.ObjectVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFIDataList xDataList = new NFCDataList(); xDataList.AddVector2(arg.Vector2Val(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFIDataList xDataList = new NFCDataList(); xDataList.AddVector3(arg.Vector3Val(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; default: break; } } } InitProperty(self, strClassName); InitRecord(self, strClassName); ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; if (null != xHandleDel && null != xHandleDel.GetHandler()) { NFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler(); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH, strClassName, strConfigIndex); } //NFCLog.Instance.Log(NFCLog.LOG_LEVEL.DEBUG, "Create object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + nContainerID + " GroupID: " + nGroupID); return(xNewObject); } return(null); }
private void LoadLogicClassRecord(string strName) { NFILogicClass xLogicClass = GetElement(strName); if (null != xLogicClass) { string strLogicPath = mstrPath + xLogicClass.GetPath(); XmlDocument xmldoc = new XmlDocument(); if (mbEncrypt) { /////////////////////////////////////////////////////////////////////////////////////// StreamReader cepherReader = new StreamReader(strLogicPath);; string strContent = cepherReader.ReadToEnd(); cepherReader.Close(); byte[] data = Convert.FromBase64String(strContent); string res = System.Text.ASCIIEncoding.Default.GetString(data); xmldoc.LoadXml(res); ///////////////////////////////////////////////////////////////// } else { xmldoc.Load(strLogicPath); } XmlNode xRoot = xmldoc.SelectSingleNode("XML"); XmlNode xNodePropertys = xRoot.SelectSingleNode("Records"); if (null != xNodePropertys) { XmlNodeList xNodeList = xNodePropertys.SelectNodes("Record"); if (null != xNodeList) { for (int i = 0; i < xNodeList.Count; ++i) { XmlNode xRecordNode = xNodeList.Item(i); string strID = xRecordNode.Attributes["Id"].Value; string strRow = xRecordNode.Attributes["Row"].Value; string strUpload = xRecordNode.Attributes["Upload"].Value; bool bUpload = strUpload.Equals("1"); NFIDataList xValue = new NFCDataList(); XmlNodeList xTagNodeList = xRecordNode.SelectNodes("Col"); for (int j = 0; j < xTagNodeList.Count; ++j) { XmlNode xColTagNode = xTagNodeList.Item(j); XmlAttribute strTagID = xColTagNode.Attributes["Tag"]; XmlAttribute strTagType = xColTagNode.Attributes["Type"]; switch (strTagType.Value) { case "int": { xValue.AddInt(0); } break; case "float": { xValue.AddFloat(0.0); } break; case "string": { xValue.AddString(""); } break; case "object": { xValue.AddObject(new NFGUID(0, 0)); } break; default: break; } } NFIRecord xRecord = xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue); xRecord.SetUpload(bUpload); } } } } }