mirror of
https://github.com/ppy/osu.git
synced 2025-02-04 23:43:00 +08:00
Move all extended animation logic out of DrawableJudgement
This commit is contained in:
parent
82c3925a37
commit
f465dd5a5e
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -19,13 +19,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
if (JudgementText != null)
|
|
||||||
JudgementText.Font = JudgementText.Font.With(size: 25);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override double FadeInDuration => 50;
|
protected override double FadeInDuration => 50;
|
||||||
|
|
||||||
protected override void ApplyHitAnimations()
|
protected override void ApplyHitAnimations()
|
||||||
@ -36,5 +29,17 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
JudgementBody.Delay(FadeInDuration).ScaleTo(0.75f, 250);
|
JudgementBody.Delay(FadeInDuration).ScaleTo(0.75f, 250);
|
||||||
this.Delay(FadeInDuration).FadeOut(200);
|
this.Delay(FadeInDuration).FadeOut(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateDefaultJudgement(HitResult type)
|
||||||
|
=> new ManiaJudgementPiece();
|
||||||
|
|
||||||
|
private class ManiaJudgementPiece : DefaultJudgementPiece
|
||||||
|
{
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
JudgementText.Font = JudgementText.Font.With(size: 25);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -65,8 +65,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
fadeOutDelay = hitLightingEnabled ? 1400 : base.FadeOutDelay;
|
fadeOutDelay = hitLightingEnabled ? 1400 : base.FadeOutDelay;
|
||||||
|
|
||||||
JudgementText?.TransformSpacingTo(Vector2.Zero).Then().TransformSpacingTo(new Vector2(14, 0), 1800, Easing.OutQuint);
|
|
||||||
base.ApplyHitAnimations();
|
base.ApplyHitAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Drawable CreateDefaultJudgement(HitResult type) => new OsuJudgementPiece();
|
||||||
|
|
||||||
|
private class OsuJudgementPiece : DefaultJudgementPiece
|
||||||
|
{
|
||||||
|
public override void PlayAnimation(HitResult resultType)
|
||||||
|
{
|
||||||
|
base.PlayAnimation(resultType);
|
||||||
|
|
||||||
|
if (resultType != HitResult.Miss)
|
||||||
|
JudgementText.TransformSpacingTo(Vector2.Zero).Then().TransformSpacingTo(new Vector2(14, 0), 1800, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
65
osu.Game/Rulesets/Judgements/DefaultJudgementPiece.cs
Normal file
65
osu.Game/Rulesets/Judgements/DefaultJudgementPiece.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Judgements
|
||||||
|
{
|
||||||
|
public class DefaultJudgementPiece : CompositeDrawable, IAnimatableJudgement
|
||||||
|
{
|
||||||
|
protected SpriteText JudgementText { get; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
public DefaultJudgementPiece()
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
JudgementText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Numeric.With(size: 20),
|
||||||
|
Scale = new Vector2(0.85f, 1),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void PlayAnimation(HitResult result)
|
||||||
|
{
|
||||||
|
JudgementText.Text = result.GetDescription().ToUpperInvariant();
|
||||||
|
JudgementText.Colour = colours.ForHitResult(result);
|
||||||
|
|
||||||
|
this.RotateTo(0);
|
||||||
|
this.MoveTo(Vector2.Zero);
|
||||||
|
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case HitResult.Miss:
|
||||||
|
this.ScaleTo(1.6f);
|
||||||
|
this.ScaleTo(1, 100, Easing.In);
|
||||||
|
|
||||||
|
this.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);
|
||||||
|
|
||||||
|
this.RotateTo(40, 800, Easing.InQuint);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
this.ScaleTo(0.9f);
|
||||||
|
this.ScaleTo(1, 500, Easing.OutElastic);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,18 +3,14 @@
|
|||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osuTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Pooling;
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Judgements
|
namespace osu.Game.Rulesets.Judgements
|
||||||
{
|
{
|
||||||
@ -25,16 +21,13 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
{
|
{
|
||||||
private const float judgement_size = 128;
|
private const float judgement_size = 128;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OsuColour colours { get; set; }
|
|
||||||
|
|
||||||
public JudgementResult Result { get; private set; }
|
public JudgementResult Result { get; private set; }
|
||||||
|
|
||||||
public DrawableHitObject JudgedObject { get; private set; }
|
public DrawableHitObject JudgedObject { get; private set; }
|
||||||
|
|
||||||
protected Container JudgementBody { get; private set; }
|
protected Container JudgementBody { get; private set; }
|
||||||
protected SpriteText JudgementText { get; private set; }
|
|
||||||
|
|
||||||
private SkinnableDrawable bodyDrawable;
|
private SkinnableDrawable skinnableJudgement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Duration of initial fade in.
|
/// Duration of initial fade in.
|
||||||
@ -69,14 +62,34 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
prepareDrawables();
|
prepareDrawables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply top-level animations to the current judgement when successfully hit.
|
||||||
|
/// Generally used for fading, defaulting to a simple fade out based on <see cref="FadeOutDelay"/>.
|
||||||
|
/// This will be used to calculate the lifetime of the judgement.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For animating the actual "default skin" judgement itself, it is recommended to use <see cref="CreateDefaultJudgement"/>.
|
||||||
|
/// This allows applying animations which don't affect custom skins.
|
||||||
|
/// </remarks>
|
||||||
protected virtual void ApplyHitAnimations()
|
protected virtual void ApplyHitAnimations()
|
||||||
{
|
{
|
||||||
JudgementBody.ScaleTo(0.9f);
|
|
||||||
JudgementBody.ScaleTo(1, 500, Easing.OutElastic);
|
|
||||||
|
|
||||||
this.Delay(FadeOutDelay).FadeOut(400);
|
this.Delay(FadeOutDelay).FadeOut(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply top-level animations to the current judgement when missed.
|
||||||
|
/// Generally used for fading, defaulting to a simple fade out based on <see cref="FadeOutDelay"/>.
|
||||||
|
/// This will be used to calculate the lifetime of the judgement.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For animating the actual "default skin" judgement itself, it is recommended to use <see cref="CreateDefaultJudgement"/>.
|
||||||
|
/// This allows applying animations which don't affect custom skins.
|
||||||
|
/// </remarks>
|
||||||
|
protected virtual void ApplyMissAnimations()
|
||||||
|
{
|
||||||
|
this.Delay(600).FadeOut(200);
|
||||||
|
}
|
||||||
|
|
||||||
public void Apply([NotNull] JudgementResult result, [CanBeNull] DrawableHitObject judgedObject)
|
public void Apply([NotNull] JudgementResult result, [CanBeNull] DrawableHitObject judgedObject)
|
||||||
{
|
{
|
||||||
Result = result;
|
Result = result;
|
||||||
@ -91,12 +104,9 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
|
|
||||||
prepareDrawables();
|
prepareDrawables();
|
||||||
|
|
||||||
bodyDrawable.ResetAnimation();
|
skinnableJudgement.ResetAnimation();
|
||||||
|
|
||||||
this.FadeInFromZero(FadeInDuration, Easing.OutQuint);
|
this.FadeInFromZero(FadeInDuration, Easing.OutQuint);
|
||||||
JudgementBody.ScaleTo(1);
|
|
||||||
JudgementBody.RotateTo(0);
|
|
||||||
JudgementBody.MoveTo(Vector2.Zero);
|
|
||||||
|
|
||||||
switch (Result.Type)
|
switch (Result.Type)
|
||||||
{
|
{
|
||||||
@ -104,13 +114,7 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HitResult.Miss:
|
case HitResult.Miss:
|
||||||
JudgementBody.ScaleTo(1.6f);
|
ApplyMissAnimations();
|
||||||
JudgementBody.ScaleTo(1, 100, Easing.In);
|
|
||||||
|
|
||||||
JudgementBody.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);
|
|
||||||
JudgementBody.RotateTo(40, 800, Easing.InQuint);
|
|
||||||
|
|
||||||
this.Delay(600).FadeOut(200);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -118,6 +122,12 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skinnableJudgement.Drawable is IAnimatableJudgement animatable)
|
||||||
|
{
|
||||||
|
using (BeginAbsoluteSequence(Result.TimeAbsolute))
|
||||||
|
animatable.PlayAnimation(Result.Type);
|
||||||
|
}
|
||||||
|
|
||||||
Expire(true);
|
Expire(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,16 +149,13 @@ namespace osu.Game.Rulesets.Judgements
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = bodyDrawable = new SkinnableDrawable(new GameplaySkinComponent<HitResult>(type), _ => JudgementText = new OsuSpriteText
|
Child = skinnableJudgement = new SkinnableDrawable(new GameplaySkinComponent<HitResult>(type), _ =>
|
||||||
{
|
CreateDefaultJudgement(type), confineMode: ConfineMode.NoScaling)
|
||||||
Text = type.GetDescription().ToUpperInvariant(),
|
|
||||||
Font = OsuFont.Numeric.With(size: 20),
|
|
||||||
Colour = colours.ForHitResult(type),
|
|
||||||
Scale = new Vector2(0.85f, 1),
|
|
||||||
}, confineMode: ConfineMode.NoScaling)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
currentDrawableType = type;
|
currentDrawableType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual Drawable CreateDefaultJudgement(HitResult type) => new DefaultJudgementPiece();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
osu.Game/Rulesets/Judgements/IAnimatableJudgement.cs
Normal file
15
osu.Game/Rulesets/Judgements/IAnimatableJudgement.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Judgements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A skinnable judgement element which supports playing an animation from the current point in time.
|
||||||
|
/// </summary>
|
||||||
|
public interface IAnimatableJudgement
|
||||||
|
{
|
||||||
|
void PlayAnimation(HitResult result);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user