//public override int FindRow( int nRow ); public override int FindColValue(int nCol, NFDataList var, ref NFDataList varResult) { for (int i = 0; i < mhtRecordVec.Count; i++) { NFDataList valueList = (NFDataList)mhtRecordVec[i]; switch (valueList.GetType(0)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: return(FindInt(nCol, var.IntVal(0), ref varResult)); case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: return(FindInt(nCol, var.IntVal(0), ref varResult)); case NFDataList.VARIANT_TYPE.VTYPE_STRING: return(FindInt(nCol, var.IntVal(0), ref varResult)); case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: return(FindObject(nCol, var.ObjectVal(0), ref varResult)); case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: return(FindVector2(nCol, var.Vector2Val(0), ref varResult)); case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: return(FindVector3(nCol, var.Vector3Val(0), ref varResult)); default: break; } } return(-1); }
public override bool SetInt(int nRow, int nCol, Int64 value) { if (nRow >= 0 && nRow < mnRow) { if (!mhtRecordVec.ContainsKey(nRow)) { AddRow(nRow); } NFDataList valueList = (NFDataList)mhtRecordVec[nRow]; if (valueList.GetType(nCol) == NFDataList.VARIANT_TYPE.VTYPE_INT) { if (valueList.IntVal(nCol) != value) { NFDataList.TData oldValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT); NFDataList.TData newValue = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT); oldValue.Set(valueList.IntVal(nCol)); newValue.Set(value); valueList.SetInt(nCol, value); if (null != doHandleDel) { doHandleDel(mSelf, mstrRecordName, eRecordOptype.Update, nRow, nCol, oldValue, newValue); } } } return(true); } return(false); }
public NFDataList(NFDataList src) { for (int i = 0; i < src.Count(); i++) { switch (src.GetType(i)) { case VARIANT_TYPE.VTYPE_INT: AddInt(src.IntVal(i)); break; case VARIANT_TYPE.VTYPE_FLOAT: AddFloat(src.FloatVal(i)); break; case VARIANT_TYPE.VTYPE_STRING: AddString(src.StringVal(i)); break; case VARIANT_TYPE.VTYPE_OBJECT: AddObject(src.ObjectVal(i)); break; case VARIANT_TYPE.VTYPE_VECTOR2: AddVector2(src.Vector2Val(i)); break; case VARIANT_TYPE.VTYPE_VECTOR3: AddVector3(src.Vector3Val(i)); break; default: break; } } }
public override int FindRecordRow(NFGUID self, string strRecordName, int nCol, NFVector3 nValue) { NFDataList datalist = new NFDataList(); int nCount = FindRecordRow(self, strRecordName, nCol, nValue, ref datalist); if (nCount > 0 && datalist.Count() > 0) { return((int)datalist.IntVal(0)); } return(-1); }
public override Int64 QueryInt(int nRow, int nCol) { NFDataList valueList = QueryRow(nRow); if (null != valueList) { return(valueList.IntVal(nCol)); } return(0); }
public override int FindVector3(int nCol, NFVector3 value) { NFDataList varResult = new NFDataList(); int nCount = FindVector3(nCol, value, ref varResult); if (nCount > 0 && varResult.Count() > 0) { return((int)varResult.IntVal(0)); } return(-1); }
public override int FindInt(int nCol, Int64 value, ref NFDataList varResult) { foreach (int i in mhtRecordVec.Keys) { NFDataList valueList = (NFDataList)mhtRecordVec[i]; if (valueList.IntVal(nCol) == value) { varResult.AddInt(i); } } return(varResult.Count()); }
public NFCProperty(NFGUID self, string strPropertyName, NFDataList varData) { mSelf = self; msPropertyName = strPropertyName; mxData = new NFDataList.TData(varData.GetType(0)); switch (varData.GetType(0)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: mxData.Set(varData.IntVal(0)); break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: mxData.Set(varData.FloatVal(0)); break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: mxData.Set(varData.ObjectVal(0)); break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: mxData.Set(varData.StringVal(0)); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: mxData.Set(varData.Vector2Val(0)); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: mxData.Set(varData.Vector3Val(0)); break; default: break; } }
public void RequireAddRow(NFGUID objectID, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.PlayerId = mHelpModule.NFToPB(objectID); xData.RecordName = ByteString.CopyFromUtf8(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.RowData.Add(xRecordAddRowStruct); xRecordAddRowStruct.Row = nRow; NFIObject xObject = mKernelModule.GetObject(objectID); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFDataList xRowData = xRecord.QueryRow(nRow); for (int i = 0; i < xRowData.Count(); i++) { switch (xRowData.GetType(i)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.Row = nRow; xRecordInt.Col = i; xRecordInt.Data = xRowData.IntVal(i); xRecordAddRowStruct.RecordIntList.Add(xRecordInt); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.Row = nRow; xRecordFloat.Col = i; xRecordFloat.Data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.RecordFloatList.Add(xRecordFloat); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.Row = nRow; xRecordString.Col = i; xRecordString.Data = ByteString.CopyFromUtf8(xRowData.StringVal(i)); xRecordAddRowStruct.RecordStringList.Add(xRecordString); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.Row = nRow; xRecordObject.Col = i; xRecordObject.Data = mHelpModule.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.RecordObjectList.Add(xRecordObject); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.RecordVector2List.Add(xRecordVector); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.RecordVector3List.Add(xRecordVector); } break; } } mxBody.SetLength(0); xData.WriteTo(mxBody); Debug.Log("send upload record addRow"); SendMsg((int)NFMsg.EGameMsgID.AckAddRow, mxBody); }
public void RequireAddRow(NFrame.NFGUID self, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.player_id = NFNetController.NFToPB(self); xData.record_name = System.Text.Encoding.Default.GetBytes(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.row_data.Add(xRecordAddRowStruct); xRecordAddRowStruct.row = nRow; NFIObject xObject = NFCKernelModule.Instance.GetObject(self); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFDataList xRowData = xRecord.QueryRow(nRow); for (int i = 0; i < xRowData.Count(); i++) { switch (xRowData.GetType(i)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.row = nRow; xRecordInt.col = i; xRecordInt.data = xRowData.IntVal(i); xRecordAddRowStruct.record_int_list.Add(xRecordInt); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.row = nRow; xRecordFloat.col = i; xRecordFloat.data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.record_float_list.Add(xRecordFloat); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.row = nRow; xRecordString.col = i; xRecordString.data = System.Text.Encoding.Default.GetBytes(xRowData.StringVal(i)); xRecordAddRowStruct.record_string_list.Add(xRecordString); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.row = nRow; xRecordObject.col = i; xRecordObject.data = NFNetController.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.record_object_list.Add(xRecordObject); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFNetController.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.record_vector2_list.Add(xRecordVector); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFNetController.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.record_vector3_list.Add(xRecordVector); } break; } } mxBody.SetLength(0); mxSerializer.Serialize(mxBody, xData); Debug.Log("send upload record addRow"); SendMsg(self, NFMsg.EGameMsgID.EGMI_ACK_ADD_ROW, mxBody); }
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); }
public static void Main() { NFIKernelModule kernel = NFCKernelModule.Instance; Console.WriteLine("****************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); Console.WriteLine(n); Console.WriteLine(f); Console.WriteLine(str); } Console.WriteLine("***************NFProperty*******************"); NFGUID ident = new NFGUID(0, 1); NFIObject gameObject = kernel.CreateObject(ident, 0, 0, "", "", new NFDataList()); NFDataList valueProperty = new NFDataList(); valueProperty.AddInt(112221); gameObject.GetPropertyManager().AddProperty("111", valueProperty); Console.WriteLine(gameObject.QueryPropertyInt("111")); Console.WriteLine("***************NFRecord*******************"); NFDataList valueRecord = new NFDataList(); valueRecord.AddInt(0); valueRecord.AddFloat(0); valueRecord.AddString(""); valueRecord.AddObject(ident); gameObject.GetRecordManager().AddRecord("testRecord", 10, valueRecord); kernel.SetRecordInt(ident, "testRecord", 0, 0, 112221); kernel.SetRecordFloat(ident, "testRecord", 0, 1, 1122210.0f); kernel.SetRecordString(ident, "testRecord", 0, 2, ";;;;;;112221"); kernel.SetRecordObject(ident, "testRecord", 0, 3, ident); Console.WriteLine(gameObject.QueryRecordInt("testRecord", 0, 0)); Console.WriteLine(gameObject.QueryRecordFloat("testRecord", 0, 1)); Console.WriteLine(gameObject.QueryRecordString("testRecord", 0, 2)); Console.WriteLine(gameObject.QueryRecordObject("testRecord", 0, 3)); Console.WriteLine(" "); Console.WriteLine("***************PropertyNFEvent*******************"); //挂属性回调,挂表回调 kernel.RegisterPropertyCallback(ident, "111", OnPropertydHandler); kernel.SetPropertyInt(ident, "111", 2456); Console.WriteLine(" "); Console.WriteLine("***************RecordNFEvent*******************"); kernel.RegisterRecordCallback(ident, "testRecord", OnRecordEventHandler); kernel.SetRecordInt(ident, "testRecord", 0, 0, 1111111); Console.WriteLine(" "); Console.WriteLine("***************ClassNFEvent*******************"); kernel.RegisterClassCallBack("CLASSAAAAA", OnClassHandler); kernel.CreateObject(new NFGUID(0, 2), 0, 0, "CLASSAAAAA", "CONFIGINDEX", new NFDataList()); kernel.DestroyObject(new NFGUID(0, 2)); Console.WriteLine(" "); Console.WriteLine("***************NFHeartBeat*******************"); kernel.AddHeartBeat(new NFGUID(0, 1), "TestHeartBeat", HeartBeatEventHandler, 5.0f, 1); while (true) { System.Threading.Thread.Sleep(1000); kernel.Execute(1.0f); } }
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); }