Add fade to banana's lighting as it approaches the catcher

This also avoids using the `UprightScalingContainer` (and allows for
scale adjust in the process).
This commit is contained in:
Dean Herbert 2022-10-28 18:29:55 +09:00
parent 92167afaab
commit e87b541c58
4 changed files with 22 additions and 9 deletions

View File

@ -5,9 +5,10 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Rulesets.Catch.Objects;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -15,10 +16,14 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
{ {
internal class ArgonBananaPiece : ArgonFruitPiece internal class ArgonBananaPiece : ArgonFruitPiece
{ {
private Container stabilisedPieceContainer = null!;
protected override Drawable BorderPiece => stabilisedPieceContainer;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AddInternal(new UprightAspectMaintainingContainer AddInternal(stabilisedPieceContainer = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -44,7 +49,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
Width = 1.6f, Width = 1.6f,
Height = 2, Height = 2,
}, },
new Box new Circle
{ {
Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.White.Opacity(0)), Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.White.Opacity(0)),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -78,5 +83,15 @@ namespace osu.Game.Rulesets.Catch.Skinning.Argon
} }
}); });
} }
protected override void Update()
{
base.Update();
float scale = 0.5f + 0.5f * (1 / (ObjectState.DisplaySize.X / (CatchHitObject.OBJECT_RADIUS * 2)));
stabilisedPieceContainer.Rotation = -ObjectState.DisplayRotation;
stabilisedPieceContainer.Scale = new Vector2(scale);
}
} }
} }

View File

@ -1,21 +1,19 @@
// 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.
#nullable disable
using osu.Framework.Graphics; using osu.Framework.Graphics;
namespace osu.Game.Rulesets.Catch.Skinning.Default namespace osu.Game.Rulesets.Catch.Skinning.Default
{ {
public class BananaPiece : CatchHitObjectPiece public class BananaPiece : CatchHitObjectPiece
{ {
protected override BorderPiece BorderPiece { get; } protected override Drawable BorderPiece { get; }
public BananaPiece() public BananaPiece()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[] InternalChildren = new[]
{ {
new BananaPulpFormation new BananaPulpFormation
{ {

View File

@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
/// A part of this piece that will be faded out while falling in the playfield. /// A part of this piece that will be faded out while falling in the playfield.
/// </summary> /// </summary>
[CanBeNull] [CanBeNull]
protected virtual BorderPiece BorderPiece => null; protected virtual Drawable BorderPiece => null;
/// <summary> /// <summary>
/// A part of this piece that will be only visible when <see cref="HyperDash"/> is true. /// A part of this piece that will be only visible when <see cref="HyperDash"/> is true.

View File

@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>(); public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
protected override BorderPiece BorderPiece { get; } protected override Drawable BorderPiece { get; }
protected override Drawable HyperBorderPiece { get; } protected override Drawable HyperBorderPiece { get; }
public FruitPiece() public FruitPiece()