diff --git a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs index ab34d49ecf..ddc394f57f 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs @@ -1,85 +1,31 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; -using osu.Game.Graphics.Sprites; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Judgements; using OpenTK; -using OpenTK.Graphics; +using osu.Game.Modes.Judgements; namespace osu.Game.Modes.Osu.Objects.Drawables { - public class HitExplosion : FillFlowContainer + public class HitExplosion : DrawableJudgementInfo { - private readonly OsuJudgementInfo judgement; - private SpriteText line1; - private SpriteText line2; - - public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null) + public HitExplosion(OsuJudgementInfo judgement) + : base(judgement) { - this.judgement = judgement; - AutoSizeAxes = Axes.Both; - Origin = Anchor.Centre; - - Direction = FillDirection.Vertical; - Spacing = new Vector2(0, 2); - Position = (h?.StackedEndPosition ?? Vector2.Zero) + judgement.PositionOffset; - - Children = new Drawable[] - { - line1 = new OsuSpriteText - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Text = judgement.Score.GetDescription(), - Font = @"Venera", - TextSize = 16, - }, - line2 = new OsuSpriteText - { - Text = judgement.Combo.GetDescription(), - Font = @"Venera", - TextSize = 11, - } - }; } protected override void LoadComplete() { base.LoadComplete(); - if (judgement.Result == HitResult.Miss) + if (Judgement.Result != HitResult.Miss) { - FadeInFromZero(60); - - ScaleTo(1.6f); - ScaleTo(1, 100, EasingTypes.In); - - MoveToOffset(new Vector2(0, 100), 800, EasingTypes.InQuint); - RotateTo(40, 800, EasingTypes.InQuint); - - Delay(600); - FadeOut(200); - } - else - { - line1.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); - line2.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); + JudgementText.TransformSpacingTo(new Vector2(14, 0), 1800, EasingTypes.OutQuint); FadeOut(500); } - switch (judgement.Result) - { - case HitResult.Miss: - Colour = Color4.Red; - break; - } - Expire(); } } diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 5caaaafb13..bd9b4982eb 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -85,7 +85,11 @@ namespace osu.Game.Modes.Osu.UI public override void OnJudgement(DrawableHitObject judgedObject) { - HitExplosion explosion = new HitExplosion(judgedObject.Judgement, judgedObject.HitObject); + HitExplosion explosion = new HitExplosion(judgedObject.Judgement) + { + Origin = Anchor.Centre, + Position = judgedObject.HitObject.StackedEndPosition + judgedObject.Judgement.PositionOffset + }; judgementLayer.Add(explosion); } diff --git a/osu.Game/Modes/Judgements/DrawableJudgementInfo.cs b/osu.Game/Modes/Judgements/DrawableJudgementInfo.cs new file mode 100644 index 0000000000..fb85e20da0 --- /dev/null +++ b/osu.Game/Modes/Judgements/DrawableJudgementInfo.cs @@ -0,0 +1,86 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Modes.Objects.Drawables; + +namespace osu.Game.Modes.Judgements +{ + /// + /// A drawable object which visualises the hit result of a . + /// + /// The type of judgement to visualise. + public class DrawableJudgementInfo : Container + where TJudgement : JudgementInfo + { + protected readonly TJudgement Judgement; + + protected readonly SpriteText JudgementText; + + /// + /// Creates a drawable which visualises a . + /// + /// The judgement to visualise. + public DrawableJudgementInfo(TJudgement judgement) + { + Judgement = judgement; + + AutoSizeAxes = Axes.Both; + + string scoreString = judgement.Result == HitResult.Hit ? judgement.ScoreString : judgement.Result.GetDescription(); + + Children = new[] + { + JudgementText = new OsuSpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = scoreString.ToUpper(), + Font = @"Venera", + TextSize = 16 + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + switch (Judgement.Result) + { + case HitResult.Miss: + Colour = colours.Red; + break; + } + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + if (Judgement.Result == HitResult.Miss) + { + FadeInFromZero(60); + + ScaleTo(1.6f); + ScaleTo(1, 100, EasingTypes.In); + + MoveToOffset(new Vector2(0, 100), 800, EasingTypes.InQuint); + RotateTo(40, 800, EasingTypes.InQuint); + + Delay(600); + FadeOut(200); + } + + Expire(); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bfb787cd51..164c8c7ec1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -96,6 +96,7 @@ +