Example #1
0
    private void OnClassPlayerEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
    {
        if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE)
        {
            Debug.Log("OBJECT_CREATE:" + self.ToString());
            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");

            // MainPlayer
            string strPrefabPath = "Player/AIThirdPersonController";
            if (self == NFCPlayerLogic.Instance().mRoleID)
            {
                strPrefabPath = "Player/ThirdPersonController";
            }
            //if (strConfigID.Length <= 0)
            //{
            //    strPrefabPath = NFCElementModule.Instance().QueryPropertyString("Player", "Prefab");
            //}
            //else
            //{
            //    strPrefabPath = NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strConfigID, "Prefab");
            //}

            //CreateObject(self, strPrefabPath, vec, strClassName);

            GameObject perfb  = Resources.Load <GameObject>(strPrefabPath);
            GameObject player = GameObject.Instantiate(perfb);
            player.name = self.ToString();
            player.transform.SetParent(transform);
            player.transform.position = vec;

            // MainPlayer
            if (self == NFCPlayerLogic.Instance().mRoleID)
            {
                player.AddComponent <MainPlayer>();
            }
            else
            {
                var other = player.AddComponent <OtherPlayer>();
                other.MoveTo(vec);
            }
        }
        else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY)
        {
            DestroyObject(transform.Find(self.ToString()));
        }
    }
Example #2
0
    public bool OnPlayerMove(NFIDataList valueList)
    {
        NFGUID tar = valueList.ObjectVal(0);


        if (tar == NFCPlayerLogic.Instance().mRoleID)
        {
            return(true);
        }

        OtherPlayer player = transform.Find(tar.ToString()).GetComponent <OtherPlayer>();

        double    fSpeed = valueList.FloatVal(1);
        NFVector3 pos    = valueList.Vector3Val(2);

        player.MoveTo(new Vector3(pos.X(), pos.Y(), pos.Z()));

        return(true);
    }
Example #3
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();
                    }
                }
            }
        }
    }
Example #4
0
    private void OnHeroChangeHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar)
    {
        Vector3 vec = new Vector3();

        vec = GetRenderObjectPosition(self);

        DestroyObject(self);

        if (vec.Equals(Vector3.zero))
        {
            NFVector3 vec3 = NFCKernelModule.Instance.QueryPropertyVector3(self, NPC.Position);
            vec.x = vec3.X();
            vec.y = vec3.Y();
            vec.z = vec3.Z();
        }

        string strPrefabPath = "";

        NFGUID    xHeroID = NFCKernelModule.Instance.QueryPropertyObject(self, NFrame.Player.FightHero);
        NFIRecord xRecord = NFCKernelModule.Instance.FindRecord(self, NFrame.Player.PlayerHero.ThisName);
        int       nRow    = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, xHeroID);

        if (nRow >= 0)
        {
            String strCnfID = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID);
            strPrefabPath = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strCnfID, NPC.Prefab);
        }

        GameObject xPlayer = CreateObject(self, strPrefabPath, vec, NFrame.Player.ThisName);

        xPlayer.name = NFrame.Player.ThisName;
        xPlayer.transform.Rotate(new Vector3(0, 90, 0));

        if (self == NFNetController.Instance.xMainRoleID)
        {
            InitPlayerComponent(self, xPlayer, true);
        }
        else
        {
            InitPlayerComponent(self, xPlayer, false);
        }

        Debug.Log("Create Object " + NFrame.Player.ThisName + " " + vec.ToString() + " " + self.ToString());
    }
Example #5
0
 public void SetObjectID(NFGUID xID)
 {
     mxID     = xID;
     ObjectID = mxID.ToString();
 }