Пример #1
0
        public override void FixedUpdateAbility()
        {
            base.FixedUpdateAbility();

            // Check if it finishes start animation
            if (m_AnimatorManager.HasFinishedAnimation(startState) && !m_FinishOnAnimationEnd && m_CurrentStatePlaying == startState)
            {
                string state = (bWallOnFoot) ? m_BracedHangStateName : m_HangStateName;
                SetState(state, m_TransitionDuration);
            }

            CheckToTurn();

            // constantly update found ledge
            if (HasFoundLedge(out frontHit, true))
            {
                WallOnFeet();

                if (!m_FinishOnAnimationEnd)
                {
                    // ------------------------------ CHANGE BETWEEN HANG AND BRACED CLIMBING -------------------------------- //

                    if (bWallOnFoot)
                    {
                        if (m_CurrentStatePlaying == m_HangStateName)
                        {
                            StartCoroutine(ChangeClimbType(ClimbType.Braced));
                        }
                    }
                    else
                    {
                        if (m_CurrentStatePlaying == m_BracedHangStateName)
                        {
                            StartCoroutine(ChangeClimbType(ClimbType.Hang));
                        }
                    }

                    // ----------------------------------------------------------------------------------------------------- //

                    m_CurrentLedgeTransform = topHit.transform; // Set current ledge as the ledge that character is holding
                    if (!m_Engine.IsCoroutinePlaying)
                    {
                        SetCharacterPositionOnLedge();
                        if (m_ClimbIK != null)
                        {
                            m_ClimbIK.RunIK(topHit, m_ClimbableMask, m_CurrentLedgeTransform);
                        }
                    }
                }
                else
                {
                    if (m_CurrentStatePlaying == m_HopUpStateName)
                    {
                        if (m_CurrentLedgeTransform != topHit.transform)
                        {
                            OnEnterAbility();
                        }
                    }
                }
            }


            // ------------------ Ledge position delta -------------------- //

            if (m_CurrentLedgeTransform != null)
            {
                Vector3 ledgeDeltaPosition = Vector3.zero;

                if (m_LastTime != 0 && (Time.fixedTime - m_LastTime) < Time.fixedDeltaTime * 5f && m_LastLedgeTransform == m_CurrentLedgeTransform)
                {
                    ledgeDeltaPosition = m_CurrentLedgeTransform.position - m_LedgeLastPosition;
                }

                transform.position += ledgeDeltaPosition;

                m_LastLedgeTransform = m_CurrentLedgeTransform;
                m_LedgeLastPosition  = m_CurrentLedgeTransform.position;
                m_LastTime           = Time.fixedTime;
            }

            // ------------------------------------------------------------ //

            InputControl();

            // Set horizontal and vertical parameters

            if (!m_SideAdjustment)
            {
                float horizontal = m_Engine.InputManager.Move.x;
                if (CanClimbSide(m_Engine.InputManager.Move.x, true))
                {
                    if (m_CurrentStatePlaying == m_BracedLookStateName)
                    {
                        SetState(m_BracedHangStateName);
                    }
                }
                else
                {
                    if (m_CurrentStatePlaying == m_BracedHangStateName)
                    {
                        SetState(m_BracedLookStateName);
                    }

                    if (!bWallOnFoot) // Check if it's hanging to stop movement
                    {
                        horizontal = 0;
                    }
                }
                m_AnimatorManager.SetHorizontalParameter(horizontal * m_MoveMultiplier, 0.1f);
            }

            m_AnimatorManager.SetForwardParameter(m_Engine.InputManager.Move.y);
        }
        public override void FixedUpdateAbility()
        {
            base.FixedUpdateAbility();

            if (m_ClimbIK != null)
            {
                m_ClimbIK.OnHang = !bWallOnFoot;
            }

            characterOffset = (bWallOnFoot) ? m_CharacterOffsetFromLedge : m_CharacterOffsetOnHang;

            m_System.UpdatePositionOnMovableObject(m_CurrentLedgeTransform);

            if (m_FinishOnAnimationEnd)
            {
                return;
            }

            if (m_CurrentStatePlaying == m_LookBackState)
            {
                m_ClimbIK.ApplyRightHandIK = false;
            }
            else
            {
                if (!m_System.m_Animator.IsInTransition(0) &&
                    m_ClimbIK.ApplyRightHandIK == false)
                {
                    m_ClimbIK.ApplyRightHandIK = true;
                }
            }

            // Check if start animation has ended
            if (m_CurrentStatePlaying == startState)
            {
                if (m_AnimatorManager.HasFinishedAnimation(startState) || Time.fixedTime - AbilityEnterFixedTime > 1)
                {
                    string state = (bWallOnFoot) ? m_BraceIdleState : m_HangIdleState;
                    SetState(state, m_TransitionDuration);
                }
            }

            CheckToTurn();

            // constantly update found ledge
            if (HasFoundLedge(out frontHit, true))
            {
                WallOnFeet();
                timeWithoutFoundLedge = 0;

                // ------------------------------ CHANGE BETWEEN HANG AND BRACED CLIMBING -------------------------------- //

                //  Check shimmy conditions by state tag
                if (bWallOnFoot)
                {
                    if (m_System.m_Animator.GetCurrentAnimatorStateInfo(AnimatorManager.BaseLayerIndex).IsTag("Hang"))
                    {
                        StartCoroutine(ChangeClimbType(ClimbType.Braced));
                    }
                }
                else
                {
                    if (m_System.m_Animator.GetCurrentAnimatorStateInfo(AnimatorManager.BaseLayerIndex).IsTag("Brace"))
                    {
                        StartCoroutine(ChangeClimbType(ClimbType.Hang));
                    }
                }

                // ----------------------------------------------------------------------------------------------------- //

                m_CurrentLedgeTransform = topHit.transform; // Set current ledge as the ledge that character is holding
                if (!m_System.IsCoroutinePlaying)
                {
                    SetCharacterPositionOnLedge();
                    if (m_ClimbIK != null && !m_SideAdjustment)
                    {
                        m_ClimbIK.RunIK(topHit, m_ClimbableMask, m_CurrentLedgeTransform);
                    }
                }
            }
            else
            {
                timeWithoutFoundLedge += Time.deltaTime; // Count time without finding ledge
            }
            SetAnimationsStates();
        }