Beispiel #1
0
        public override void OnActiveFixedUpdate()
        {
            UpdateControlLockTimer();

            // Accelerate as long as the control lock isn't on
            if (!ControlLockTimerOn)
            {
                Accelerate(_axis);
            }

            // If we're on a wall and aren't going quickly enough, start the control lock
            if (Mathf.Abs(Controller.GroundVelocity) < Controller.DetachSpeed &&
                DMath.AngleInRange_d(Controller.RelativeSurfaceAngle, 50.0f, 310.0f))
            {
                Lock();
            }

            // Disable slope gravity when we're not moving, so that Sonic can stand on slopes
            Controller.DisableSlopeGravity = !(Accelerating || ControlLockTimerOn ||
                                               Mathf.Abs(Controller.GroundVelocity) > MinSlopeGravitySpeed);

            // Disable ground friction while we have player input
            Controller.DisableGroundFriction =
                (!DisableAcceleration && Accelerating) ||
                (!DisableDeceleration && Braking);

            // Orient the player in the direction we're moving (not graphics-wise, just internally!)
            if (!ControlLockTimerOn && !DMath.Equalsf(_axis))
            {
                Controller.FacingForward = Controller.GroundVelocity >= 0.0f;
            }
        }
Beispiel #2
0
        public override void OnActiveFixedUpdate()
        {
            var previousUphill = Uphill;

            if (Controller.GroundVelocity > 0.0f)
            {
                Uphill = DMath.AngleInRange_d(Controller.RelativeSurfaceAngle, 0.0f, 180.0f);
            }
            else if (Controller.GroundVelocity < 0.0f)
            {
                Uphill = DMath.AngleInRange_d(Controller.RelativeSurfaceAngle, 180.0f, 360.0f);
            }

            if (Controller.SlopeGravity != (previousUphill ? UphillGravity : DownhillGravity))
            {
                _originalSlopeGravity = Controller.SlopeGravity;
            }

            Controller.SlopeGravity = Uphill ? UphillGravity : DownhillGravity;
        }
Beispiel #3
0
 /// <summary>
 /// The test used when LimitAngle is true to see if the platform should be activated.
 /// </summary>
 /// <param name="angle">The angle, in degrees.</param>
 /// <returns></returns>
 public bool CheckAngle(float angle)
 {
     return(DMath.AngleInRange_d(angle - (RelativeToRotation ? transform.eulerAngles.z : 0f)
                                 , SurfaceAngleMin, SurfaceAngleMax));
 }