2019-07-24 17:50:57 +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;
|
2022-11-09 12:36:52 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2019-07-24 17:50:57 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-12-04 19:21:53 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-07-24 17:50:57 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-04 19:21:53 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
2019-07-24 17:50:57 +08:00
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class MainCirclePiece : CompositeDrawable
|
2019-07-24 17:50:57 +08:00
|
|
|
{
|
|
|
|
private readonly CirclePiece circle;
|
|
|
|
private readonly RingPiece ring;
|
|
|
|
private readonly FlashPiece flash;
|
|
|
|
private readonly ExplodePiece explode;
|
|
|
|
private readonly NumberPiece number;
|
|
|
|
private readonly GlowPiece glow;
|
|
|
|
|
2019-09-26 15:57:58 +08:00
|
|
|
public MainCirclePiece()
|
2019-07-24 17:50:57 +08:00
|
|
|
{
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
glow = new GlowPiece(),
|
|
|
|
circle = new CirclePiece(),
|
2019-09-26 15:57:58 +08:00
|
|
|
number = new NumberPiece(),
|
2019-07-24 17:50:57 +08:00
|
|
|
ring = new RingPiece(),
|
|
|
|
flash = new FlashPiece(),
|
|
|
|
explode = new ExplodePiece(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-09-26 15:57:58 +08:00
|
|
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2020-11-03 16:49:48 +08:00
|
|
|
[Resolved]
|
2022-11-09 12:36:52 +08:00
|
|
|
private DrawableHitObject drawableObject { get; set; } = null!;
|
2020-11-03 16:49:48 +08:00
|
|
|
|
2019-07-24 17:50:57 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-11-03 16:49:48 +08:00
|
|
|
private void load()
|
2019-07-24 17:50:57 +08:00
|
|
|
{
|
2020-11-05 13:40:48 +08:00
|
|
|
var drawableOsuObject = (DrawableOsuHitObject)drawableObject;
|
2019-09-26 15:57:58 +08:00
|
|
|
|
2019-07-24 17:50:57 +08:00
|
|
|
accentColour.BindTo(drawableObject.AccentColour);
|
2020-11-11 18:01:12 +08:00
|
|
|
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2019-07-24 17:50:57 +08:00
|
|
|
accentColour.BindValueChanged(colour =>
|
|
|
|
{
|
|
|
|
explode.Colour = colour.NewValue;
|
|
|
|
glow.Colour = colour.NewValue;
|
|
|
|
circle.Colour = colour.NewValue;
|
|
|
|
}, true);
|
2019-09-26 15:57:58 +08:00
|
|
|
|
|
|
|
indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);
|
2021-06-02 10:32:24 +08:00
|
|
|
|
2021-06-09 15:14:55 +08:00
|
|
|
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
updateStateTransforms(drawableObject, drawableObject.State.Value);
|
2019-07-24 17:50:57 +08:00
|
|
|
}
|
|
|
|
|
2021-06-09 15:14:55 +08:00
|
|
|
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
2019-07-24 17:50:57 +08:00
|
|
|
{
|
2021-03-23 18:22:37 +08:00
|
|
|
using (BeginAbsoluteSequence(drawableObject.StateUpdateTime))
|
2020-11-03 16:49:48 +08:00
|
|
|
glow.FadeOut(400);
|
|
|
|
|
2021-03-23 18:22:37 +08:00
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
{
|
2021-06-09 15:14:55 +08:00
|
|
|
switch (state)
|
2020-11-03 16:49:48 +08:00
|
|
|
{
|
|
|
|
case ArmedState.Hit:
|
|
|
|
const double flash_in = 40;
|
|
|
|
const double flash_out = 100;
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2020-11-03 16:49:48 +08:00
|
|
|
flash.FadeTo(0.8f, flash_in)
|
|
|
|
.Then()
|
|
|
|
.FadeOut(flash_out);
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2020-11-03 16:49:48 +08:00
|
|
|
explode.FadeIn(flash_in);
|
|
|
|
this.ScaleTo(1.5f, 400, Easing.OutQuad);
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2021-06-02 10:46:28 +08:00
|
|
|
using (BeginDelayedSequence(flash_in))
|
2020-11-03 16:49:48 +08:00
|
|
|
{
|
|
|
|
// after the flash, we can hide some elements that were behind it
|
|
|
|
ring.FadeOut();
|
|
|
|
circle.FadeOut();
|
|
|
|
number.FadeOut();
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2020-11-03 16:49:48 +08:00
|
|
|
this.FadeOut(800);
|
|
|
|
}
|
2019-07-24 17:50:57 +08:00
|
|
|
|
2020-11-03 16:49:48 +08:00
|
|
|
break;
|
|
|
|
}
|
2019-07-24 17:50:57 +08:00
|
|
|
}
|
|
|
|
}
|
2021-06-09 15:14:55 +08:00
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
2022-11-09 12:36:52 +08:00
|
|
|
if (drawableObject.IsNotNull())
|
2021-06-09 15:14:55 +08:00
|
|
|
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
}
|
2019-07-24 17:50:57 +08:00
|
|
|
}
|
|
|
|
}
|