Пример #1
0
        private void OnPropertyString(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = new NFMsg.MsgBase();
            xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream);

            NFMsg.ObjectPropertyString propertyData = new NFMsg.ObjectPropertyString();
            propertyData = Serializer.Deserialize <NFMsg.ObjectPropertyString>(new MemoryStream(xMsg.msg_data));

            NFIObject go = NFCKernelModule.Instance().GetObject(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)
                {
                    NFIDataList varList = new NFCDataList();
                    varList.AddString("");

                    property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name), varList);
                }

                property.SetString(System.Text.Encoding.Default.GetString(propertyData.property_list[i].data));
            }
        }
Пример #2
0
 public override void RegisterCallback(string strPropertyName, NFIProperty.PropertyEventHandler handler)
 {
     if (mhtProperty.ContainsKey(strPropertyName))
     {
         NFIProperty xProperty = (NFCProperty)mhtProperty[strPropertyName];
         xProperty.RegisterCallback(handler);
     }
 }
Пример #3
0
        public override NFGUID QueryPropertyObject(string strPropertyName)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null != property)
            {
                return(property.QueryObject());
            }

            return(NFIDataList.NULL_OBJECT);
        }
Пример #4
0
        public override NFGUID QueryObject(string strName)
        {
            NFIProperty xProperty = GetPropertyManager().GetProperty(strName);

            if (null != xProperty)
            {
                return(xProperty.QueryObject());
            }

            return(NFDataList.NULL_OBJECT);
        }
Пример #5
0
        public override double QueryFloat(string strName)
        {
            NFIProperty xProperty = GetPropertyManager().GetProperty(strName);

            if (null != xProperty)
            {
                return(xProperty.QueryFloat());
            }

            return(0.0);
        }
Пример #6
0
        public override string QueryString(string strName)
        {
            NFIProperty xProperty = GetPropertyManager().GetProperty(strName);

            if (null != xProperty)
            {
                return(xProperty.QueryString());
            }

            return(NFDataList.NULL_STRING);
        }
Пример #7
0
        public override double QueryPropertyFloat(string strPropertyName)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null != property)
            {
                return(property.QueryFloat());
            }

            return(0.0);
        }
Пример #8
0
        public override Int64 QueryInt(string strName)
        {
            NFIProperty xProperty = GetPropertyManager().GetProperty(strName);

            if (null != xProperty)
            {
                return(xProperty.QueryInt());
            }

            return(0);
        }
Пример #9
0
        public override Int64 QueryPropertyInt(string strPropertyName)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null != property)
            {
                return(property.QueryInt());
            }

            return(0);
        }
Пример #10
0
        public override NFVector3 QueryPropertyVector3(string strPropertyName)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null != property)
            {
                return(property.QueryVector3());
            }

            return(NFIDataList.NULL_VECTOR3);
        }
Пример #11
0
        public override string QueryPropertyString(string strPropertyName)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null != property)
            {
                return(property.QueryString());
            }

            return(NFIDataList.NULL_STRING);
        }
Пример #12
0
        public override NFIProperty GetProperty(string strPropertyName)
        {
            NFIProperty xProperty = null;

            if (mhtProperty.ContainsKey(strPropertyName))
            {
                xProperty = (NFCProperty)mhtProperty[strPropertyName];
                return(xProperty);
            }

            return(xProperty);
        }
Пример #13
0
 public override bool SetProperty(string strPropertyName, NFDataList varData)
 {
     if (mhtProperty.ContainsKey(strPropertyName))
     {
         NFIProperty xProperty = (NFCProperty)mhtProperty[strPropertyName];
         if (null != xProperty)
         {
             xProperty.SetData(varData.GetData(0));
         }
     }
     return(true);
 }
Пример #14
0
        public override NFIProperty AddProperty(string strPropertyName, NFDataList.TData varData)
        {
            NFIProperty xProperty = null;

            if (!mhtProperty.ContainsKey(strPropertyName))
            {
                xProperty = new NFCProperty(mSelf, strPropertyName, varData);
                mhtProperty[strPropertyName] = xProperty;
            }

            return(xProperty);
        }
Пример #15
0
        public override bool SetPropertyVector3(string strPropertyName, NFVector3 obj)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFDataList.TData xValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR3);
                property = mPropertyManager.AddProperty(strPropertyName, xValue);
            }

            property.SetVector3(obj);
            return(true);
        }
Пример #16
0
        public override bool SetPropertyObject(string strPropertyName, NFGUID obj)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFDataList.TData xValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_OBJECT);
                property = mPropertyManager.AddProperty(strPropertyName, xValue);
            }

            property.SetObject(obj);
            return(true);
        }
Пример #17
0
        public override bool SetPropertyInt(string strPropertyName, Int64 nValue)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFDataList.TData xValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT);
                property = mPropertyManager.AddProperty(strPropertyName, xValue);
            }

            property.SetInt(nValue);
            return(true);
        }
Пример #18
0
        public override bool SetPropertyFloat(string strPropertyName, double fValue)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFDataList.TData xValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_FLOAT);
                property = mPropertyManager.AddProperty(strPropertyName, xValue);
            }

            property.SetFloat(fValue);
            return(true);
        }
Пример #19
0
        public override bool SetPropertyString(string strPropertyName, string strValue)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFDataList.TData xValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_STRING);
                property = mPropertyManager.AddProperty(strPropertyName, xValue);;
            }

            property.SetString(strValue);
            return(true);
        }
Пример #20
0
        public override bool SetPropertyVector3(string strPropertyName, NFVector3 obj)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFIDataList valueList = new NFCDataList();
                valueList.AddVector3(new NFVector3());
                property = mPropertyManager.AddProperty(strPropertyName, valueList);
            }

            property.SetVector3(obj);
            return(true);
        }
Пример #21
0
        public override bool SetPropertyObject(string strPropertyName, NFGUID obj)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFIDataList valueList = new NFCDataList();
                valueList.AddObject(new NFGUID());
                property = mPropertyManager.AddProperty(strPropertyName, valueList);
            }

            property.SetObject(obj);
            return(true);
        }
Пример #22
0
        public override bool SetPropertyString(string strPropertyName, string strValue)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFIDataList valueList = new NFCDataList();
                valueList.AddString("");
                property = mPropertyManager.AddProperty(strPropertyName, valueList);
            }

            property.SetString(strValue);
            return(true);
        }
Пример #23
0
        public override bool SetPropertyFloat(string strPropertyName, double fValue)
        {
            NFIProperty property = mPropertyManager.GetProperty(strPropertyName);

            if (null == property)
            {
                NFIDataList valueList = new NFCDataList();
                valueList.AddFloat(0.0f);
                property = mPropertyManager.AddProperty(strPropertyName, valueList);
            }

            property.SetFloat(fValue);
            return(true);
        }
Пример #24
0
        void AddBasePropertyFormOther(NFIClass xLogicClass, string strOther)
        {
            NFIClass xOtherClass = GetElement(strOther);

            if (null != xLogicClass && null != xOtherClass)
            {
                NFDataList xValue = xOtherClass.GetPropertyManager().GetPropertyList();
                for (int i = 0; i < xValue.Count(); ++i)
                {
                    NFIProperty xProperty = xOtherClass.GetPropertyManager().GetProperty(xValue.StringVal(i));
                    xLogicClass.GetPropertyManager().AddProperty(xValue.StringVal(i), xProperty.GetData());
                }
            }
        }
Пример #25
0
        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);
        }
Пример #26
0
        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());
                }
            }
        }
Пример #27
0
        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);
            }
        }
Пример #28
0
        private void LoadLogicClassProperty(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("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.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "float":
                    {
                        NFDataList.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_FLOAT);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "string":
                    {
                        NFDataList.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_STRING);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "object":
                    {
                        NFDataList.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_OBJECT);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "vector2":
                    {
                        NFDataList.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR2);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    case "vector3":
                    {
                        NFDataList.TData xValue    = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR3);
                        NFIProperty      xProperty = xLogicClass.GetPropertyManager().AddProperty(strID.Value, xValue);
                        xProperty.SetUpload(bUpload);
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #29
0
        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;
                            }
                        }
                    }
                }
            }
        }
Пример #30
0
        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));
                }
            }
        }