コード例 #1
0
        public override bool TryEnterAbility()
        {
            if ((m_System.IsGrounded || m_System.GroundCheckDistance < 0.05f) &&
                UsePredictionMath)
            {
                if (!Mathf.Approximately(m_System.InputManager.RelativeInput.magnitude, 0))
                {
                    Vector3 direction = m_System.InputManager.RelativeInput.normalized;

                    // Get all climbing abilities attached to character
                    List <ThirdPersonAbstractClimbing> climbingAttached = new List <ThirdPersonAbstractClimbing>();
                    climbingAttached.AddRange(GetComponents <ThirdPersonAbstractClimbing>());

                    // Loop trough all climbing abilities
                    foreach (ThirdPersonAbstractClimbing climbing in climbingAttached)
                    {
                        // Ignore abilities that no use math
                        if (!climbing.UseLaunchMath)
                        {
                            continue;
                        }

                        // Get a launch data
                        LaunchData data = GetLaunchData(climbing.GrabPosition, climbing.LinecastStartPoint, NormalJumpParameters,
                                                        direction, m_MaxAngle, Vector3.zero, climbing.ClimbingMask);

                        if (IsLaunchDataOnlyWay(data, direction)) // If launch data is the unique way to reach point
                        {
                            SetLaunchParameters(data, (climbing is LowerClimbAbility) ? ClimbJumpType.FromGroundToLower :
                                                ClimbJumpType.FromGroundToHang);

                            return(true);
                        }
                    }

                    // Check for ladders
                    LadderAbility ladder = GetComponent <LadderAbility>();
                    if (ladder != null)
                    {
                        // Check if ladder wants to use math for launch
                        if (ladder.CalculateLaunchParameters)
                        {
                            LaunchData data = GetLaunchData(ladder.GrabPosition, m_System.m_Capsule.height, NormalJumpParameters, direction, m_MaxAngle, Vector3.up, ladder.LadderMask);
                            if (IsLaunchDataOnlyWay(data, direction))
                            {
                                SetLaunchParameters(data, ClimbJumpType.FromGroundToHang);
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
コード例 #2
0
        protected virtual void Awake()
        {
            LadderAbility climbLadderAbility = GetComponent <LadderAbility>();

            if (climbLadderAbility != null)
            {
                m_LadderMask = climbLadderAbility.LadderMask;
            }

            characterOffset = m_CharacterOffsetFromLedge;
        }