// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Input; using System.Collections.Generic; using osu.Framework.Input; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Taiko.Judgements; using System; namespace osu.Game.Modes.Taiko.Objects.Drawable { public class DrawableSwell : DrawableTaikoHitObject { /// /// A list of keys which this HitObject will accept. These are the standard Taiko keys for now. /// These should be moved to bindings later. /// private List validKeys { get; } = new List(new[] { Key.D, Key.F, Key.J, Key.K }); /// /// The amount of times the user has hit this swell. /// private int userHits; private readonly Swell swell; public DrawableSwell(Swell swell) : base(swell) { this.swell = swell; } protected override void CheckJudgement(bool userTriggered) { if (userTriggered) { if (Time.Current < HitObject.StartTime) return; userHits++; if (userHits == swell.RequiredHits) { Judgement.Result = HitResult.Hit; Judgement.TaikoResult = TaikoHitResult.Great; } } else { if (Judgement.TimeOffset < 0) return; if (userHits > swell.RequiredHits / 2) { Judgement.Result = HitResult.Hit; Judgement.TaikoResult = TaikoHitResult.Good; } else Judgement.Result = HitResult.Miss; } } protected override void UpdateState(ArmedState state) { } protected override void UpdateScrollPosition(double time) { base.UpdateScrollPosition(Math.Min(time, HitObject.StartTime)); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (Judgement.Result.HasValue) return false; if (!validKeys.Contains(args.Key)) return false; UpdateJudgement(true); return true; } } }