예제 #1
0
        public static bool CheckLadderKind(PlayerEntity player, out LadderLocation location, bool considerDirection = false)
        {
            location = LadderLocation.Null;

            var playerTransform = player.RootGo().transform;
            var pos             = playerTransform.position;

            Vector3 capsuleBottom, capsuleUp;
            float   capsuleRadius;

            PlayerEntityUtility.GetCapsule(player, pos, out capsuleBottom,
                                           out capsuleUp, out capsuleRadius);

            //DebugDraw.DebugWireSphere(capsuleBottom, Color.red, capsuleRadius);

            var length = Physics.OverlapSphereNonAlloc(capsuleBottom, capsuleRadius, colliders, UnityLayers.ClimbLadderLayerMask);

            if (length == 0)
            {
                return(false);
            }


            location = CheckLadderLocation(colliders, length, playerTransform, considerDirection);

            return(location != LadderLocation.Null);
        }
예제 #2
0
 private void Reset()
 {
     _isUsingLadder    = false;
     _triggerEnterOnce = false;
     _triggerExitOnce  = false;
     if (null != _thirdPersonAnimator)
     {
         _thirdPersonAnimator.applyRootMotion = false;
     }
     _toLadderLocation = LadderLocation.Null;
     _ladderKind       = LadderKind.Null;
 }
예제 #3
0
        private void TestExitLadderImpl(LadderLocation ladderLocation)
        {
            _toLadderLocation = ladderLocation;
            if (!_isUsingLadder || _triggerEnterOnce || _triggerExitOnce)
            {
                return;
            }

            if (LadderLocation.Bottom == ladderLocation && _ladderSpeed < -0.05f ||
                (LadderLocation.Top == ladderLocation && _ladderSpeed > 0.05f))
            {
                _ladderKind = LadderKind.Exit;
                TriggerExitLadder();
            }
        }
예제 #4
0
        private void TestEnterLadderImpl(LadderLocation location)
        {
            _toLadderLocation = location;
            if (_isUsingLadder || _triggerEnterOnce || _triggerExitOnce)
            {
                return;
            }

            if (_ladderSpeed > 0.05f)
            {
                if (LadderLocation.Bottom == location ||
                    LadderLocation.Top == location)
                {
                    _ladderKind = LadderKind.Enter;
                    TriggerEnterLadder();
                }
                else if (LadderLocation.Middle == location)
                {
                    TriggerMiddleEnterLadder();
                }
            }
        }
예제 #5
0
 public void TestEnterLadder(LadderLocation location)
 {
     TestEnterLadderImpl(location);
 }
예제 #6
0
 public void Update(LadderLocation ladderLocation)
 {
     TestExitLadderImpl(ladderLocation);
 }