1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:07:24 +08:00
osu-lazer/osu.Game.Modes.Taiko/Objects/Drawable/DrawableDrumRollTick.cs

107 lines
3.4 KiB
C#
Raw Normal View History

2017-03-20 17:24:28 +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 OpenTK.Input;
using osu.Game.Modes.Taiko.Judgements;
using System;
using osu.Game.Modes.Objects.Drawables;
2017-03-28 15:49:39 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transforms;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
2017-03-17 18:27:06 +08:00
public class DrawableDrumRollTick : DrawableTaikoHitObject
{
2017-03-28 15:49:39 +08:00
/// <summary>
/// The size of a tick.
/// </summary>
2017-03-28 16:10:01 +08:00
private const float tick_size = TaikoHitObject.CIRCLE_RADIUS / 2;
2017-03-28 15:49:39 +08:00
/// <summary>
/// Any tick that is not the first is not filled, but is displayed
/// as a circle instead. This is what controls the stroke width of that circle.
/// </summary>
2017-03-28 16:10:01 +08:00
private const float tick_border_width = tick_size / 4;
2017-03-28 15:49:39 +08:00
2017-03-23 18:43:49 +08:00
private readonly DrumRollTick tick;
2017-03-17 18:27:06 +08:00
2017-03-28 15:49:39 +08:00
private readonly CircularContainer bodyContainer;
public DrawableDrumRollTick(DrumRollTick tick)
: base(tick)
{
2017-03-17 18:27:06 +08:00
this.tick = tick;
2017-03-28 15:49:39 +08:00
Anchor = Anchor.CentreLeft;
Origin = Anchor.Centre;
RelativePositionAxes = Axes.X;
Size = new Vector2(tick_size);
Children = new[]
{
bodyContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = tick_border_width,
BorderColour = Color4.White,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = tick.FirstTick ? 1 : 0,
AlwaysPresent = true
}
}
}
};
}
2017-03-28 15:49:39 +08:00
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement { SecondHit = tick.IsStrong };
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > tick.HitWindow)
2017-03-20 17:07:44 +08:00
Judgement.Result = HitResult.Miss;
return;
}
if (Math.Abs(Judgement.TimeOffset) < tick.HitWindow)
{
Judgement.Result = HitResult.Hit;
2017-03-22 00:51:44 +08:00
Judgement.TaikoResult = TaikoHitResult.Great;
}
}
2017-03-23 18:43:00 +08:00
protected override void UpdateState(ArmedState state)
{
2017-03-28 15:49:39 +08:00
switch (state)
{
case ArmedState.Hit:
bodyContainer.ScaleTo(0, 100, EasingTypes.OutQuint);
break;
}
2017-03-23 18:43:00 +08:00
}
protected override void UpdateScrollPosition(double time)
{
2017-03-28 15:49:39 +08:00
// Ticks don't move
}
protected override bool HandleKeyPress(Key key)
{
return !Judgement.Result.HasValue && UpdateJudgement(true);
}
}
}