// Copyright (c) 2007-2017 ppy Pty Ltd . // 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; 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 { public class DrawableDrumRollTick : DrawableTaikoHitObject { /// /// The size of a tick. /// private const float tick_size = TaikoHitObject.CIRCLE_RADIUS / 2; /// /// 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. /// private const float tick_border_width = tick_size / 4; private readonly DrumRollTick tick; private readonly CircularContainer bodyContainer; public DrawableDrumRollTick(DrumRollTick tick) : base(tick) { this.tick = tick; 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 } } } }; } protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement { SecondHit = tick.IsStrong }; protected override void CheckJudgement(bool userTriggered) { if (!userTriggered) { if (Judgement.TimeOffset > tick.HitWindow) Judgement.Result = HitResult.Miss; return; } if (Math.Abs(Judgement.TimeOffset) < tick.HitWindow) { Judgement.Result = HitResult.Hit; Judgement.TaikoResult = TaikoHitResult.Great; } } protected override void UpdateState(ArmedState state) { switch (state) { case ArmedState.Hit: bodyContainer.ScaleTo(0, 100, EasingTypes.OutQuint); break; } } protected override void UpdateScrollPosition(double time) { // Ticks don't move } protected override bool HandleKeyPress(Key key) { return !Judgement.Result.HasValue && UpdateJudgement(true); } } }