1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 09:07:22 +08:00

102 lines
3.1 KiB
C#
Raw Normal View History

// 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.
2018-04-13 18:19:50 +09:00
2022-06-17 16:37:17 +09:00
#nullable disable
using osu.Framework.Allocation;
2018-04-13 18:19:50 +09:00
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
2018-11-20 16:51:59 +09:00
using osuTK;
using osuTK.Graphics;
2018-04-13 18:19:50 +09:00
using osu.Framework.Graphics.Shapes;
using osu.Game.Skinning;
using osu.Framework.Graphics.Containers;
2018-04-13 18:19:50 +09:00
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public partial class DrawableSliderTick : DrawableOsuHitObject
2018-04-13 18:19:50 +09:00
{
public const double ANIM_DURATION = 150;
2024-01-25 19:14:04 +09:00
public const float DEFAULT_TICK_SIZE = 16;
2020-12-03 20:03:39 +09:00
protected DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
2020-11-05 13:51:46 +09:00
private SkinnableDrawable scaleContainer;
2020-11-12 15:59:48 +09:00
public DrawableSliderTick()
: base(null)
{
}
2019-02-28 13:31:40 +09:00
public DrawableSliderTick(SliderTick sliderTick)
: base(sliderTick)
2020-11-05 13:51:46 +09:00
{
}
[BackgroundDependencyLoader]
private void load()
2018-04-13 18:19:50 +09:00
{
2023-09-20 12:48:15 +09:00
Size = OsuHitObject.OBJECT_DIMENSIONS;
2018-04-13 18:19:50 +09:00
Origin = Anchor.Centre;
AddInternal(scaleContainer = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
2018-04-13 18:19:50 +09:00
{
Masking = true,
Origin = Anchor.Centre,
2024-01-25 19:14:04 +09:00
Size = new Vector2(DEFAULT_TICK_SIZE),
BorderThickness = DEFAULT_TICK_SIZE / 4,
BorderColour = Color4.White,
Child = new Box
2018-04-13 18:19:50 +09:00
{
RelativeSizeAxes = Axes.Both,
Colour = AccentColour.Value,
Alpha = 0.3f,
}
})
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
2020-11-12 15:59:48 +09:00
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
}
2020-12-03 19:46:42 +09:00
protected override void OnApply()
{
base.OnApply();
2020-12-03 20:03:39 +09:00
Position = HitObject.Position - DrawableSlider.HitObject.Position;
}
protected override void CheckForResult(bool userTriggered, double timeOffset) => DrawableSlider.SliderInputManager.TryJudgeNestedObject(this, timeOffset);
2018-04-13 18:19:50 +09:00
2019-07-22 15:33:12 +09:00
protected override void UpdateInitialTransforms()
2018-04-13 18:19:50 +09:00
{
this.FadeOut().FadeIn(ANIM_DURATION);
this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf);
}
2020-11-04 16:19:07 +09:00
protected override void UpdateHitStateTransforms(ArmedState state)
2018-04-13 18:19:50 +09:00
{
2020-11-04 16:19:07 +09:00
base.UpdateHitStateTransforms(state);
2019-09-13 18:49:21 +09:00
2018-04-13 18:19:50 +09:00
switch (state)
{
case ArmedState.Idle:
this.Delay(HitObject.TimePreempt).FadeOut();
break;
2019-04-01 12:44:46 +09:00
2018-04-13 18:19:50 +09:00
case ArmedState.Miss:
2024-01-25 19:25:42 +09:00
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
2018-04-13 18:19:50 +09:00
break;
2019-04-01 12:44:46 +09:00
2018-04-13 18:19:50 +09:00
case ArmedState.Hit:
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
this.ScaleTo(Scale * 1.5f, ANIM_DURATION, Easing.Out);
break;
}
}
}
}