public void OnClassHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex) { if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE) { NFIObject xObject = NFCKernelModule.Instance.GetObject(self); NFIPropertyManager xPropertyManager = xObject.GetPropertyManager(); NFDataList xPropertyNameList = xPropertyManager.GetPropertyList(); for (int i = 0; i < xPropertyNameList.Count(); i++) { string strPropertyName = xPropertyNameList.StringVal(i); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (xProperty.GetUpload()) { xProperty.RegisterCallback(OnPropertyHandler); } } NFIRecordManager xRecordManager = xObject.GetRecordManager(); NFDataList xRecordNameList = xRecordManager.GetRecordList(); for (int i = 0; i < xRecordNameList.Count(); i++) { string strRecodeName = xRecordNameList.StringVal(i); NFIRecord xRecord = xRecordManager.GetRecord(strRecodeName); if (xRecord.GetUpload()) { xRecord.RegisterCallback(OnRecordHandler); } } } }
private void OnClassPlayerEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex) { if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH) { NFIClass classObject = mClassModule.GetElement(strClassName); NFIPropertyManager propertyManager = classObject.GetPropertyManager(); NFIRecordManager recordManager = classObject.GetRecordManager(); NFDataList propertyList = propertyManager.GetPropertyList(); NFDataList recordList = recordManager.GetRecordList(); for (int i = 0; i < propertyList.Count(); ++i) { NFIProperty propertyObject = propertyManager.GetProperty(propertyList.StringVal(i)); if (propertyObject.GetUpload()) { mKernelModule.RegisterPropertyCallback(self, propertyObject.GetKey(), OnPropertyDataHandler); } } for (int i = 0; i < recordList.Count(); ++i) { NFIRecord recordObject = recordManager.GetRecord(recordList.StringVal(i)); if (recordObject.GetUpload()) { mKernelModule.RegisterRecordCallback(self, recordObject.GetName(), RecordEventHandler); } } } }
public void OnPropertyHandler(NFGUID self, string strPropertyName, NFDataList.TData oldVar, NFDataList.TData newVar) { NFIObject xObject = NFCKernelModule.Instance.GetObject(self); NFIProperty xProperty = xObject.GetPropertyManager().GetProperty(strPropertyName); if (!xProperty.GetUpload()) { return; } switch (oldVar.GetType()) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFNetController.Instance.mxNetSender.RequirePropertyInt(self, strPropertyName, newVar); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFNetController.Instance.mxNetSender.RequirePropertyFloat(self, strPropertyName, newVar); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFNetController.Instance.mxNetSender.RequirePropertyString(self, strPropertyName, newVar); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFNetController.Instance.mxNetSender.RequirePropertyObject(self, strPropertyName, newVar); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFNetController.Instance.mxNetSender.RequirePropertyVector2(self, strPropertyName, newVar); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFNetController.Instance.mxNetSender.RequirePropertyVector3(self, strPropertyName, newVar); } break; } }
void InitProperty(NFGUID self, string strClassName) { NFIClass xLogicClass = mxLogicClassModule.GetElement(strClassName); NFDataList xDataList = xLogicClass.GetPropertyManager().GetPropertyList(); for (int i = 0; i < xDataList.Count(); ++i) { string strPropertyName = xDataList.StringVal(i); NFIProperty xProperty = xLogicClass.GetPropertyManager().GetProperty(strPropertyName); NFIObject xObject = GetObject(self); NFIPropertyManager xPropertyManager = xObject.GetPropertyManager(); NFIProperty property = xPropertyManager.AddProperty(strPropertyName, xProperty.GetData()); //if property==null ,means this property alreay exist in manager if (property != null) { property.SetUpload(xProperty.GetUpload()); } } }
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 LoadInstanceElement(NFIClass xLogicClass) { string strLogicPath = mstrRootPath; strLogicPath += xLogicClass.GetInstance(); strLogicPath = strLogicPath.Replace(".xml", ""); TextAsset textAsset = (TextAsset)Resources.Load(strLogicPath); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(textAsset.text); 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; } } } } } }