void OnGMGUI(int nHeight, int nWidth) { if (buttonLeft == null) { buttonLeft = GUI.skin.button; buttonLeft.alignment = TextAnchor.MiddleLeft; } int nElementWidth = 300; int nElementHeight = 20; GUI.color = Color.red; strInfo = GUI.TextField(new Rect(0, nHeight - 20, nElementWidth, 20), strInfo); strCommand = GUI.TextField(new Rect(nElementWidth, nHeight - 20, 350, 20), strCommand); if (GUI.Button(new Rect(nElementWidth + 350, nHeight - 20, 100, 20), "cmd")) { } GUI.color = Color.white; NFDataList objectList = mKernelModule.GetObjectList(); scrollPositionFirst = GUI.BeginScrollView(new Rect(0, nElementHeight, nElementWidth / 2 + 20, nHeight - 100), scrollPositionFirst, new Rect(0, 0, nElementWidth, objectList.Count() * (nElementHeight))); //all object for (int i = 0; i < objectList.Count(); i++) { NFGUID ident = objectList.ObjectVal(i); if (GUI.Button(new Rect(0, i * nElementHeight, nElementWidth, nElementHeight), ident.nHead64.ToString() + "_" + ident.nData64.ToString())) { xTargetIdent = ident; strTableName = ""; strInfo = ident.ToString(); } } GUI.EndScrollView(); //////////////// if (!xTargetIdent.IsNull()) { NFIObject go = mKernelModule.GetObject(xTargetIdent); if (null != go) { NFDataList recordLlist = go.GetRecordManager().GetRecordList(); NFDataList propertyList = go.GetPropertyManager().GetPropertyList(); int nAllElement = 1; for (int j = 0; j < recordLlist.Count(); j++) { string strRecordName = recordLlist.StringVal(j); if (strRecordName.Length > 0) { nAllElement++; } } for (int j = 0; j < propertyList.Count(); j++) { string strPropertyName = propertyList.StringVal(j); if (strPropertyName.Length > 0) { nAllElement++; } } ////////////////// scrollPositionSecond = GUI.BeginScrollView(new Rect(nElementWidth / 2 + 25, nElementHeight, nElementWidth / 2 + 25, nHeight - 100), scrollPositionSecond, new Rect(0, 0, nElementWidth, (nAllElement + 1) * (nElementHeight) + 1)); int nElementIndex = 0; GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), xTargetIdent.ToString()); nElementIndex++; //all record List <string> xRecordList = new List <string>(); for (int j = 0; j < recordLlist.Count(); j++) { xRecordList.Add(recordLlist.StringVal(j)); } xRecordList.Sort(); for (int j = 0; j < xRecordList.Count; j++) { string strRecordName = xRecordList[j]; if (strRecordName.Length > 0) { if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), "++" + strRecordName)) { strTableName = strRecordName; } nElementIndex++; } } /////////////////////////////// //all property List <string> xPropertyList = new List <string>(); for (int k = 0; k < propertyList.Count(); k++) { xPropertyList.Add(propertyList.StringVal(k)); } xPropertyList.Sort(); for (int k = 0; k < xPropertyList.Count; k++) { string strPropertyValue = null; string strPropertyName = xPropertyList[k]; NFIProperty property = go.GetPropertyManager().GetProperty(strPropertyName); NFDataList.VARIANT_TYPE eType = property.GetType(); switch (eType) { case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: strPropertyValue = property.QueryFloat().ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_INT: strPropertyValue = property.QueryInt().ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: strPropertyValue = property.QueryObject().ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: strPropertyValue = property.QueryString(); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: strPropertyValue = property.QueryVector2().ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: strPropertyValue = property.QueryVector3().ToString(); break; default: strPropertyValue = "?"; break; } if (strPropertyName.Length > 0) { if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), strPropertyName + ":" + strPropertyValue)) { strTableName = ""; strInfo = strPropertyName + ":" + strPropertyValue; } nElementIndex++; } } GUI.EndScrollView(); //////////////////////// if (strTableName.Length > 0) { NFIRecord record = go.GetRecordManager().GetRecord(strTableName); if (null != record) { int nRow = record.GetRows(); int nCol = record.GetCols(); int nOffest = 30; scrollPositionThird = GUI.BeginScrollView(new Rect(nElementWidth + 50, nElementHeight, nElementWidth * 3, nHeight / 2), scrollPositionThird, new Rect(0, 0, nElementWidth * nCol + nOffest, nRow * nElementHeight + nOffest)); string selString = null; for (int row = 0; row < nRow; row++) { GUI.Button(new Rect(0, row * nElementHeight + nOffest, nOffest, nElementHeight), row.ToString());//row for (int col = 0; col < nCol; col++) { if (0 == row) { GUI.Button(new Rect(col * nElementWidth + nOffest, 0, nElementWidth, nElementHeight), col.ToString() + " [" + record.GetColType(col) + "]" + record.GetColTag(col)); } if (record.IsUsed(row)) { NFDataList.VARIANT_TYPE eType = record.GetColType(col); switch (eType) { case NFDataList.VARIANT_TYPE.VTYPE_INT: selString = record.QueryInt(row, col).ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: selString = record.QueryFloat(row, col).ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: selString = record.QueryString(row, col); break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: selString = record.QueryObject(row, col).ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: selString = record.QueryObject(row, col).ToString(); break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: selString = record.QueryObject(row, col).ToString(); break; default: selString = "UnKnowType"; break; } } else { selString = "NoUse"; } if (GUI.Button(new Rect(col * nElementWidth + nOffest, row * nElementHeight + nOffest, nElementWidth, nElementHeight), selString)) { strInfo = "Row:" + row.ToString() + " Col:" + col.ToString() + " " + selString; } } } GUI.EndScrollView(); } } } } }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = NFCKernelModule.Instance.GetObject(self); 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] = NFIDataList.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] = NFIDataList.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] = NFIDataList.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] = NFIDataList.VARIANT_TYPE.VTYPE_OBJECT; recordVecData[addObjectStruct.col] = PBToNF(addObjectStruct.data); } } NFIDataList varListDesc = new NFCDataList(); NFIDataList varListData = new NFCDataList(); for (int m = 0; m < recordVecDesc.Count; m++) { if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m)) { NFIDataList.VARIANT_TYPE nType = (NFIDataList.VARIANT_TYPE)recordVecDesc[m]; switch (nType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { varListDesc.AddInt(0); varListData.AddInt((Int64)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { varListDesc.AddFloat(0.0f); varListData.AddFloat((float)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { varListDesc.AddString(""); varListData.AddString((string)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { varListDesc.AddObject(new NFGUID()); varListData.AddObject((NFGUID)recordVecData[m]); } break; default: break; } } else { //报错 //Debug.LogException(i); } } NFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc); } xRecord.AddRow(xAddStruct.row, varListData); }
private void EGMI_ACK_OBJECT_PROPERTY_ENTRY(MsgHead head, 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)); } } }
//////////////////////////////////////////////////////////// void OnOpratorGUI(int nHeight, int nWidth) { ////////////////////////////////// if (null != mxClient && mxClient.IsConnected() && mPlayerState == PLAYER_STATE.E_PLAYER_GAMEING) { ////聊天 scrollVecChatMsg = GUI.BeginScrollView(new Rect(0, nHeight / 2 + 20, 150 * 1.5f + 40, nHeight / 2 - 40), scrollVecChatMsg, new Rect(0, 0, 1500, 3000)); int nChatIndex = 0; for (int i = mxListener.aChatMsgList.Count - 1; i >= 0; i--) { string strData = (string)mxListener.aChatMsgList[i]; GUI.Label(new Rect(0, nChatIndex * 20, 2000, 20), strData); nChatIndex++; } GUI.EndScrollView(); ////网络消息 scrollVecMsg = GUI.BeginScrollView(new Rect(150 * 1.5f + 40, nHeight / 2 + 20, 150 * 2, nHeight / 2 - 40), scrollVecMsg, new Rect(0, 0, 1500, 3000)); int nNetIndex = 0; for (int i = mxListener.aMsgList.Count - 1; i >= 0; i--) { string strData = (string)mxListener.aMsgList[i]; GUI.Label(new Rect(0, nNetIndex * 20, 2000, 20), strData); nNetIndex++; } GUI.EndScrollView(); //操作功能区 scrollVecBtn = GUI.BeginScrollView(new Rect(570, 20, 350, nHeight - 40), scrollVecBtn, new Rect(0, 0, 600, 3000)); //////////////////////////////////////////////////////////////////////////////////////////////// if (GUI.Button(new Rect(0, 0, 100, 50), "SwapScene")) { mxSendLogic.RequireSwapScene(nMainRoleID, 0, int.Parse(strReqSwapSceneID), -1); } strReqSwapSceneID = GUI.TextField(new Rect(100, 0, 100, 50), strReqSwapSceneID); //////////////////////////////////////////////////////////////////////////////////////////////// if (GUI.Button(new Rect(0, 50, 100, 50), "Move")) { mxSendLogic.RequireMove(nMainRoleID, float.Parse(strReqMoveX), float.Parse(strReqMoveZ)); } strReqMoveX = GUI.TextField(new Rect(100, 50, 100, 50), strReqMoveX); strReqMoveZ = GUI.TextField(new Rect(200, 50, 100, 50), strReqMoveZ); //////////////////////////////////////////////////////////////////////////////////////////////// /* * * if (GUI.Button(new Rect(0, 100, 100, 50), "接任务")) * { * sendLogic.RequireAcceptTask(strReqAcceptTaskID); * } * strReqAcceptTaskID = GUI.TextField(new Rect(100, 100, 100, 50), strReqAcceptTaskID); * * //////////////////////////////////////////////////////////////////////////////////////////////// * * if (GUI.Button(new Rect(0, 150, 100, 50), "交任务")) * { * sendLogic.RequireCompeleteTask(nSelfID, strReqAcceptTaskID); * } * strReqAcceptTaskID = GUI.TextField(new Rect(100, 150, 100, 50), strReqAcceptTaskID); * * //////////////////////////////////////////////////////////////////////////////////////////////// * * if (GUI.Button(new Rect(0, 200, 100, 50), "杀怪")) * { * sendLogic.RequireUseSkill("", long.Parse(strReqKillNPCID)); * } * strReqKillNPCID = GUI.TextField(new Rect(100, 200, 100, 50), strReqKillNPCID); * * //////////////////////////////////////////////////////////////////////////////////////////////// * if (GUI.Button(new Rect(0, 250, 100, 50), "使用道具")) * { * sendLogic.RequireUseItem(long.Parse(strReqUseItemID), nSelfID); * } * strReqUseItemID = GUI.TextField(new Rect(100, 250, 100, 50), strReqUseItemID); * * //////////////////////////////////////////////////////////////////////////////////////////////// * * if (GUI.Button(new Rect(0, 300, 100, 50), "拾取")) * { * sendLogic.RequirePickUpItem(long.Parse(strPickUpItemID)); * } * strPickUpItemID = GUI.TextField(new Rect(100, 300, 100, 50), strPickUpItemID); * * //////////////////////////////////////////////////////////////////////////////////////////////// */ // if (GUI.Button(new Rect(0, 350, 100, 50), "Set Property")) // { // //mxSendLogic.RequireProperty(nMainRoleID, strReqSetProperty, int.Parse(strReqPropertyValue)); // } // strReqSetProperty = GUI.TextField(new Rect(100, 350, 100, 50), strReqSetProperty); // strReqPropertyValue = GUI.TextField(new Rect(200, 350, 100, 50), strReqPropertyValue); //////////////////////////////////////////////////////////////////////////////////////////////// /* * if (GUI.Button(new Rect(0, 400, 100, 50), "添加道具")) * { * sendLogic.RequireItem(strReqAddItem, int.Parse(strAddCount)); * } * strReqAddItem = GUI.TextField(new Rect(100, 400, 100, 50), strReqAddItem); * strAddCount = GUI.TextField(new Rect(200, 400, 100, 50), strAddCount); */ //////////////////////////////////////////////////////////////////////////////////////////////// if (GUI.Button(new Rect(0, 450, 100, 50), "Chat")) { mxSendLogic.RequireChat(nMainRoleID, new NFrame.NFGUID(), 3, strChatData); //test if (false) { int value = int.Parse(strChatData); NFIObject obj = NFCKernelModule.Instance.GetObject(nMainRoleID); NFIPropertyManager propertyManager = obj.GetPropertyManager(); NFIProperty property = propertyManager.GetProperty("Gold"); property.SetInt(value); } } strChatTargetID = nTarget.ToString(); // strChatTargetID = GUI.TextField(new Rect(100, 450, 100, 50), strChatTargetID); // strType = GUI.TextField(new Rect(200, 450, 100, 50), strType); strChatData = GUI.TextField(new Rect(100, 450, 100, 50), strChatData); GUI.EndScrollView(); } }