예제 #1
0
    //Character needs to be touching a Zipline object
    public override bool IsApplicable()
    {
        if (!m_IsActive && ((Time.time - m_LastZiplineClimbTime < m_ZiplineClimbCoolDown) || m_ControlledCollider.GetVelocity().y > 0.0f))
        {
            return(false);
        }
        if (m_CanReleaseZiplineWithInput)
        {
            if ((DoesInputExist("ClimbRelease") && GetButtonInput("ClimbRelease").m_IsPressed) ||
                GetDirInput("Move").m_Direction == DirectionInput.Direction.Down)
            {
                return(false);
            }
        }
        if (m_ControlledCollider.IsGrounded())
        {
            return(false);
        }
        Zipline zipline = null;

        if (m_IsActive)
        {
            zipline = m_CurrentZipline;
        }
        else
        {
            zipline = FindZipline();
        }
        if (zipline)
        {
            if (!m_IsActive)
            {
                m_IsSkating = zipline.IsSkateLine();
                Vector3 newPoint = zipline.GetClosestPointOnZipline(GetAttachPoint());

                Vector3 diff = newPoint - GetAttachPoint();
                if (m_ControlledCollider.GetCapsuleTransform().CanMove(diff))
                {
                    return(true);
                }
            }
            else
            {
                //We might have been blocked from attaching too closely to the zipline. Let's make sure that we can actually attach
                if (zipline.GetDistToClosestPointOnZipline(GetAttachPoint()) > m_ZiplineReachRadius)
                {
                    return(false);
                }
                Vector3 travelSpeed = zipline.GetTravelVelocity(GetAttachPoint(), m_ControlledCollider.GetVelocity());
                if (zipline.GetDistToEnd(GetAttachPoint(), travelSpeed) < zipline.GetLetGoDistance())
                {
                    return(false);
                }
                return(true);
            }
        }
        return(false);
    }