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;
|
2017-03-17 18:08:50 +08:00
|
|
|
|
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;
|
2017-03-17 18:08:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|
|
|
|
{
|
2017-03-17 18:27:06 +08:00
|
|
|
|
public class DrawableDrumRollTick : DrawableTaikoHitObject
|
2017-03-17 18:08:50 +08:00
|
|
|
|
{
|
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;
|
|
|
|
|
|
2017-03-17 18:08:50 +08:00
|
|
|
|
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-17 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 15:49:39 +08:00
|
|
|
|
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement { SecondHit = tick.IsStrong };
|
2017-03-17 18:08:50 +08:00
|
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
2017-03-28 08:50:43 +08:00
|
|
|
|
if (Judgement.TimeOffset > tick.HitWindow)
|
2017-03-20 17:07:44 +08:00
|
|
|
|
Judgement.Result = HitResult.Miss;
|
2017-03-17 18:08:50 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 08:50:43 +08:00
|
|
|
|
if (Math.Abs(Judgement.TimeOffset) < tick.HitWindow)
|
2017-03-17 18:08:50 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-22 00:51:44 +08:00
|
|
|
|
Judgement.TaikoResult = TaikoHitResult.Great;
|
2017-03-17 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 00:51:53 +08:00
|
|
|
|
protected override void UpdateScrollPosition(double time)
|
2017-03-17 18:08:50 +08:00
|
|
|
|
{
|
2017-03-28 15:49:39 +08:00
|
|
|
|
// Ticks don't move
|
2017-03-17 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 22:54:50 +08:00
|
|
|
|
protected override bool HandleKeyPress(Key key)
|
2017-03-17 18:08:50 +08:00
|
|
|
|
{
|
2017-03-25 22:54:50 +08:00
|
|
|
|
return !Judgement.Result.HasValue && UpdateJudgement(true);
|
2017-03-17 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|