1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-30 23:57:25 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs

158 lines
5.3 KiB
C#
Raw Normal View History

2017-03-20 16:02:06 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Backgrounds;
using OpenTK.Graphics;
using osu.Game.Beatmaps.ControlPoints;
using osu.Framework.Audio.Track;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
/// <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 class CirclePiece : TaikoPiece
{
2017-08-03 18:34:35 +08:00
public const float SYMBOL_SIZE = 0.45f;
2017-03-28 09:32:01 +08:00
public const float SYMBOL_BORDER = 8;
2017-05-24 16:15:51 +08:00
private const double pre_beat_transition_time = 80;
2017-03-28 09:32:01 +08:00
/// <summary>
/// The colour of the inner circle and outer glows.
/// </summary>
public override Color4 AccentColour
{
get { return base.AccentColour; }
set
{
base.AccentColour = value;
background.Colour = AccentColour;
resetEdgeEffects();
}
}
/// <summary>
2017-03-24 14:55:25 +08:00
/// Whether Kiai mode effects are enabled for this circle piece.
/// </summary>
public override bool KiaiMode
{
get { return base.KiaiMode; }
set
{
base.KiaiMode = value;
resetEdgeEffects();
}
}
protected override Container<Drawable> Content => content;
private readonly Container content;
private readonly Container background;
public Box FlashBox;
2017-08-03 18:49:50 +08:00
public CirclePiece()
{
EarlyActivationMilliseconds = pre_beat_transition_time;
2017-07-11 21:58:06 +08: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,
2017-09-07 21:46:21 +08:00
Blending = BlendingMode.Additive,
Alpha = 0,
AlwaysPresent = true
}
}
},
content = new Container
{
2017-04-05 12:53:07 +08:00
Name = "Content",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2017-08-03 12:23:12 +08:00
RelativeSizeAxes = Axes.Both,
}
});
}
2017-05-24 16:15:51 +08:00
private const float edge_alpha_kiai = 0.5f;
private void resetEdgeEffects()
{
2017-06-12 11:48:47 +08:00
background.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
2017-05-24 16:15:51 +08:00
Colour = AccentColour.Opacity(KiaiMode ? edge_alpha_kiai : 1f),
Radius = KiaiMode ? 32 : 8
};
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
{
if (!effectPoint.KiaiMode)
return;
if (beatIndex % (int)timingPoint.TimeSignature != 0)
return;
2017-05-24 16:15:51 +08:00
double duration = timingPoint.BeatLength * 2;
2017-07-16 23:28:20 +08:00
background
2017-07-23 02:50:25 +08:00
.FadeEdgeEffectTo(1, pre_beat_transition_time, Easing.OutQuint)
2017-07-16 23:28:20 +08:00
.Then()
2017-07-23 02:50:25 +08:00
.FadeEdgeEffectTo(edge_alpha_kiai, duration, Easing.OutQuint);
}
}
}