/**
  * Updates the first-person camera, if appropriate.
  * This is called every frame by StateHandler.
  */
 public void UpdateFPCamera()
 {
     if (firstPersonCamera != null)
     {
         firstPersonCamera._UpdateFPCamera();
     }
 }
Example #2
0
        /** The Player's "Update" function, called by StateHandler. */
        public override void _Update()
        {
            if (!IsActivePlayer())
            {
                base._Update();
                return;
            }

            if (firstPersonCamera != null && !KickStarter.stateHandler.MovementIsOff)
            {
                firstPersonCamera._UpdateFPCamera();
            }

            bool jumped = false;

            if (KickStarter.playerInput.InputGetButtonDown("Jump") && KickStarter.stateHandler.IsInGameplay() && motionControl == MotionControl.Automatic && !KickStarter.stateHandler.MovementIsOff)
            {
                if (!jumpingLocked)
                {
                    jumped = Jump();
                }
            }

            if (hotspotDetector)
            {
                hotspotDetector._Update();
            }

            if (activePath && !pausePath)
            {
                if (IsTurningBeforeWalking())
                {
                    if (charState == CharState.Move)
                    {
                        StartDecelerating();
                    }
                    else if (charState == CharState.Custom)
                    {
                        charState = CharState.Idle;
                    }
                }
                else if ((KickStarter.stateHandler.gameState == GameState.Cutscene && !lockedPath) ||
                         (KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick) ||
                         (KickStarter.settingsManager.movementMethod == MovementMethod.None) ||
                         (KickStarter.settingsManager.movementMethod == MovementMethod.StraightToCursor && KickStarter.settingsManager.singleTapStraight) ||
                         IsMovingToHotspot())
                {
                    charState = CharState.Move;
                }
            }
            else if (activePath == null && charState == CharState.Move && !KickStarter.stateHandler.IsInGameplay() && KickStarter.stateHandler.gameState != GameState.Paused)
            {
                StartDecelerating();
            }

            if (isJumping && !jumped)
            {
                if (IsGrounded())
                {
                    isJumping = false;
                }
            }

            BaseUpdate();
        }