Exemple #1
0
        /// <summary>
        /// Determines what Height-changing action should be taken based on player's input and PlayerMotor.IsRiding
        /// </summary>
        public void DecideHeightAction()
        {
            bool onWater = OnWater;

            timerMax = timerSlow;
            if (onWater && !toggleSink)
            {
                heightAction = HeightChangeAction.DoSinking;
                toggleSink   = true;
            }
            else if (!onWater && toggleSink)
            {
                heightAction = HeightChangeAction.DoUnsinking;
                toggleSink   = false;
            }
            else if (playerMotor.IsRiding && !toggleRiding)
            {
                heightAction = HeightChangeAction.DoMounting;
                toggleRiding = true;
            }
            else if (!playerMotor.IsRiding && toggleRiding)
            {
                heightAction = HeightChangeAction.DoDismounting;
                toggleRiding = false;
            }
            else if (!playerMotor.IsRiding)
            {
                // Toggle crouching
                if (!onWater && InputManager.Instance.ActionComplete(InputManager.Actions.Crouch))
                {
                    if (playerMotor.IsCrouching)
                    {
                        heightAction = HeightChangeAction.DoStanding;
                    }
                    else
                    {
                        heightAction = HeightChangeAction.DoCrouching;
                    }
                }
            }
        }
Exemple #2
0
        private void DoMount() // adjust height first, camera last
        {
            if (controller.height != rideHeight)
            {
                ControllerHeightChange();
            }

            heightTimer += Time.deltaTime;
            float t = Mathf.Clamp((heightTimer / timerMax), 0, 1);

            float prevCamLevel = playerMotor.IsCrouching ? camCrouchLevel : camStandLevel;

            UpdateCameraPosition(Mathf.Lerp(prevCamLevel, camRideLevel, t));

            if (heightTimer >= timerMax)
            {
                heightTimer          = 0f;
                heightAction         = HeightChangeAction.DoNothing;
                playerMotor.IsRiding = true;
            }
        }
Exemple #3
0
 /// <summary>
 /// Reset the camera timer and action
 /// </summary>
 private void timerResetAction()
 {
     camTimer     = 0f;
     heightAction = HeightChangeAction.DoNothing;
 }
Exemple #4
0
        /// <summary>
        /// Determines what Height-changing action should be taken based on player's input and PlayerMotor.IsRiding
        /// </summary>
        public void DecideHeightAction()
        {
            bool onWater       = (GameManager.Instance.PlayerMotor.OnExteriorWater == PlayerMotor.OnExteriorWaterMethod.Swimming);
            bool swimming      = levitateMotor.IsSwimming;
            bool crouching     = playerMotor.IsCrouching;
            bool riding        = playerMotor.IsRiding;
            bool pressedCrouch = InputManager.Instance.ActionComplete(InputManager.Actions.Crouch);
            bool climbing      = climbingMotor.IsClimbing;

            //timerMax = timerSlow;

            if (onWater && !toggleSink)
            {
                timerMax     = timerSlow;
                heightAction = HeightChangeAction.DoSinking;
                toggleSink   = true;
            }
            else if (!onWater && toggleSink)
            {
                timerMax     = timerSlow;
                heightAction = HeightChangeAction.DoUnsinking;
                toggleSink   = false;
            }
            else if (riding && !toggleRiding)
            {
                timerMax     = timerMedium;
                heightAction = HeightChangeAction.DoMounting;
                toggleRiding = true;
            }
            else if (!riding && toggleRiding)
            {
                timerMax     = timerFast;
                heightAction = HeightChangeAction.DoDismounting;
                toggleRiding = false;
            }
            else if (!riding && !onWater)
            {
                // if we crouch out of water or while on solid ground
                if ((!swimming || playerMotor.IsGrounded) && pressedCrouch)
                {
                    timerMax = timerFast;
                    // Toggle crouching
                    if (crouching)
                    {
                        heightAction = HeightChangeAction.DoStanding;
                    }
                    else
                    {
                        heightAction = HeightChangeAction.DoCrouching;
                    }
                    forcedSwimCrouch = false;
                }
                // if climbing, force into standing
                else if (climbing)
                {
                    timerMax = timerMedium;
                    if (crouching)
                    {
                        heightAction = HeightChangeAction.DoStanding;
                    }
                    forcedSwimCrouch = false;
                }
                // if swimming but not crouching, crouch.
                else if (swimming && !forcedSwimCrouch && !playerMotor.IsGrounded)
                {
                    timerMax = timerMedium;
                    if (!crouching)
                    {
                        heightAction = HeightChangeAction.DoCrouching;
                    }
                    forcedSwimCrouch = true;
                }
                // if we're in a forced swim crouch, but not swimming, un-force the crouch
                else if (!swimming && forcedSwimCrouch)
                {
                    timerMax = timerMedium;
                    if (crouching)
                    {
                        heightAction = HeightChangeAction.DoStanding;
                    }
                    forcedSwimCrouch = false;
                }
            }
        }