2022-09-15 16:51:10 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-09-16 18:25:12 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2022-09-15 16:51:10 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2023-01-25 14:50:49 +08:00
|
|
|
using osu.Game.Configuration;
|
2022-09-15 16:51:10 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
|
|
|
{
|
|
|
|
public partial class ArgonMainCirclePiece : CompositeDrawable
|
|
|
|
{
|
2022-09-19 16:05:36 +08:00
|
|
|
public const float BORDER_THICKNESS = (OsuHitObject.OBJECT_RADIUS * 2) * (2f / 58);
|
2022-09-19 13:38:21 +08:00
|
|
|
|
2022-09-19 16:05:36 +08:00
|
|
|
public const float GRADIENT_THICKNESS = BORDER_THICKNESS * 2.5f;
|
|
|
|
|
|
|
|
public const float OUTER_GRADIENT_SIZE = (OsuHitObject.OBJECT_RADIUS * 2) - BORDER_THICKNESS * 4;
|
|
|
|
|
|
|
|
public const float INNER_GRADIENT_SIZE = OUTER_GRADIENT_SIZE - GRADIENT_THICKNESS * 2;
|
|
|
|
public const float INNER_FILL_SIZE = INNER_GRADIENT_SIZE - GRADIENT_THICKNESS * 2;
|
2022-09-19 13:38:21 +08:00
|
|
|
|
2022-09-19 15:14:35 +08:00
|
|
|
private readonly Circle outerFill;
|
2022-09-15 16:51:10 +08:00
|
|
|
private readonly Circle outerGradient;
|
|
|
|
private readonly Circle innerGradient;
|
|
|
|
private readonly Circle innerFill;
|
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
private readonly RingPiece border;
|
2022-09-15 16:51:10 +08:00
|
|
|
private readonly OsuSpriteText number;
|
|
|
|
|
|
|
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
2022-09-16 18:25:12 +08:00
|
|
|
private readonly FlashPiece flash;
|
2023-01-25 17:59:26 +08:00
|
|
|
private readonly KiaiFlash kiaiFlash;
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2023-01-25 14:50:49 +08:00
|
|
|
private Bindable<bool> configHitLighting = null!;
|
|
|
|
|
2022-09-15 16:51:10 +08:00
|
|
|
[Resolved]
|
|
|
|
private DrawableHitObject drawableObject { get; set; } = null!;
|
|
|
|
|
2022-09-19 15:14:35 +08:00
|
|
|
public ArgonMainCirclePiece(bool withOuterFill)
|
2022-09-15 16:51:10 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2022-09-19 15:14:35 +08:00
|
|
|
outerFill = new Circle // renders white outer border and dark fill
|
|
|
|
{
|
|
|
|
Size = Size,
|
|
|
|
Alpha = withOuterFill ? 1 : 0,
|
|
|
|
},
|
2022-09-15 16:51:10 +08:00
|
|
|
outerGradient = new Circle // renders the outer bright gradient
|
|
|
|
{
|
2022-09-19 13:38:21 +08:00
|
|
|
Size = new Vector2(OUTER_GRADIENT_SIZE),
|
2022-09-15 16:51:10 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
innerGradient = new Circle // renders the inner bright gradient
|
|
|
|
{
|
2022-09-19 16:05:36 +08:00
|
|
|
Size = new Vector2(INNER_GRADIENT_SIZE),
|
2022-09-15 16:51:10 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
innerFill = new Circle // renders the inner dark fill
|
|
|
|
{
|
2022-09-19 16:05:36 +08:00
|
|
|
Size = new Vector2(INNER_FILL_SIZE),
|
2022-09-15 16:51:10 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
2023-01-25 17:59:26 +08:00
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
Masking = true,
|
|
|
|
Size = Size,
|
|
|
|
Child = kiaiFlash = new KiaiFlash
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
},
|
2022-09-15 16:51:10 +08:00
|
|
|
number = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.Default.With(size: 52, weight: FontWeight.Bold),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = -2,
|
|
|
|
Text = @"1",
|
|
|
|
},
|
2022-09-16 18:25:12 +08:00
|
|
|
flash = new FlashPiece(),
|
2022-09-19 13:38:21 +08:00
|
|
|
border = new RingPiece(BORDER_THICKNESS),
|
2022-09-15 16:51:10 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2023-01-25 14:50:49 +08:00
|
|
|
private void load(OsuConfigManager config)
|
2022-09-15 16:51:10 +08:00
|
|
|
{
|
|
|
|
var drawableOsuObject = (DrawableOsuHitObject)drawableObject;
|
|
|
|
|
|
|
|
accentColour.BindTo(drawableObject.AccentColour);
|
|
|
|
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
|
2023-01-25 14:50:49 +08:00
|
|
|
|
|
|
|
configHitLighting = config.GetBindable<bool>(OsuSetting.HitLighting);
|
2022-09-15 16:51:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-10-19 14:52:25 +08:00
|
|
|
indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);
|
|
|
|
|
2022-09-15 16:51:10 +08:00
|
|
|
accentColour.BindValueChanged(colour =>
|
|
|
|
{
|
2022-10-19 14:52:25 +08:00
|
|
|
// A colour transform is applied.
|
|
|
|
// Without removing transforms first, when it is rewound it may apply an old colour.
|
2022-10-20 06:16:27 +08:00
|
|
|
outerGradient.ClearTransforms(targetMember: nameof(Colour));
|
2022-09-15 16:51:10 +08:00
|
|
|
outerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.1f));
|
2022-10-20 06:18:07 +08:00
|
|
|
|
2023-01-25 17:59:26 +08:00
|
|
|
kiaiFlash.Colour = colour.NewValue;
|
2022-10-19 14:52:25 +08:00
|
|
|
outerFill.Colour = innerFill.Colour = colour.NewValue.Darken(4);
|
2022-09-15 16:51:10 +08:00
|
|
|
innerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue.Darken(0.5f), colour.NewValue.Darken(0.6f));
|
2022-09-19 12:19:56 +08:00
|
|
|
flash.Colour = colour.NewValue;
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2022-11-01 18:12:59 +08:00
|
|
|
// Accent colour may be changed many times during a paused gameplay state.
|
|
|
|
// Schedule the change to avoid transforms piling up.
|
2023-01-24 16:43:14 +08:00
|
|
|
Scheduler.AddOnce(() =>
|
|
|
|
{
|
|
|
|
ApplyTransformsAt(double.MinValue, true);
|
|
|
|
ClearTransformsAfter(double.MinValue, true);
|
2023-01-25 10:47:15 +08:00
|
|
|
|
|
|
|
updateStateTransforms(drawableObject, drawableObject.State.Value);
|
2023-01-24 16:43:14 +08:00
|
|
|
});
|
2022-10-19 14:52:25 +08:00
|
|
|
}, true);
|
2022-09-15 16:51:10 +08:00
|
|
|
|
|
|
|
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
|
|
|
{
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case ArmedState.Hit:
|
2022-09-19 12:19:56 +08:00
|
|
|
// Fade out time is at a maximum of 800. Must match `DrawableHitCircle`'s arbitrary lifetime spec.
|
2022-09-16 18:25:12 +08:00
|
|
|
const double fade_out_time = 800;
|
2022-09-19 12:19:56 +08:00
|
|
|
const double flash_in_duration = 150;
|
2022-09-22 23:53:52 +08:00
|
|
|
const double resize_duration = 400;
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
const float shrink_size = 0.8f;
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2023-01-25 14:50:49 +08:00
|
|
|
// When the user has hit lighting disabled, we won't be showing the bright white flash.
|
|
|
|
// To make things look good, the surrounding animations are also slightly adjusted.
|
|
|
|
bool showFlash = configHitLighting.Value;
|
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
// Animating with the number present is distracting.
|
|
|
|
// The number disappearing is hidden by the bright flash.
|
|
|
|
number.FadeOut(flash_in_duration / 2);
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
// The fill layers add too much noise during the explosion animation.
|
|
|
|
// They will be hidden by the additive effects anyway.
|
2022-09-19 15:14:35 +08:00
|
|
|
outerFill.FadeOut(flash_in_duration, Easing.OutQuint);
|
2022-09-19 12:19:56 +08:00
|
|
|
innerFill.FadeOut(flash_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
// The inner-most gradient should actually be resizing, but is only visible for
|
|
|
|
// a few milliseconds before it's hidden by the flash, so it's pointless overhead to bother with it.
|
|
|
|
innerGradient.FadeOut(flash_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
// The border is always white, but after hit it gets coloured by the skin/beatmap's colouring.
|
|
|
|
// A gradient is applied to make the border less prominent over the course of the animation.
|
|
|
|
// Without this, the border dominates the visual presence of the explosion animation in a bad way.
|
|
|
|
border.TransformTo(nameof
|
2022-09-16 18:25:12 +08:00
|
|
|
(BorderColour), ColourInfo.GradientVertical(
|
|
|
|
accentColour.Value.Opacity(0.5f),
|
|
|
|
accentColour.Value.Opacity(0)), fade_out_time);
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
// The outer ring shrinks immediately, but accounts for its thickness so it doesn't overlap the inner
|
|
|
|
// gradient layers.
|
|
|
|
border.ResizeTo(Size * shrink_size + new Vector2(border.BorderThickness), resize_duration, Easing.OutElasticHalf);
|
2022-09-16 18:25:12 +08:00
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
// The outer gradient is resize with a slight delay from the border.
|
|
|
|
// This is to give it a bomb-like effect, with the border "triggering" its animation when getting close.
|
|
|
|
using (BeginDelayedSequence(flash_in_duration / 12))
|
2022-09-22 23:53:52 +08:00
|
|
|
{
|
2022-11-01 17:31:30 +08:00
|
|
|
outerGradient.ResizeTo(OUTER_GRADIENT_SIZE * shrink_size, resize_duration, Easing.OutElasticHalf);
|
2023-01-25 14:50:49 +08:00
|
|
|
|
|
|
|
if (showFlash)
|
|
|
|
{
|
|
|
|
outerGradient
|
|
|
|
.FadeColour(Color4.White, 80)
|
|
|
|
.Then()
|
|
|
|
.FadeOut(flash_in_duration);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outerGradient
|
|
|
|
.FadeColour(Color4.White, flash_in_duration * 8)
|
|
|
|
.FadeOut(flash_in_duration * 2);
|
|
|
|
}
|
2022-09-22 23:53:52 +08:00
|
|
|
}
|
2022-09-15 16:51:10 +08:00
|
|
|
|
2023-01-25 14:50:49 +08:00
|
|
|
if (showFlash)
|
|
|
|
flash.FadeTo(1, flash_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
this.FadeOut(showFlash ? fade_out_time : fade_out_time / 2, Easing.OutQuad);
|
2022-09-15 16:51:10 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
if (drawableObject.IsNotNull())
|
|
|
|
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
}
|
2022-09-16 18:25:12 +08:00
|
|
|
|
|
|
|
private partial class FlashPiece : Circle
|
|
|
|
{
|
|
|
|
public FlashPiece()
|
|
|
|
{
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS);
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
Alpha = 0;
|
|
|
|
Blending = BlendingParameters.Additive;
|
|
|
|
|
2022-09-19 12:19:56 +08:00
|
|
|
// The edge effect provides the fill due to not being rendered hollow.
|
2022-09-16 18:25:12 +08:00
|
|
|
Child.Alpha = 0;
|
|
|
|
Child.AlwaysPresent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2022-09-19 12:19:56 +08:00
|
|
|
|
2022-09-16 18:25:12 +08:00
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Colour,
|
2022-09-19 12:19:56 +08:00
|
|
|
Radius = OsuHitObject.OBJECT_RADIUS * 1.2f,
|
2022-09-16 18:25:12 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2022-09-15 16:51:10 +08:00
|
|
|
}
|
|
|
|
}
|