private void OnObjectMove(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ReqAckPlayerMove xData = new NFMsg.ReqAckPlayerMove(); xData = Serializer.Deserialize <NFMsg.ReqAckPlayerMove>(new MemoryStream(xMsg.msg_data)); if (xData.target_pos.Count <= 0) { return; } NFGUID mover = mHelpModule.PBToNF(xData.mover); float fSpeed = mKernelModule.QueryPropertyInt(mover, NFrame.Player.MOVE_SPEED) / 100.0f; NFDataList var = new NFDataList(); var.AddObject(mHelpModule.PBToNF(xData.mover)); var.AddFloat(fSpeed); var.AddInt(xData.moveType); NFVector3 pos = mHelpModule.PBToNF(xData.target_pos[0]); var.AddVector3(pos); mEventModule.DoEvent((int)Event.PlayerMove, var); }
private void OnPropertyFloat(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectPropertyFloat propertyData = new NFMsg.ObjectPropertyFloat(); propertyData = Serializer.Deserialize <NFMsg.ObjectPropertyFloat>(new MemoryStream(xMsg.msg_data)); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(propertyData.player_id)); for (int i = 0; i < propertyData.property_list.Count; i++) { NFIPropertyManager propertyManager = go.GetPropertyManager(); NFIProperty property = propertyManager.GetProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name)); if (null == property) { NFDataList varList = new NFDataList(); varList.AddFloat(0.0f); property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name), varList); } property.SetFloat(propertyData.property_list[i].data); } }
public override bool SetPropertyFloat(string strPropertyName, double fValue) { NFIProperty property = mPropertyManager.GetProperty(strPropertyName); if (null == property) { NFDataList valueList = new NFDataList(); valueList.AddFloat(0.0f); property = mPropertyManager.AddProperty(strPropertyName, valueList); } property.SetFloat(fValue); return(true); }
private void OnObjectJump(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ReqAckPlayerMove xData = NFMsg.ReqAckPlayerMove.Parser.ParseFrom(xMsg.msg_data); if (xData.target_pos.Count <= 0) { return; } float fSpeed = mKernelModule.QueryPropertyInt(mHelpModule.PBToNF(xData.mover), "MOVE_SPEED") / 100.0f; NFDataList var = new NFDataList(); var.AddObject(mHelpModule.PBToNF(xData.mover)); var.AddFloat(fSpeed); var.AddVector3(mHelpModule.PBToNF(xData.target_pos[0])); mEventModule.DoEvent((int)Event.PlayerJump, var); //DoEvent((int)Event.PlayerJump, var); }
private void OnPropertyFloat(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ObjectPropertyFloat propertyData = NFMsg.ObjectPropertyFloat.Parser.ParseFrom(xMsg.msg_data); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(propertyData.player_id)); for (int i = 0; i < propertyData.property_list.Count; i++) { NFIPropertyManager propertyManager = go.GetPropertyManager(); NFIProperty property = propertyManager.GetProperty(propertyData.property_list[i].property_name.ToStringUtf8()); if (null == property) { NFDataList varList = new NFDataList(); varList.AddFloat(0.0f); property = propertyManager.AddProperty(propertyData.property_list[i].property_name.ToStringUtf8(), varList); } property.SetFloat(propertyData.property_list[i].data); } }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = mKernelModule.GetObject(self); if (go == null) { return; } 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] = NFDataList.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] = NFDataList.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] = NFDataList.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] = NFDataList.VARIANT_TYPE.VTYPE_OBJECT; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } for (int k = 0; k < xAddStruct.record_vector2_list.Count; ++k) { NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.record_vector2_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR2; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } for (int k = 0; k < xAddStruct.record_vector3_list.Count; ++k) { NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.record_vector3_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR3; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } NFDataList varListDesc = new NFDataList(); NFDataList varListData = new NFDataList(); for (int m = 0; m < recordVecDesc.Count; m++) { if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m)) { NFDataList.VARIANT_TYPE nType = (NFDataList.VARIANT_TYPE)recordVecDesc[m]; switch (nType) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { varListDesc.AddInt(0); varListData.AddInt((Int64)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { varListDesc.AddFloat(0.0f); varListData.AddFloat((float)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { varListDesc.AddString(""); varListData.AddString((string)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { varListDesc.AddObject(new NFGUID()); varListData.AddObject((NFGUID)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { varListDesc.AddVector2(new NFVector2()); varListData.AddVector2((NFVector2)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { varListDesc.AddVector3(new NFVector3()); varListData.AddVector3((NFVector3)recordVecData[m]); } break; default: break; } } else { //���� //Debug.LogException(i); } } NFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { string strClassName = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); NFIClass xLogicClass = mClassModule.GetElement(strClassName); NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName); xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData()); } xRecord.AddRow(xAddStruct.row, varListData); }
private void LoadLogicClassRecord(string strName) { NFIClass xLogicClass = GetElement(strName); if (null != xLogicClass) { string strLogicPath = mstrPath + xLogicClass.GetPath(); strLogicPath = strLogicPath.Replace(".xml", ""); TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(textAsset.text); 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"); NFDataList xValue = new NFDataList(); NFDataList xTag = new NFDataList(); 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"]; xTag.AddString(strTagID.Value); 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; case "vector2": { xValue.AddVector2(NFVector2.Zero()); } break; case "vector3": { xValue.AddVector3(NFVector3.Zero()); } break; default: break; } } NFIRecord xRecord = xLogicClass.GetRecordManager().AddRecord(strID, int.Parse(strRow), xValue, xTag); xRecord.SetUpload(bUpload); } } } } }
internal void OnObjectPropertyEntry(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.MultiObjectPropertyList xMultiObjectPropertyList = NFMsg.MultiObjectPropertyList.Parser.ParseFrom(xMsg.msg_data); for (int i = 0; i < xMultiObjectPropertyList.multi_player_property.Count; i++) { NFMsg.ObjectPropertyList xPropertyData = xMultiObjectPropertyList.multi_player_property[i]; NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(xPropertyData.player_id)); NFIPropertyManager xPropertyManager = go.GetPropertyManager(); for (int j = 0; j < xPropertyData.property_int_list.Count; j++) { string strPropertyName = xPropertyData.property_int_list[j].property_name.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); 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 = xPropertyData.property_float_list[j].property_name.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); 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 = xPropertyData.property_string_list[j].property_name.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddString(""); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetString(xPropertyData.property_string_list[j].data.ToStringUtf8()); } for (int j = 0; j < xPropertyData.property_object_list.Count; j++) { string strPropertyName = xPropertyData.property_object_list[j].property_name.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddObject(new NFGUID()); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetObject(mHelpModule.PBToNF(xPropertyData.property_object_list[j].data)); } } }
public override NFIObject CreateObject(NFGUID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, NFDataList arg) { if (!mhtObject.ContainsKey(self)) { NFIObject xNewObject = new NFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex); mhtObject.Add(self, xNewObject); NFDataList varConfigID = new NFDataList(); varConfigID.AddString(strConfigIndex); xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID); NFDataList varConfigClass = new NFDataList(); 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); NFDataList.VARIANT_TYPE eType = arg.GetType(i + 1); switch (eType) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFDataList xDataList = new NFDataList(); xDataList.AddInt(arg.IntVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFDataList xDataList = new NFDataList(); xDataList.AddFloat(arg.FloatVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFDataList xDataList = new NFDataList(); xDataList.AddString(arg.StringVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFDataList xDataList = new NFDataList(); xDataList.AddObject(arg.ObjectVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFDataList xDataList = new NFDataList(); xDataList.AddVector2(arg.Vector2Val(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFDataList xDataList = new NFDataList(); 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 LoadLogicClassProperty(string strName) { NFIClass xLogicClass = GetElement(strName); if (null != xLogicClass) { XmlDocument xmldoc = new XmlDocument(); string strLogicPath = mstrPath + xLogicClass.GetPath(); if (RuntimePlatform.Android == Application.platform || RuntimePlatform.IPhonePlayer == Application.platform) { strLogicPath = strLogicPath.Replace(".xml", ""); TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath); xmldoc.LoadXml(textAsset.text); } else { try { xmldoc.Load(strLogicPath); } catch (Exception e) { Debug.LogFormat("Load Config Error {0}", e.ToString()); } } XmlNode xRoot = xmldoc.SelectSingleNode("XML"); XmlNode xNodePropertys = xRoot.SelectSingleNode("Propertys"); XmlNodeList xNodeList = xNodePropertys.SelectNodes("Property"); for (int i = 0; i < xNodeList.Count; ++i) { XmlNode xPropertyNode = xNodeList.Item(i); XmlAttribute strID = xPropertyNode.Attributes["Id"]; XmlAttribute strType = xPropertyNode.Attributes["Type"]; XmlAttribute strUpload = xPropertyNode.Attributes["Upload"]; bool bUpload = strUpload.Value.Equals("1"); switch (strType.Value) { case "int": { NFDataList xValue = new NFDataList(); xValue.AddInt(0); NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); xProperty.SetUpload(bUpload); } break; case "float": { NFDataList xValue = new NFDataList(); xValue.AddFloat(0.0); NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); xProperty.SetUpload(bUpload); } break; case "string": { NFDataList xValue = new NFDataList(); xValue.AddString(""); NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); xProperty.SetUpload(bUpload); } break; case "object": { NFDataList xValue = new NFDataList(); xValue.AddObject(new NFGUID(0, 0)); NFIProperty xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue); xProperty.SetUpload(bUpload); } break; default: break; } } } }
private void LoadInstanceElement(NFIClass xLogicClass) { string strLogicPath = mstrRootPath; strLogicPath += xLogicClass.GetInstance(); XmlDocument xmldoc = new XmlDocument(); 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) { NFDataList.VARIANT_TYPE eType = xProperty.GetType(); switch (eType) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFDataList xValue = new NFDataList(); xValue.AddInt(int.Parse(xAttribute.Value)); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFDataList xValue = new NFDataList(); xValue.AddFloat(float.Parse(xAttribute.Value)); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFDataList xValue = new NFDataList(); xValue.AddString(xAttribute.Value); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFDataList xValue = new NFDataList(); xValue.AddObject(new NFGUID(0, int.Parse(xAttribute.Value))); NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue); property.SetUpload(xProperty.GetUpload()); } break; default: break; } } } } } }