Ejemplo n.º 1
0
 public HumanoidEquipmentModule(Weapon[] weapons,
                                WeaponProp[] props,
                                MovingAgent.CharacterMainStates state,
                                GameObject target,
                                Recoil recoil,
                                HumanoidAnimationModule animSystem,
                                AgentParameters parameters)
 {
     m_currentState    = state;
     m_target          = target;
     m_recoil          = recoil;
     m_animationSystem = animSystem;
     getAllWeapons(weapons, props);
     m_agentParameters = parameters;
 }
        public void UpdateAnimationState(MovingAgent.CharacterMainStates state)
        {
            switch (state)
            {
            case MovingAgent.CharacterMainStates.Aimed:
                m_aimIK.solver.IKPositionWeight = Mathf.Lerp(m_aimIK.solver.IKPositionWeight, 1, Time.deltaTime * m_aimSpeed / 2);
                break;

            case MovingAgent.CharacterMainStates.Armed_not_Aimed:
                m_aimIK.solver.IKPositionWeight = Mathf.Lerp(m_aimIK.solver.IKPositionWeight, 0, Time.deltaTime * m_aimSpeed);
                break;

            case MovingAgent.CharacterMainStates.Idle:
                m_aimIK.solver.IKPositionWeight = Mathf.Lerp(m_aimIK.solver.IKPositionWeight, 0, Time.deltaTime * m_aimSpeed);
                break;
            }
        }
Ejemplo n.º 3
0
        public void UpdateSystem(MovingAgent.CharacterMainStates state)
        {
            if (m_currentWeapon != null)
            {
                m_currentWeapon.updateWeapon();
            }


            // On Character state change.
            switch (state)
            {
            case MovingAgent.CharacterMainStates.Aimed:

                // Set Gun Aimed;
                if (!m_currentState.Equals(MovingAgent.CharacterMainStates.Aimed))
                {
                    aimCurrentEquipment(true);
                }

                break;

            case MovingAgent.CharacterMainStates.Armed_not_Aimed:

                // Set Gun Aimed;
                if (!m_currentState.Equals(MovingAgent.CharacterMainStates.Armed_not_Aimed))
                {
                    aimCurrentEquipment(false);
                }
                break;

            case MovingAgent.CharacterMainStates.Idle:
                if (!m_currentState.Equals(MovingAgent.CharacterMainStates.Idle))
                {
                    aimCurrentEquipment(false);
                }
                break;
            }


            m_currentState = state;
        }
        public override void UpdateMovment(int characterState, Vector3 movmentDirection)
        {
            m_characterState = (MovingAgent.CharacterMainStates)characterState;

            float crouchSpeedMultiplayer = 1;

            if (this.isCrouched())
            {
                crouchSpeedMultiplayer = 0.3f;
                movmentDirection       = movmentDirection.normalized;
            }

            switch (m_characterState)
            {
            case MovingAgent.CharacterMainStates.Aimed:

                //Turn player
                float angle = Vector3.Angle(getTargetDirection(), this.m_characterTransform.forward);

                if (movmentDirection.magnitude < 0.1)
                {
                    if (Mathf.Abs(angle) > 90)
                    {
                        m_characterTransform.LookAt(getTurnPoint(), Vector3.up);
                    }
                }
                else
                {
                    m_characterTransform.LookAt(getTurnPoint(), Vector3.up);
                }

                // Move Character animator
                Vector3 selfTransfrommoveDiection = this.m_characterTransform.InverseTransformDirection(movmentDirection);
                m_animationSystem.setMovment(selfTransfrommoveDiection.z, selfTransfrommoveDiection.x);

                if (m_enableTranslateMovment)
                {
                    // Move character transfrom
                    Vector3 translateDirection = new Vector3(selfTransfrommoveDiection.x, 0, selfTransfrommoveDiection.z);
                    this.m_characterTransform.Translate(translateDirection.normalized * crouchSpeedMultiplayer / 50);
                }


                //Vector3 translateDirection = new Vector3(movmentDirection.x, 0, movmentDirection.z);

                //if (m_characterController.enabled)
                //{
                //    m_characterController.Move(translateDirection.normalized / 15);
                //}
                break;

            case MovingAgent.CharacterMainStates.Armed_not_Aimed:
            case MovingAgent.CharacterMainStates.Idle:

                //Move character and turn
                if (movmentDirection.magnitude > 0)
                {
                    Vector3 moveDirection = new Vector3(movmentDirection.x, 0, movmentDirection.z);
                    m_characterTransform.rotation = Quaternion.Lerp(m_characterTransform.rotation, Quaternion.LookRotation(moveDirection, Vector3.up), 50f * Time.deltaTime);
                }

                m_animationSystem.setMovment(movmentDirection.magnitude, 0);

                float divider = 1;
                if (m_characterState.Equals(MovingAgent.CharacterMainStates.Idle))
                {
                    divider = 20;
                }
                else
                {
                    divider = 15;
                }

                if (m_enableTranslateMovment)
                {
                    this.m_characterTransform.Translate(Vector3.forward * movmentDirection.magnitude * crouchSpeedMultiplayer / divider);
                }
                break;
            }
        }
 public HumanoidMovmentModule(Transform transfrom, MovingAgent.CharacterMainStates characterState, GameObject target, HumanoidAnimationModule animationSystem) : base(target, transfrom)
 {
     m_characterState  = characterState;
     m_animationSystem = animationSystem;
 }