1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 00:02:56 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonReverseArrow.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

119 lines
4.3 KiB
C#
Raw Normal View History

2022-09-19 14:39:08 +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 System;
2022-09-19 14:39:08 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
2023-10-02 21:28:33 +08:00
using osu.Framework.Extensions.ObjectExtensions;
2022-09-19 14:39:08 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2022-09-19 14:39:08 +08:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
2022-09-19 14:39:08 +08:00
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonReverseArrow : CompositeDrawable
2022-09-19 14:39:08 +08:00
{
private DrawableSliderRepeat drawableRepeat { get; set; } = null!;
2022-09-19 14:39:08 +08:00
private Bindable<Color4> accentColour = null!;
private SpriteIcon icon = null!;
private Container main = null!;
2023-10-02 17:26:35 +08:00
private Sprite side = null!;
2022-09-19 14:39:08 +08:00
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject, TextureStore textures)
2022-09-19 14:39:08 +08:00
{
drawableRepeat = (DrawableSliderRepeat)drawableObject;
2022-09-19 14:39:08 +08:00
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2023-09-20 11:48:15 +08:00
Size = OsuHitObject.OBJECT_DIMENSIONS;
2022-09-19 14:39:08 +08:00
InternalChildren = new Drawable[]
{
main = new Container
2022-09-19 14:39:08 +08:00
{
RelativeSizeAxes = Axes.Both,
2022-09-19 14:39:08 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Circle
{
Size = new Vector2(40, 20),
Colour = Color4.White,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
icon = new SpriteIcon
{
Icon = FontAwesome.Solid.AngleDoubleRight,
Size = new Vector2(16),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
}
2022-09-19 14:39:08 +08:00
},
2023-10-02 17:26:35 +08:00
side = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = textures.Get("Gameplay/osu/repeat-edge-piece"),
Size = new Vector2(ArgonMainCirclePiece.OUTER_GRADIENT_SIZE),
}
2022-09-19 14:39:08 +08:00
};
accentColour = drawableRepeat.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(accent => icon.Colour = accent.NewValue.Darken(4), true);
drawableRepeat.ApplyCustomUpdateState += updateStateTransforms;
2022-09-19 14:39:08 +08:00
}
private void updateStateTransforms(DrawableHitObject hitObject, ArmedState state)
{
const float move_distance = -12;
const double move_out_duration = 35;
const double move_in_duration = 250;
const double total = 300;
switch (state)
2023-10-02 17:26:35 +08:00
{
case ArmedState.Idle:
main.ScaleTo(1.3f, move_out_duration, Easing.Out)
.Then()
.ScaleTo(1f, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
side
.MoveToX(move_distance, move_out_duration, Easing.Out)
.Then()
.MoveToX(0, move_in_duration, Easing.Out)
.Loop(total - (move_in_duration + move_out_duration));
break;
case ArmedState.Hit:
double animDuration = Math.Min(300, drawableRepeat.HitObject.SpanDuration);
this.ScaleTo(1.5f, animDuration, Easing.Out);
break;
2023-10-02 17:26:35 +08:00
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
2023-10-02 21:28:33 +08:00
if (drawableRepeat.IsNotNull())
drawableRepeat.ApplyCustomUpdateState -= updateStateTransforms;
}
2022-09-19 14:39:08 +08:00
}
}