示例#1
0
    private void OnClassNPCEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
    {
        if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE)
        {
            string strConfigID = NFCKernelModule.Instance.QueryPropertyString(self, "ConfigID");
            Vector3 vec = new Vector3();
            vec.x = (float)NFCKernelModule.Instance.QueryPropertyFloat(self, "X");
            vec.y = (float)NFCKernelModule.Instance.QueryPropertyFloat(self, "Y");
            vec.z = (float)NFCKernelModule.Instance.QueryPropertyFloat(self, "Z");

            string strPrefabPath = "";
            if (strConfigID.Length <= 0)
            {
                strPrefabPath = NFCKernelModule.Instance.GetElementModule().QueryPropertyString("Player", "Prefab");
            }
            else
            {
                strPrefabPath = NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strConfigID, "Prefab");
            }

            //CreateObject(self, strPrefabPath, vec, strClassName);
        }
        else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY)
        {
            //DestroyObject(self);
        }
        
    }
示例#2
0
        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();
                NFIDataList 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();
                NFIDataList 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);
                    }
                }
            }
        }
示例#3
0
 static void OnClassHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
 {
     Debug.Log(self);
     Debug.Log(" ");
     Debug.Log(eType.ToString());
     Debug.Log(" ");
     Debug.Log(strClassName);
     Debug.Log(" ");
     Debug.Log(strConfigIndex);
     Debug.Log(" ");
 }
示例#4
0
 static void OnClassHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
 {
     Console.Write(self);
     Console.Write(" ");
     Console.Write(eType.ToString());
     Console.Write(" ");
     Console.Write(strClassName);
     Console.Write(" ");
     Console.Write(strConfigIndex);
     Console.WriteLine(" ");
 }
示例#5
0
			public void AddDel(NFIObject.ClassEventHandler handler)
			{
				if (!mhtHandleDelList.ContainsKey(handler))
				{
					mhtHandleDelList.Add(handler, handler.ToString());
					mHandleDel += handler;
				}
			}
示例#6
0
		public override void RegisterClassCallBack(string strClassName, NFIObject.ClassEventHandler handler)
		{
			if(mhtClassHandleDel.ContainsKey(strClassName))
			{
				ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName];
				xHandleDel.AddDel(handler);
				
			}
			else
			{
				ClassHandleDel xHandleDel = new ClassHandleDel();
				xHandleDel.AddDel(handler);
				mhtClassHandleDel[strClassName] = xHandleDel;
			}
		}
        private void AttachObjectData(NFGUID self)
        {
            Debug.Log("AttachObjectData : " + self.ToString());

            ObjectDataBuff xDataBuff;

            if (mxObjectDataBuff.TryGetValue(self, out xDataBuff))
            {
                ////////////////record
                if (xDataBuff.xRecordList != null)
                {
                    for (int j = 0; j < xDataBuff.xRecordList.RecordList.Count; j++)
                    {
                        NFMsg.ObjectRecordBase xObjectRecordBase = xDataBuff.xRecordList.RecordList[j];
                        string srRecordName = xObjectRecordBase.RecordName.ToStringUtf8();

                        for (int k = 0; k < xObjectRecordBase.RowStruct.Count; ++k)
                        {
                            NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.RowStruct[k];

                            ADD_ROW(self, xObjectRecordBase.RecordName.ToStringUtf8(), xAddRowStruct);
                        }
                    }

                    xDataBuff.xRecordList = null;
                }
                ////////////////property
                if (xDataBuff.xPropertyList != null)
                {
                    ///
                    NFIObject          go = mKernelModule.GetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PlayerId));
                    NFIPropertyManager xPropertyManager = go.GetPropertyManager();

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyIntList.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyIntList[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT);
                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                        //Debug.LogError (self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_int_list[j].Data);

                        xProperty.SetInt(xDataBuff.xPropertyList.PropertyIntList[j].Data);
                    }

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyFloatList.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyFloatList[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_FLOAT);
                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        xProperty.SetFloat(xDataBuff.xPropertyList.PropertyFloatList[j].Data);
                    }

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyStringList.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyStringList[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_STRING);
                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                        //Debug.LogError(self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_string_list[j].Data.ToStringUtf8());

                        xProperty.SetString(xDataBuff.xPropertyList.PropertyStringList[j].Data.ToStringUtf8());
                    }

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyObjectList.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyObjectList[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_OBJECT);
                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        xProperty.SetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyObjectList[j].Data));
                    }

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector2List.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyVector2List[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR2);

                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        xProperty.SetVector2(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector2List[j].Data));
                    }

                    for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector3List.Count; j++)
                    {
                        string      strPropertyName = xDataBuff.xPropertyList.PropertyVector3List[j].PropertyName.ToStringUtf8();
                        NFIProperty xProperty       = xPropertyManager.GetProperty(strPropertyName);
                        if (null == xProperty)
                        {
                            NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR3);

                            xProperty = xPropertyManager.AddProperty(strPropertyName, var);
                        }

                        xProperty.SetVector3(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector3List[j].Data));
                    }


                    xDataBuff.xPropertyList = null;
                }
            }
        }
示例#8
0
 public abstract void RegisterClassCallBack(string strClassName, NFIObject.ClassEventHandler handler);
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject go = mKernelModule.GetObject(self);

            if (go == null)
            {
                Debug.LogError("error id" + self);
                return;
            }

            NFIRecordManager xRecordManager = go.GetRecordManager();

            Hashtable recordVecDesc = new Hashtable();
            Hashtable recordVecData = new Hashtable();

            for (int k = 0; k < xAddStruct.RecordIntList.Count; ++k)
            {
                NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.RecordIntList[k];

                if (addIntStruct.Col >= 0)
                {
                    recordVecDesc[addIntStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_INT;
                    recordVecData[addIntStruct.Col] = addIntStruct.Data;
                }
            }

            for (int k = 0; k < xAddStruct.RecordFloatList.Count; ++k)
            {
                NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.RecordFloatList[k];

                if (addFloatStruct.Col >= 0)
                {
                    recordVecDesc[addFloatStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_FLOAT;
                    recordVecData[addFloatStruct.Col] = addFloatStruct.Data;
                }
            }

            for (int k = 0; k < xAddStruct.RecordStringList.Count; ++k)
            {
                NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.RecordStringList[k];

                if (addStringStruct.Col >= 0)
                {
                    recordVecDesc[addStringStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_STRING;
                    if (addStringStruct.Data != null)
                    {
                        recordVecData[addStringStruct.Col] = addStringStruct.Data.ToStringUtf8();
                    }
                    else
                    {
                        recordVecData[addStringStruct.Col] = "";
                    }
                }
            }

            for (int k = 0; k < xAddStruct.RecordObjectList.Count; ++k)
            {
                NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.RecordObjectList[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.RecordVector2List.Count; ++k)
            {
                NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.RecordVector2List[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.RecordVector3List.Count; ++k)
            {
                NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.RecordVector3List[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)
            {
                Debug.Log("Empty record:" + strRecordName);
                string    strClassName  = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                NFIClass  xLogicClass   = mClassModule.GetElement(strClassName);
                NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName);
                if (xStaticRecord != null)
                {
                    xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData());
                }
            }

            if (null != xRecord)
            {
                if (self.IsNull())
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    for (int i = 0; i < varListData.Count(); ++i)
                    {
                        stringBuilder.Append(varListData.GetData(i).ToString());
                        stringBuilder.Append(";");
                    }

                    Debug.Log(strRecordName + " add row:" + stringBuilder.ToString());
                }

                xRecord.AddRow(xAddStruct.Row, varListData);
            }
        }
示例#10
0
        public void MainU3D()
        {
            Debug.Log("****************NFDataList******************");

            NFDataList var = new NFDataList();

            for (int i = 0; i < 9; i += 3)
            {
                var.AddInt(i);
                var.AddFloat((float)i + 1);
                var.AddString((i + 2).ToString());
            }

            for (int i = 0; i < 9; i += 3)
            {
                Int64  n   = var.IntVal(i);
                double f   = var.FloatVal(i + 1);
                string str = var.StringVal(i + 2);
                Debug.Log(n);
                Debug.Log(f);
                Debug.Log(str);
            }


            Debug.Log("***************NFProperty*******************");

            NFGUID    ident      = new NFGUID(0, 1);
            NFIObject gameObject = xKernel.CreateObject(ident, 0, 0, "", "", new NFDataList());

            NFDataList valueProperty = new NFDataList();

            valueProperty.AddInt(112221);
            gameObject.GetPropertyManager().AddProperty("111", valueProperty);
            Debug.Log(gameObject.QueryPropertyInt("111"));

            Debug.Log("***************NFRecord*******************");

            NFDataList valueRecord = new NFDataList();

            valueRecord.AddInt(0);
            valueRecord.AddFloat(0);
            valueRecord.AddString("");
            valueRecord.AddObject(ident);

            gameObject.GetRecordManager().AddRecord("testRecord", 10, valueRecord);

            xKernel.SetRecordInt(ident, "testRecord", 0, 0, 112221);
            xKernel.SetRecordFloat(ident, "testRecord", 0, 1, 1122210.0f);
            xKernel.SetRecordString(ident, "testRecord", 0, 2, ";;;;;;112221");
            xKernel.SetRecordObject(ident, "testRecord", 0, 3, ident);

            Debug.Log(gameObject.QueryRecordInt("testRecord", 0, 0));
            Debug.Log(gameObject.QueryRecordFloat("testRecord", 0, 1));
            Debug.Log(gameObject.QueryRecordString("testRecord", 0, 2));
            Debug.Log(gameObject.QueryRecordObject("testRecord", 0, 3));

            Debug.Log(" ");
            Debug.Log("***************PropertyNFEvent*******************");

            //挂属性回调,挂表回调
            xKernel.RegisterPropertyCallback(ident, "111", OnPropertydHandler);
            xKernel.SetPropertyInt(ident, "111", 2456);

            Debug.Log(" ");
            Debug.Log("***************RecordNFEvent*******************");

            xKernel.RegisterRecordCallback(ident, "testRecord", OnRecordEventHandler);
            xKernel.SetRecordInt(ident, "testRecord", 0, 0, 1111111);

            Debug.Log(" ");
            Debug.Log("***************ClassNFEvent*******************");

            xKernel.RegisterClassCallBack("CLASSAAAAA", OnClassHandler);
            xKernel.CreateObject(new NFGUID(0, 2), 0, 0, "CLASSAAAAA", "CONFIGINDEX", new NFDataList());
            xKernel.DestroyObject(new NFGUID(0, 2));


            Debug.Log(" ");
            Debug.Log("***************NFHeartBeat*******************");
            xKernel.AddHeartBeat(new NFGUID(0, 1), "TestHeartBeat", HeartBeatEventHandler, 5.0f, 1);
        }