osu/osu.Game.Rulesets.Taiko/Skinning/Default/CirclePiece.cs

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

168 lines
5.3 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 09:19:50 +00:00
2020-06-23 04:49:18 +00:00
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2020-12-07 03:30:25 +00:00
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
2020-12-07 03:30:25 +00:00
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
2020-12-07 03:30:25 +00:00
using osuTK.Graphics;
2018-04-13 09:19:50 +00:00
2020-12-07 03:30:25 +00:00
namespace osu.Game.Rulesets.Taiko.Skinning.Default
{
/// <summary>
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
/// <para>
/// Note that this can actually be non-circle if the width is changed. See <see cref="ElongatedCirclePiece"/>
/// for a usage example.
/// </para>
/// </summary>
public abstract class CirclePiece : BeatSyncedContainer, IHasAccentColour
{
2017-08-03 10:34:35 +00:00
public const float SYMBOL_SIZE = 0.45f;
2017-03-28 01:32:01 +00:00
public const float SYMBOL_BORDER = 8;
2017-05-24 08:15:51 +00:00
private const double pre_beat_transition_time = 80;
2018-04-13 09:19:50 +00:00
private Color4 accentColour;
/// <summary>
/// The colour of the inner circle and outer glows.
/// </summary>
public Color4 AccentColour
{
get => accentColour;
set
{
accentColour = value;
2018-04-13 09:19:50 +00:00
background.Colour = AccentColour;
2018-04-13 09:19:50 +00:00
resetEdgeEffects();
}
}
2018-04-13 09:19:50 +00:00
private bool kiaiMode;
/// <summary>
2017-03-24 06:55:25 +00:00
/// Whether Kiai mode effects are enabled for this circle piece.
/// </summary>
public bool KiaiMode
{
get => kiaiMode;
set
{
kiaiMode = value;
2018-04-13 09:19:50 +00:00
resetEdgeEffects();
}
}
2018-04-13 09:19:50 +00:00
protected override Container<Drawable> Content => content;
2018-04-13 09:19:50 +00:00
private readonly Container content;
2018-04-13 09:19:50 +00:00
private readonly Container background;
2018-04-13 09:19:50 +00:00
public Box FlashBox;
2018-04-13 09:19:50 +00:00
2020-04-12 08:40:22 +00:00
protected CirclePiece()
{
2020-04-11 04:41:14 +00:00
RelativeSizeAxes = Axes.Both;
EarlyActivationMilliseconds = pre_beat_transition_time;
2018-04-13 09:19:50 +00:00
2017-07-11 13:58:06 +00:00
AddRangeInternal(new Drawable[]
{
background = new CircularContainer
{
Name = "Background",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
},
new Triangles
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
ColourLight = Color4.White,
ColourDark = Color4.White.Darken(0.1f)
}
}
},
new CircularContainer
{
Name = "Ring",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
BorderThickness = 8,
BorderColour = Color4.White,
Masking = true,
Children = new[]
{
FlashBox = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
2019-08-21 04:29:50 +00:00
Blending = BlendingParameters.Additive,
Alpha = 0,
AlwaysPresent = true
}
}
},
content = new Container
{
2017-04-05 04:53:07 +00:00
Name = "Content",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-08-03 04:23:12 +00:00
RelativeSizeAxes = Axes.Both,
}
});
}
2018-04-13 09:19:50 +00:00
2017-05-24 08:15:51 +00:00
private const float edge_alpha_kiai = 0.5f;
2018-04-13 09:19:50 +00:00
private void resetEdgeEffects()
{
2017-06-12 03:48:47 +00:00
background.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
2017-05-24 08:15:51 +00:00
Colour = AccentColour.Opacity(KiaiMode ? edge_alpha_kiai : 1f),
Radius = KiaiMode ? 32 : 8
};
}
2018-04-13 09:19:50 +00:00
2020-06-23 04:49:18 +00:00
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
if (!effectPoint.KiaiMode)
return;
2018-04-13 09:19:50 +00:00
if (beatIndex % timingPoint.TimeSignature.Numerator != 0)
return;
2018-04-13 09:19:50 +00:00
2017-05-24 08:15:51 +00:00
double duration = timingPoint.BeatLength * 2;
2018-04-13 09:19:50 +00:00
2017-07-16 15:28:20 +00:00
background
2017-07-22 18:50:25 +00:00
.FadeEdgeEffectTo(1, pre_beat_transition_time, Easing.OutQuint)
2017-07-16 15:28:20 +00:00
.Then()
2017-07-22 18:50:25 +00:00
.FadeEdgeEffectTo(edge_alpha_kiai, duration, Easing.OutQuint);
}
}
2018-01-05 11:21:19 +00:00
}