Exemplo n.º 1
0
        /// <summary>
        /// end trigger animations
        /// </summary>
        /// <param name="character">character interacting with trigger</param>
        /// <param name="limbsIK">ik helper</param>
        public override void end(TPCharacter character, IKHelper limbsIK)
        {
            if (!character)
            {
#if DEBUG_INFO
                Debug.LogError("object cannot be null!" + " < " + this.ToString() + ">");
#endif
                return;
            }
            if (!Target)
            {
#if DEBUG_INFO
                Debug.LogWarning("trigger target not assigned!" + " < " + this.ToString() + ">");
#endif
                return;
            }


            character.triggerRootMotion = false;
            character.disableMove       = false;
            character.setMoveMode(TPCharacter.MovingMode.Ledge);

            OrbitCameraController oc = character.GetComponentInChildren <OrbitCameraController>();
            if (oc)
            {
                oc.additiveRotation = true;
            }

            character.disableCapsuleScale = true;
            character.animator.SetBool(/*"pGrabLedgeUp"*/ HashIDs.GrabLedgeUpBool, false);
            character.animator.SetBool(/*"pOnLedge"*/ HashIDs.OnLedgeBool, true);
            character.animatorDampTime       = 0.0f;
            character.ledgeMove              = true;
            character.disableLedgeConstraint = false;
            character.fullStop();
            character.jumpAllowed = true;

            if (limbsIK)
            {
                limbsIK.RHandIKEnabled = true;
                limbsIK.LFootIKEnabled = true;
                limbsIK.RFootIKEnabled = true;
                limbsIK.LHandIKEnabled = true;
                limbsIK.LFWeightTime   = 0.0f;
                limbsIK.RFWeightTime   = 0.0f;

                limbsIK.startLedgeAdjust(m_TriggerInfo.targetRotation);
                limbsIK.checkHang = true;
            }
            if (character.animator.GetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool))
            {
                character.restoreCapsuleSize();
            }
            else
            {
                character.scaleCapsuleToHalf();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// break from trigger matching target
        /// </summary>
        public void breakTrigger()
        {
#if DEBUG_INFO
            if (!m_initialized)
            {
                Debug.LogError("Component not initialized! " + " < " + this.ToString() + ">");
                return;
            }
#endif

            if (!enabled)
            {
                return;
            }
            m_Character.animator.InterruptMatchTarget();
            if (m_CurrentActiveTrigger)
            {
                m_CurrentActiveTrigger.end(m_Character, m_IKHelper);
            }

            m_Character.animator.SetBool(/*"pOnLedge"*/ HashIDs.OnLedgeBool, false);
            m_Character.animator.SetBool(/*"pGrabLedgeUp"*/ HashIDs.GrabLedgeUpBool, false);
            m_Character.animator.SetBool(/*"pGrabLedgeDown"*/ HashIDs.GrabLedgeDownBool, false);
            m_Character.animator.SetBool(/*"pGrabLedgeLeft"*/ HashIDs.GrabLedgeLeftBool, false);
            m_Character.animator.SetBool(/*"pGrabLedgeRight"*/ HashIDs.GrabLedgeRightBool, false);
            m_Character.animator.SetBool(/*"pLedgeHang"*/ HashIDs.LedgeHangBool, false);

            m_Character.jumpAllowed = true;
            m_Character.enablePhysics();
            m_Character.rigidBody.isKinematic = false;
            m_Character.setMoveMode(TPCharacter.MovingMode.RotateToDirection);
            m_Character.disableCapsuleScale = false;
            m_Character.restoreCapsuleSize();
            m_Character.disableMove        = false;
            m_Character.disableGroundCheck = false;
            m_Character.ledgeMove          = false;
            m_Character.animatorDampTime   = 0.1f;
            m_Character.setLedge(null);
            m_IKHelper.handIKMode = IKMode.Default;
            m_IKHelper.feetIKMode = IKMode.Default;

            m_TriggerAllowed = false;
            m_TriggerTime    = 0.0f;

            disableIK();
            m_TriggerActive = false;

            if (OnTriggerEnd != null)
            {
                OnTriggerEnd();
            }

            m_CurrentActiveTrigger = null;
        }
        /// <summary>
        /// return to guard position state
        /// </summary>
        private void _return_state()
        {
            m_CurrentDest = m_StartPosition;

            m_Direction2target   = m_CurrentDest - transform.position;
            m_Distance2target    = m_Direction2target.magnitude;
            m_Direction2target.y = 0.0f;
            m_Direction2target.Normalize();

            _calc_ranges();

            m_Character.setMoveMode(TPCharacter.MovingMode.RotateToDirection);


            _calculate_path(ref m_Move);

            m_Move.y      = 0.0f;
            m_Move       *= m_Stats.DefaultMoveSpeed;
            m_BodyLookDir = m_Move;
            if (takingHit)
            {
                m_Move        = Vector3.zero;
                m_BodyLookDir = Vector3.zero;
            }
            m_Character.move(m_Move, false, false, false, m_BodyLookDir, Vector3.zero);

            if (m_InAttackRange)
            {
                m_NpcState = NPCState.Idle;
                m_Character.setMoveMode(TPCharacter.MovingMode.RotateToDirection);
                m_Move = Vector3.zero;
                m_Character.fullStop();
                m_OnStartPosition = true;
            }
        }