Exemplo n.º 1
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;
                 *  }
                 * }
                 */
            }
        }
Exemplo n.º 2
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;
                }
            }
        }