Exemplo n.º 1
0
    public bool DoCmd(string strArg, string strGMID)
    {
        NFMsg.EGameMsgID xMsgID = (NFMsg.EGameMsgID)Enum.Parse(typeof(NFMsg.EGameMsgID), strGMID);
        if (!mxGM.ContainsKey(xMsgID))
        {
            Debug.LogWarning("GMID Error");
            return(false);
        }

        string strOriginArg = (string)mxGM[xMsgID];

        NFDataList xOriginArgList = new NFDataList(strOriginArg, ',');
        NFDataList xNowArgList    = new NFDataList(strArg, ',');

        if (xOriginArgList.Count() != xNowArgList.Count())
        {
            Debug.LogWarning("Arg Count Error");
            return(false);
        }

        NFDataList xNowDataList = new NFDataList();

        for (int i = 0; i < xOriginArgList.Count(); ++i)
        {
            string strOriginType = xOriginArgList.StringVal(i);
            switch (strOriginType)
            {
            case "VTYPE_INT":
            {
                string strNowDataInt = xNowArgList.StringVal(i);
                int    nData         = 0;
                if (!int.TryParse(strNowDataInt, out nData))
                {
                    Debug.LogWarning("Arg:" + i + " Can not parse to int:" + strNowDataInt);
                    return(false);
                }

                xNowDataList.AddInt(nData);
            }
            break;

            case "VTYPE_FLOAT":
            {
                string strNowDataFloat = xNowArgList.StringVal(i);
                float  fData           = 0;
                if (!float.TryParse(strNowDataFloat, out fData))
                {
                    Debug.LogWarning("Arg:" + i + " Can not parse to float:" + strNowDataFloat);
                    return(false);
                }

                xNowDataList.AddFloat(fData);
            }
            break;

            case "VTYPE_STRING":
            {
                string strNowData = xNowArgList.StringVal(i);
                xNowDataList.AddString(strNowData);
            }
            break;

            case "VTYPE_OBJECT":
            {
                string strNowDataObject = xNowArgList.StringVal(i);
                NFGUID xIdent           = new NFGUID();
                if (!xIdent.Parse(strNowDataObject))
                {
                    Debug.LogWarning("Arg:" + i + " Can not parse to Object:" + strNowDataObject);
                    return(false);
                }

                xNowDataList.AddObject(xIdent);
            }
            break;

            default:
                break;
            }
            //NFDataList.VARIANT_TYPE
        }

        switch (xMsgID)
        {
        case NFMsg.EGameMsgID.EGMI_REQ_SWAP_SCENE:
        {
            //NFNetController.Instance.mxNetSender.RequireSwapScene(NFNetController.Instance.xMainRoleID, (int)xNowDataList.IntVal(0), (int)xNowDataList.IntVal(1), (int)xNowDataList.IntVal(3), 0f, 0f, 0f);
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_PROPERTY_INT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMPropertyInt(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.IntVal(1));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_PROPERTY_FLOAT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMPropertyFloat(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.FloatVal(1));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_PROPERTY_STR:
        {
            //NFNetController.Instance.mxNetSender.RequireGMPropertyStr(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.StringVal(1));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_PROPERTY_OBJECT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMPropertyObject(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.ObjectVal(1));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_RECORD_INT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMRecordInt(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.IntVal(1), xNowDataList.IntVal(2), xNowDataList.IntVal(3));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_RECORD_FLOAT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMRecordFloat(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.IntVal(1), xNowDataList.IntVal(2), xNowDataList.FloatVal(3));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_RECORD_STR:
        {
            //NFNetController.Instance.mxNetSender.RequireGMRecordStr(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.IntVal(1), xNowDataList.IntVal(2), xNowDataList.StringVal(3));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_RECORD_OBJECT:
        {
            //NFNetController.Instance.mxNetSender.RequireGMRecordObject(NFNetController.Instance.xMainRoleID, xNowDataList.StringVal(0), xNowDataList.IntVal(1), xNowDataList.IntVal(2), xNowDataList.ObjectVal(3));
        }
        break;



        case NFMsg.EGameMsgID.EGMI_REQ_PICK_ITEM:
        {
            //NFNetController.Instance.mxNetSender.RequirePickUpItem(NFNetController.Instance.xMainRoleID, xNowDataList.ObjectVal(0));
        }
        break;

        case NFMsg.EGameMsgID.EGMI_REQ_CMD_NORMAL:
        {
            //NFNetController.Instance.mxNetSender.RequireNormalGM(NFNetController.Instance.xMainRoleID, (NFMsg.ReqCommand.EGameCommandType)xNowDataList.IntVal(0)
            //    , xNowDataList.StringVal(1), xNowDataList.StringVal(2), xNowDataList.IntVal(3), xNowDataList.FloatVal(4), xNowDataList.ObjectVal(5));
        }
        break;

        default:
            break;
        }

        return(true);
    }
Exemplo n.º 2
0
    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();
                    }
                }
            }
        }
    }