From 4db2a1e693c248322c47e21fa1fb8c91ea5345a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 18 Nov 2016 17:36:53 +0900 Subject: [PATCH] Split ApproachCircle out into its own class. --- .../Objects/Drawables/DrawableHitCircle.cs | 47 +++++++++---------- .../Drawables/Pieces/ApproachCircle.cs | 35 ++++++++++++++ osu.Game.Mode.Osu/UI/OsuPlayfield.cs | 1 + osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj | 1 + .../Objects/Drawables/DrawableHitObject.cs | 6 --- 5 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs diff --git a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs index 9d6d918344..6fe58929bb 100644 --- a/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -4,6 +4,7 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Framework.IO.Stores; @@ -15,32 +16,38 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableHitCircle : DrawableHitObject { - private Sprite approachCircle; + private OsuBaseHit osuObject; + + private ApproachCircle approachCircle; private CirclePiece circle; private RingPiece ring; private FlashPiece flash; private ExplodePiece explode; private NumberPiece number; private GlowPiece glow; - private OsuBaseHit h; private HitExplosion explosion; public DrawableHitCircle(HitCircle h) : base(h) { - this.h = h; + osuObject = h; + } + + protected override void LoadComplete() + { + base.LoadComplete(); Origin = Anchor.Centre; - Position = h.Position; + Position = osuObject.Position; Children = new Drawable[] { glow = new GlowPiece { - Colour = h.Colour + Colour = osuObject.Colour }, circle = new CirclePiece { - Colour = h.Colour, + Colour = osuObject.Colour, Hit = Hit, }, number = new NumberPiece(), @@ -48,29 +55,16 @@ namespace osu.Game.Modes.Osu.Objects.Drawables flash = new FlashPiece(), explode = new ExplodePiece { - Colour = h.Colour, + Colour = osuObject.Colour, }, - approachCircle = new Sprite + approachCircle = new ApproachCircle() { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = h.Colour + Colour = osuObject.Colour, } }; //may not be so correct Size = circle.DrawSize; - } - - [BackgroundDependencyLoader] - private void load(BaseGame game) - { - approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x"); - } - - protected override void LoadComplete() - { - base.LoadComplete(); //force application of the state that was set before we loaded. UpdateState(State); @@ -81,8 +75,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (!IsLoaded) return; Flush(true); //move to DrawableHitObject + approachCircle.Flush(true); - double t = HitTime ?? h.StartTime; + double t = HitTime ?? osuObject.StartTime; + + Alpha = 0; //sane defaults ring.Alpha = circle.Alpha = number.Alpha = approachCircle.Alpha = glow.Alpha = 1; @@ -91,18 +88,20 @@ namespace osu.Game.Modes.Osu.Objects.Drawables //always-present transforms Transforms.Add(new TransformAlpha { StartTime = t - 1000, EndTime = t - 800, StartValue = 0, EndValue = 1 }); + approachCircle.Transforms.Add(new TransformScale { StartTime = t - 1000, EndTime = t, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) }); //set transform delay to t==hitTime Delay(t - Time.Current, true); approachCircle.FadeOut(); + glow.FadeOut(400); switch (state) { case ArmedState.Disarmed: - Delay(h.Duration + 200); + Delay(osuObject.Duration + 200); FadeOut(200); explosion?.Expire(); diff --git a/osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs new file mode 100644 index 0000000000..0932fef28f --- /dev/null +++ b/osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs @@ -0,0 +1,35 @@ +using System; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.Input; +using OpenTK; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class ApproachCircle : Container + { + private Sprite approachCircle; + + public ApproachCircle() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + approachCircle = new Sprite() + }; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + approachCircle.Texture = textures.Get(@"Play/osu/approachcircle@2x"); + } + } +} \ No newline at end of file diff --git a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs index 93700db30b..6ce25b10eb 100644 --- a/osu.Game.Mode.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Mode.Osu/UI/OsuPlayfield.cs @@ -4,6 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.UI; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj index 7f59ab3a83..d19491647e 100644 --- a/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Mode.Osu/osu.Game.Modes.Osu.csproj @@ -41,6 +41,7 @@ + diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index d5674d8314..1fca19484b 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -53,12 +53,6 @@ namespace osu.Game.Modes.Objects.Drawables return true; } - protected override void LoadComplete() - { - base.LoadComplete(); - UpdateState(state); - } - private bool counted; protected override void Update()