2020-03-11 13:28:13 +08:00
|
|
|
// 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.
|
|
|
|
|
2020-12-07 17:12:55 +08:00
|
|
|
using osu.Framework.Graphics;
|
2021-06-16 15:14:42 +08:00
|
|
|
using osu.Framework.Timing;
|
2021-07-29 16:12:01 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Pooling;
|
2020-03-11 13:28:13 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
|
|
{
|
2021-06-16 13:01:12 +08:00
|
|
|
/// <summary>
|
|
|
|
/// A trail of the catcher.
|
|
|
|
/// It also represents a hyper dash afterimage.
|
|
|
|
/// </summary>
|
2021-07-29 16:12:01 +08:00
|
|
|
public partial class CatcherTrail : PoolableDrawableWithLifetime<CatcherTrailEntry>
|
2020-03-11 13:28:13 +08:00
|
|
|
{
|
2021-06-14 18:45:58 +08:00
|
|
|
private readonly SkinnableCatcher body;
|
2020-12-07 17:12:55 +08:00
|
|
|
|
2021-06-14 18:47:18 +08:00
|
|
|
public CatcherTrail()
|
2020-12-07 17:12:55 +08:00
|
|
|
{
|
2021-07-21 15:43:24 +08:00
|
|
|
Size = new Vector2(Catcher.BASE_SIZE);
|
2021-06-14 18:45:58 +08:00
|
|
|
Origin = Anchor.TopCentre;
|
2021-06-14 18:46:48 +08:00
|
|
|
Blending = BlendingParameters.Additive;
|
2021-06-16 15:14:42 +08:00
|
|
|
InternalChild = body = new SkinnableCatcher
|
|
|
|
{
|
|
|
|
// Using a frozen clock because trails should not be animated when the skin has an animated catcher.
|
|
|
|
// TODO: The animation should be frozen at the animation frame at the time of the trail generation.
|
|
|
|
Clock = new FramedClock(new ManualClock()),
|
|
|
|
};
|
2020-03-11 13:28:13 +08:00
|
|
|
}
|
2020-12-08 16:31:00 +08:00
|
|
|
|
2021-07-29 16:12:01 +08:00
|
|
|
protected override void OnApply(CatcherTrailEntry entry)
|
2020-12-08 16:31:00 +08:00
|
|
|
{
|
2021-07-29 16:12:01 +08:00
|
|
|
Position = new Vector2(entry.Position, 0);
|
2021-07-31 07:31:08 +08:00
|
|
|
Scale = entry.Scale;
|
2021-07-29 16:12:01 +08:00
|
|
|
|
|
|
|
body.AnimationState.Value = entry.CatcherState;
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(entry.LifetimeStart, false))
|
|
|
|
applyTransforms(entry.Animation);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnFree(CatcherTrailEntry entry)
|
|
|
|
{
|
2021-07-31 07:31:08 +08:00
|
|
|
ApplyTransformsAt(double.MinValue);
|
2021-07-29 16:12:01 +08:00
|
|
|
ClearTransforms();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyTransforms(CatcherTrailAnimation animation)
|
|
|
|
{
|
|
|
|
switch (animation)
|
|
|
|
{
|
|
|
|
case CatcherTrailAnimation.Dashing:
|
|
|
|
case CatcherTrailAnimation.HyperDashing:
|
|
|
|
this.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
|
|
|
|
break;
|
|
|
|
|
2021-08-02 14:08:42 +08:00
|
|
|
case CatcherTrailAnimation.HyperDashAfterImage:
|
2021-07-29 16:12:01 +08:00
|
|
|
this.MoveToOffset(new Vector2(0, -10), 1200, Easing.In);
|
|
|
|
this.ScaleTo(Scale * 0.95f).ScaleTo(Scale * 1.2f, 1200, Easing.In);
|
|
|
|
this.FadeOut(1200);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Expire();
|
2020-12-08 16:31:00 +08:00
|
|
|
}
|
2020-03-11 13:28:13 +08:00
|
|
|
}
|
|
|
|
}
|