Пример #1
0
    private void Update()
    {
        myIsJumping   = myPlayerInput.IsJumping();
        myIsQuitting  = myPlayerInput.IsQuitting();
        myHasCollided = myPlayerCollision.HasCollided();

        if (myIsQuitting)
        {
            Application.Quit();
        }

        if (myHasCollided)
        {
            myPlayerCollision.ResetCollided();
            myCamera.TriggerShake(myShakeDurationRocks, myShakeMagnitudeRocks);

            if (!myGrounded && myAirMovement.y < 0)
            {
                myPlayerJump.Bounce(ref myAirMovement, myJumpForce);
                return;
            }

            myPlayerDeath.Die();
            myCurrentSpeed = myBaseSpeed;
            mySplineManager.ResetAllSplines();
            ResetSpline();
        }

        if (myGrounded)
        {
            myPlayerBobbing.Bob();

            if (myIsJumping)
            {
                myPlayerJump.Jump(myCurrentPoints, myPointsIndex, myJumpForce, myCurrentSpeed, ref myAirMovement);
                ResetSpline();
                return;
            }

            if (!myPlayerSpline.SplineMovement(myCurrentPoints, ref myCurrentSpeed, ref myPointsIndex, ref mySplineT, myGravity, myBoost))
            {
                myPlayerSpline.ReleaseSpline(myCurrentPoints, myCurrentSpeed, ref myAirMovement, myPointsIndex);
                ResetSpline();
            }
            return;
        }

        myPlayerAir.AirMovement(myGravity, ref myAirMovement);

        if (myIsJumping)
        {
            myPlayerBackflip.Backflip(myFlipRotationSpeed);
        }
        else
        {
            myPlayerAir.AirRotation(myRotationResetSpeed);
        }

        if (myAirMovement.y < 0)
        {
            if (myPlayerSpline.AttemptToCatchSpline(mySplineManager, myReach, ref myTooCloseToOldSpline, ref myPointsIndex, ref myCurrentPoints, ref myOldPoints, ref myBoost))
            {
                myCamera.TriggerShake(myShakeDurationSplines, myShakeMagnitudeSplines);
                myGrounded = true;
                mySplineT  = 0;
            }
        }
    }