1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-16 04:32:57 +08:00

Make drumroll body colour depending on completion.

This commit is contained in:
smoogipooo 2017-03-29 09:38:24 +09:00
parent 2a018e708d
commit 1b291ec1a1
3 changed files with 41 additions and 5 deletions

View File

@ -13,6 +13,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{
private readonly DrumRoll drumRoll;
private readonly DrumRollCirclePiece circle;
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
@ -21,7 +23,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
RelativeSizeAxes = Axes.X;
Width = (float)(drumRoll.Duration / drumRoll.PreEmpt);
Add(new DrumRollCirclePiece(CreateCirclePiece()));
Add(circle = new DrumRollCirclePiece(CreateCirclePiece()));
foreach (var tick in drumRoll.Ticks)
{
@ -30,11 +32,19 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
X = (float)((tick.StartTime - HitObject.StartTime) / drumRoll.Duration)
};
newTick.OnJudgement += onTickJudgement;
AddNested(newTick);
Add(newTick);
}
}
private void onTickJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> obj)
{
int countHit = NestedHitObjects.Count(o => o.Judgement.Result == HitResult.Hit);
circle.Completion = (float)countHit / NestedHitObjects.Count();
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -36,9 +36,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
accentColour = value;
innerBackground.Colour = AccentColour;
triangles.ColourLight = AccentColour;
triangles.ColourDark = AccentColour.Darken(0.1f);
triangles.Colour = AccentColour;
resetEdgeEffects();
}
@ -107,6 +105,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
ColourLight = Color4.White,
ColourDark = Color4.White.Darken(0.1f)
}
}
},

View File

@ -1,9 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
@ -13,8 +16,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
/// </summary>
public class DrumRollCirclePiece : Container
{
private float completion;
/// <summary>
/// The amount of the drumroll that has been completed, as a percentage of the number
/// of ticks in the drumroll. This determines the internal colour of the drumroll.
/// </summary>
public float Completion
{
get { return completion; }
set
{
completion = MathHelper.Clamp(value, 0, 1);
if (!IsLoaded)
return;
circle.AccentColour = Interpolation.ValueAt(completion, baseColour, finalColour, 0, 1);
}
}
private readonly CirclePiece circle;
private Color4 baseColour;
private Color4 finalColour;
public DrumRollCirclePiece(CirclePiece piece)
{
RelativeSizeAxes = Axes.X;
@ -25,7 +50,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
circle.AccentColour = colours.YellowDark;
circle.AccentColour = baseColour = colours.YellowDark;
finalColour = colours.YellowDarker;
}
}
}