Beispiel #1
0
        Vector2 IMotionAdjuster.AdjustMotionPerSecond(TimeSpan elapsedInFrame, Vector2 current)
        {
            float targetMultiplier = 1f;

            if (Multiplier != null)
            {
                Config.Change.Scale = Multiplier.GetDeltaMod();
                targetMultiplier    = Multiplier.GetTargetMod();
            }

            var   currentAxisSpeed = current.GetAxis(Axis);
            float newAxisSpeed     = currentAxisSpeed;

            if (justActivated)
            {
                justActivated = false;

                if (Config.StartSpeed != 0)
                {
                    float start = Config.StartSpeed;
                    if (Config.Vary != 0)
                    {
                        start += Random.Get(Config.Vary);
                    }

                    newAxisSpeed = start * FlipAdjust() * targetMultiplier;
                }
            }
            else
            {
                var target = Config.TargetSpeed * FlipAdjust() * targetMultiplier;
                newAxisSpeed = currentAxisSpeed.Approach(target, Config.Change.Value * elapsedInFrame.TotalSeconds);
            }

            if (Config.DeactivateAfterStart)
            {
                Active = false;
            }

            if (Config.DeactivateWhenTargetReached && newAxisSpeed.IsCloseTo(Config.TargetSpeed * targetMultiplier))
            {
                newAxisSpeed = Config.TargetSpeed * FlipAdjust() * targetMultiplier;
                Active       = false;
            }

            var ret = current.SetAxis(Axis, newAxisSpeed);

            return(ret);
        }
        Vector2 IMotionAdjuster.AdjustMotionPerSecond(TimeSpan elapsedInFrame, Vector2 currentMotionPerSecond)
        {
            var axis       = Direction.Axis();
            var axisMotion = currentMotionPerSecond.GetAxis(axis).Abs();

            if (axisMotion >= DistancePerSecond)
            {
                return(currentMotionPerSecond);
            }

            var dps = DistancePerSecond;

            if (Direction == Direction.Left || Direction == Direction.Up)
            {
                dps *= -1;
            }

            return(currentMotionPerSecond.SetAxis(axis, dps));
        }