From dbc2eb4771f985b9e6e87b0925bf62f897555272 Mon Sep 17 00:00:00 2001 From: Kyle Chang Date: Tue, 18 Sep 2018 23:15:36 -0400 Subject: [PATCH] Create ZoomIn Mod --- osu.Game.Rulesets.Osu/Mods/OsuModZoomIn.cs | 55 ++++++++++++++++++++++ osu.Game.Rulesets.Osu/OsuRuleset.cs | 1 + 2 files changed, 56 insertions(+) create mode 100644 osu.Game.Rulesets.Osu/Mods/OsuModZoomIn.cs diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModZoomIn.cs b/osu.Game.Rulesets.Osu/Mods/OsuModZoomIn.cs new file mode 100644 index 0000000000..b531b9b3d0 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Mods/OsuModZoomIn.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Graphics; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Mods +{ + public class OsuModZoomIn : Mod, IApplicableToDrawableHitObjects + { + public override string Name => "Zoom In"; + public override string ShortenedName => "ZI"; + public override FontAwesome Icon => FontAwesome.fa_dot_circle_o; + public override ModType Type => ModType.Fun; + public override string Description => "Circles zoom in. No approach circles."; + public override double ScoreMultiplier => 1; + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + foreach (var drawable in drawables) + { + drawable.ApplyCustomUpdateState += ApplyBounceState; + } + } + + protected void ApplyBounceState(DrawableHitObject drawable, ArmedState state) + { + if (!(drawable is DrawableOsuHitObject d)) + return; + + var h = (OsuHitObject)drawable.HitObject; + + double appearTime = h.StartTime - h.TimePreempt; + double moveDuration = h.TimePreempt; + + using (drawable.BeginAbsoluteSequence(appearTime, true)) + { + var origScale = drawable.Scale; + + drawable + .ScaleTo(0.0f) + .ScaleTo(origScale, moveDuration, Easing.InOutSine); + } + + // Hide approach circle + (drawable as DrawableHitCircle)?.ApproachCircle.Hide(); + } + } +} diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 6736d10dab..029ca7d43e 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -121,6 +121,7 @@ namespace osu.Game.Rulesets.Osu return new Mod[] { new OsuModTransform(), new OsuModWiggle(), + new OsuModZoomIn(), }; default: return new Mod[] { };