2017-03-20 17:25:12 +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 15:55:57 +08:00
|
|
|
|
using osu.Game.Modes.Objects.Drawables;
|
|
|
|
|
using osu.Game.Modes.Taiko.Judgements;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|
|
|
|
{
|
2017-03-17 18:24:39 +08:00
|
|
|
|
public abstract class DrawableHit : DrawableTaikoHitObject
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of keys which can result in hits for this HitObject.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected abstract List<Key> HitKeys { get; }
|
|
|
|
|
|
2017-03-24 13:59:59 +08:00
|
|
|
|
private readonly Hit hit;
|
2017-03-17 15:55:57 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether the last key pressed is a valid hit key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool validKeyPressed;
|
|
|
|
|
|
2017-03-24 13:59:59 +08:00
|
|
|
|
protected DrawableHit(Hit hit)
|
|
|
|
|
: base(hit)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
2017-03-24 13:59:59 +08:00
|
|
|
|
this.hit = hit;
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
2017-03-24 13:59:59 +08:00
|
|
|
|
if (Judgement.TimeOffset > hit.HitWindowGood)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double hitOffset = Math.Abs(Judgement.TimeOffset);
|
|
|
|
|
|
2017-03-24 13:59:59 +08:00
|
|
|
|
if (hitOffset > hit.HitWindowMiss)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!validKeyPressed)
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
2017-03-24 13:59:59 +08:00
|
|
|
|
else if (hitOffset < hit.HitWindowGood)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-24 13:59:59 +08:00
|
|
|
|
Judgement.TaikoResult = hitOffset < hit.HitWindowGreat ? TaikoHitResult.Great : TaikoHitResult.Good;
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 22:43:41 +08:00
|
|
|
|
protected override bool HandleKeyPress(Key key)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
if (Judgement.Result.HasValue)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
validKeyPressed = HitKeys.Contains(key);
|
|
|
|
|
|
|
|
|
|
return UpdateJudgement(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|