예제 #1
0
        private void FindAboveBehindWall()
        {
            Vector3 pos      = controller.transform.position;
            Vector3 startPos = pos + (controller.transform.forward * 0.4f) + (Vector3.up * 0.5f);

            if (InputManager.Instance.HasAction(InputManager.Actions.MoveBackwards))
            {
                scanner.FindAdjacentSurface(startPos, -controller.transform.forward, PlayerMoveScanner.RotationDirection.YZClockwise);
            }
        }
예제 #2
0
        private bool GetAdjacentWallInfo(Vector3 origin, Vector3 direction, PlayerMoveScanner.RotationDirection turnDirection)
        {
            moveScanner.FindAdjacentSurface(origin, direction, turnDirection);
            AdjacentSurface adjSurface = moveScanner.SideWall;

            if (adjSurface != null && adjSurface.adjacentTurns == 0)
            {
                atInsideCorner = IsAtInsideCorner(adjSurface.turnHitDistance);
            }

            if (adjSurface != null)
            {
                adjacentLedgeDirection = adjSurface.grabDirection;
                adjacentWallRay        = adjSurface.adjacentSurfaceRay;
            }

            return(adjSurface != null);
        }
예제 #3
0
        /// <summary>
        /// Check if should do rappel, and do rappel and attach to wall.
        /// </summary>
        public void RappelChecks()
        {
            if (rappelStage == RappelStage.Inactive)
            {
                measure = null;
            }
            else
            {
                // Player can become grounded with a partial rappel state based on object height
                // If player is grounded then reset back to inactive state
                if (GameManager.Instance.PlayerMotor.IsGrounded)
                {
                    ResetRappelState();
                    return;
                }
            }

            InitialSetRappelType();

            bool    inputBackward = InputManager.Instance.HasAction(InputManager.Actions.MoveBackwards);
            Vector3 origin        = Vector3.zero;
            Vector3 direction     = -controller.transform.forward;

            #region Scan For AdjacentSurface
            if (inputBackward)
            {
                // check from different origins to find different surfaces
                if (!climbingMotor.IsClimbing)
                {
                    origin = controller.transform.position + Vector3.down * (0.25f * controller.height) + controller.transform.forward * (0.8f * controller.radius);
                }
                else
                {
                    origin = controller.transform.position + Vector3.up * (0.25f * controller.height) + controller.transform.forward * (0.8f * controller.radius);
                }

                playerScanner.FindAdjacentSurface(origin, direction, PlayerMoveScanner.RotationDirection.YZCounterClockwise);
            }
            #endregion

            // the only time Ground closeness can cancel the start of the rappel is when we are
            // going to rappel down and behind to a wall
            if (InitialTooCloseToGround(rappelDirection))
            {
                IsRappelling = false;
                return;
            }

            if (rappelStage == RappelStage.Activated)
            {
                DaggerfallUI.AddHUDText(UserInterfaceWindows.HardStrings.rappelMode);
                rappelStage = RappelStage.Swooping;
                InitialSetGrappleDirection();

                swoopBasePosition = controller.transform.position;
                rappelTimer       = 0f;
                measure           = null;
            }

            // Rappel swooping
            if (rappelStage == RappelStage.Swooping)
            {
                player.TallySkill(DFCareer.Skills.Climbing, 1);
                Vector3 swoopDirection = grappleDirection;
                // if we are rappelling under to ceiling, grappledirection is different so use adjacentSurfaceRay
                // direction to get right direction to go under the ceiling.
                if (rappelDirection == RappelDirection.DownUnder || rappelDirection == RappelDirection.FrontUp)
                {
                    swoopDirection = playerScanner.WallDetachedVector;
                }
                rappelTimer += Time.deltaTime;

                switch (rappelDirection)
                {
                case RappelDirection.DownBehind:
                    CurlDown(swoopBasePosition, swoopDirection);
                    break;

                case RappelDirection.UpBehind:
                    CurlOver(swoopBasePosition, swoopDirection);
                    break;

                //case RappelDirection.DownUnder:
                //    CurlUnder(swoopBasePosition, swoopDirection);
                //    break;
                case RappelDirection.FrontUp:
                    if (updateSwoopBasePosition)
                    {       // enables player to bottom out on DownUnder and continue FrontUp
                        swoopBasePosition       = controller.transform.position;
                        updateSwoopBasePosition = false;
                        rappelTimer             = 0;
                    }
                    CurlUpHalf(swoopBasePosition, swoopDirection);
                    break;

                default:
                    break;
                }

                controller.transform.position = rappelPosition;
            }

            if (rappelStage == RappelStage.Grappling)
            // perform horizontal measurement-based Wall-grapple direction or vertical for ceiling
            {
                // if measurement hasn't started, start measuring grapple-to-surface movement
                if (measure == null)
                {
                    measure = new VectorMeasurement(controller.transform.position);
                }

                if (!(/*hangingMotor.IsHanging ||*/ climbingMotor.IsClimbing) &&
                    measure.Distance(controller.transform.position) < 1f)
                {
                    // Auto move toward surface to grab
                    float speed = speedChanger.GetBaseSpeed();

                    grappleDirection = grappleDirection.normalized * speed * 1.15f;
                    groundMotor.MoveWithMovingPlatform(grappleDirection);
                }
                else // if we've moved past the distance limit
                {
                    ResetRappelState();
                }
            }
        }