Beispiel #1
0
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject go = mKernelModule.GetObject(self);

            if (go == null)
            {
                return;
            }
            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] = NFDataList.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] = NFDataList.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] = NFDataList.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] = NFDataList.VARIANT_TYPE.VTYPE_OBJECT;
                    recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data);
                }
            }

            for (int k = 0; k < xAddStruct.record_vector2_list.Count; ++k)
            {
                NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.record_vector2_list[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.record_vector3_list.Count; ++k)
            {
                NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.record_vector3_list[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)
            {
                string    strClassName  = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                NFIClass  xLogicClass   = mClassModule.GetElement(strClassName);
                NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName);

                xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData());
            }

            xRecord.AddRow(xAddStruct.row, varListData);
        }
Beispiel #2
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 = mKernelModule.QueryPropertyString(self, NFrame.Player.ConfigID);
                Vector3   vec         = new Vector3();
                NFVector3 vector3     = mKernelModule.QueryPropertyVector3(self, NFrame.Player.Position);
                //vec.x = vector3.X();
                //vec.y = vector3.Y();
                //vec.z = vector3.Z();

                //MainPlayer
                string strPrefabPath = "Player/AIThirdPersonController";
                if (self == mLoginModule.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);

                mGameObjectMap.Add(self, player);

                GameObject.DontDestroyOnLoad(player);

                player.name = self.ToString();
                player.transform.position = vec;

                //MainPlayer
                if (self == mLoginModule.mRoleID)
                {
                    player.AddComponent <MainPlayer>();
                }
                else
                {
                    player.AddComponent <OtherPlayer>();
                }
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY)
            {
                //DestroyObject(transform.Find(self.ToString()));
                GameObject go = GetObject(self);
                if (go != null)
                {
                    mGameObjectMap.Remove(self);

                    GameObject.DestroyObject(go);
                }
            }
        }
Beispiel #3
0
        public void InitPlayerComponent(NFGUID xID, GameObject self, bool bMainRole)
        {
            if (null == self)
            {
                return;
            }

            if (!self.GetComponent <Rigidbody>())
            {
                self.AddComponent <Rigidbody>();
            }

            if (!self.GetComponent <NFHeroSyncBuffer>())
            {
                self.AddComponent <NFHeroSyncBuffer>();
            }

            if (!self.GetComponent <NFHeroSync>())
            {
                self.AddComponent <NFHeroSync>();
            }


            NFHeroInput xInput = self.GetComponent <NFHeroInput>();

            if (!xInput)
            {
                xInput = self.AddComponent <NFHeroInput>();
            }

            if (bMainRole)
            {
                xInput.enabled = true;
                xInput.SetInputEnable(true);
            }
            else
            {
                xInput.enabled = false;
                xInput.SetInputEnable(false);
            }

            if (!self.GetComponent <GroundDetection>())
            {
                GroundDetection groundDetection = self.AddComponent <GroundDetection>();
                groundDetection.enabled    = true;
                groundDetection.groundMask = -1;
            }

            if (!self.GetComponent <CharacterMovement>())
            {
                CharacterMovement characterMovement = self.AddComponent <CharacterMovement>();
                characterMovement.enabled = true;
            }

            if (!self.GetComponent <NFHeroMotor>())
            {
                NFHeroMotor xHeroMotor = self.AddComponent <NFHeroMotor>();
                xHeroMotor.enabled = true;
            }

            if (!self.GetComponent <NFAnimatStateController>())
            {
                NFAnimatStateController xHeroAnima = self.AddComponent <NFAnimatStateController>();
                xHeroAnima.enabled = true;
            }


            if (!self.GetComponent <NFAnimaStateMachine>())
            {
                NFAnimaStateMachine xHeroAnima = self.AddComponent <NFAnimaStateMachine>();
                xHeroAnima.enabled = true;
            }

            if (bMainRole)
            {
                CapsuleCollider xHeroCapsuleCollider = self.GetComponent <CapsuleCollider>();
                xHeroCapsuleCollider.isTrigger = false;
            }
            else
            {
                CapsuleCollider xHeroCapsuleCollider = self.GetComponent <CapsuleCollider>();
                Rigidbody       rigidbody            = self.GetComponent <Rigidbody>();

                string         configID = mKernelModule.QueryPropertyString(xID, NFrame.IObject.ConfigID);
                NFMsg.ENPCType npcType  = (NFMsg.ENPCType)mElementModule.QueryPropertyInt(configID, NFrame.NPC.NPCType);
                //NFMsg.esub npcSubType = (NFMsg.ENPCType)mElementModule.QueryPropertyInt(configID, NFrame.NPC.NPCSubType);
                if (npcType == NFMsg.ENPCType.TurretNpc)
                {
                    //is trigger must false if it is a building
                    // and the kinematic must true
                    xHeroCapsuleCollider.isTrigger = false;
                    //rigidbody.isKinematic = true;
                    //rigidbody.useGravity = true;
                    rigidbody.mass = 10000;
                }
                else
                {
                    xHeroCapsuleCollider.isTrigger = true;
                }

                /*
                 * if (mKernelModule.QueryPropertyObject(xID, NFrame.NPC.MasterID) == mLoginModule.mRoleID)
                 * {
                 *  //your building or your clan member building
                 *  if (!self.GetComponent<FogCharacter>())
                 *  {
                 *      FogCharacter fogCharacter = self.AddComponent<FogCharacter>();
                 *      fogCharacter.enabled = true;
                 *      fogCharacter.radius = 8;
                 *  }
                 * }
                 * else
                 * {
                 *  if (!self.GetComponent<FogAgent>())
                 *  {
                 *      FogAgent fogAgent = self.AddComponent<FogAgent>();
                 *      fogAgent.enabled = true;
                 *  }
                 * }
                 */
            }
        }
Beispiel #4
0
        public void InitPlayerComponent(NFGUID xID, GameObject self, bool bMainRole)
        {
            if (null == self)
            {
                return;
            }

            if (!self.GetComponent <Rigidbody>())
            {
                self.AddComponent <Rigidbody>();
            }

            if (!self.GetComponent <NFHeroSyncBuffer>())
            {
                self.AddComponent <NFHeroSyncBuffer>();
            }

            if (!self.GetComponent <NFHeroSync>())
            {
                self.AddComponent <NFHeroSync>();
            }

            NFHeroInput xInput = self.GetComponent <NFHeroInput>();

            if (!xInput)
            {
                xInput = self.AddComponent <NFHeroInput>();
            }

            if (bMainRole)
            {
                xInput.enabled = true;
                xInput.SetInputEnable(true);
            }
            else
            {
                xInput.enabled = false;
                xInput.SetInputEnable(false);
            }

            if (!self.GetComponent <GroundDetection>())
            {
                GroundDetection groundDetection = self.AddComponent <GroundDetection>();
                groundDetection.enabled    = true;
                groundDetection.groundMask = -1;
            }

            if (!self.GetComponent <CharacterMovement>())
            {
                CharacterMovement characterMovement = self.AddComponent <CharacterMovement>();
                characterMovement.enabled = true;
            }

            if (!self.GetComponent <NFHeroMotor>())
            {
                NFHeroMotor xHeroMotor = self.AddComponent <NFHeroMotor>();
                xHeroMotor.enabled = true;
            }

            if (!self.GetComponent <NFAnimatStateController>())
            {
                NFAnimatStateController xHeroAnima = self.AddComponent <NFAnimatStateController>();
                xHeroAnima.enabled = true;
            }

            if (!self.GetComponent <NFAnimaStateMachine>())
            {
                NFAnimaStateMachine xHeroAnima = self.AddComponent <NFAnimaStateMachine>();
                xHeroAnima.enabled = true;
            }

            if (bMainRole)
            {
                if (Camera.main)
                {
                    NFHeroCameraFollow xHeroCameraFollow = Camera.main.GetComponent <NFHeroCameraFollow>();
                    if (!xHeroCameraFollow)
                    {
                        xHeroCameraFollow = Camera.main.GetComponentInParent <NFHeroCameraFollow>();
                    }

                    xHeroCameraFollow.target = self.transform;
                }


                CapsuleCollider xHeroCapsuleCollider = self.GetComponent <CapsuleCollider>();
                xHeroCapsuleCollider.isTrigger = false;
            }
            else
            {
                CapsuleCollider xHeroCapsuleCollider = self.GetComponent <CapsuleCollider>();
                Rigidbody       rigidbody            = self.GetComponent <Rigidbody>();

                string         configID = mKernelModule.QueryPropertyString(xID, NFrame.IObject.ConfigID);
                NFMsg.ENPCType npcType  = (NFMsg.ENPCType)mElementModule.QueryPropertyInt(configID, NFrame.NPC.NPCType);
                //NFMsg.esub npcSubType = (NFMsg.ENPCType)mElementModule.QueryPropertyInt(configID, NFrame.NPC.NPCSubType);
                if (npcType == NFMsg.ENPCType.TurretNpc)
                {
                    //is trigger must false if it is a building
                    // and the kinematic must true
                    xHeroCapsuleCollider.isTrigger = false;
                    //rigidbody.isKinematic = true;
                    //rigidbody.useGravity = true;
                    rigidbody.mass = 10000;
                }
                else
                {
                    xHeroCapsuleCollider.isTrigger = true;
                }
            }
        }