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
|
|
|
|
|
|
2017-03-17 16:38:49 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2017-11-02 20:55:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
2017-03-17 16:38:49 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
2017-04-05 09:37:49 +08:00
|
|
|
|
public abstract class DrawableHitStrong : DrawableHit
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The lenience for the second key press.
|
|
|
|
|
/// This does not adjust by map difficulty in ScoreV2 yet.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const double second_hit_window = 30;
|
|
|
|
|
|
|
|
|
|
private double firstHitTime;
|
2017-03-25 22:43:41 +08:00
|
|
|
|
private bool firstKeyHeld;
|
2017-08-20 20:18:21 +08:00
|
|
|
|
private TaikoAction firstHitAction;
|
2017-03-17 16:38:49 +08:00
|
|
|
|
|
2017-04-05 09:37:49 +08:00
|
|
|
|
protected DrawableHitStrong(Hit hit)
|
2017-03-24 13:59:59 +08:00
|
|
|
|
: base(hit)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
2017-11-02 20:55:50 +08:00
|
|
|
|
if (!SecondHitAllowed)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
base.CheckForJudgements(userTriggered, timeOffset);
|
2017-03-17 16:38:49 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!userTriggered)
|
2017-11-02 20:55:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (timeOffset > second_hit_window)
|
|
|
|
|
AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.Miss });
|
2017-03-17 16:38:49 +08:00
|
|
|
|
return;
|
2017-11-02 20:55:50 +08:00
|
|
|
|
}
|
2017-03-17 16:38:49 +08:00
|
|
|
|
|
|
|
|
|
// If we get here, we're assured that the key pressed is the correct secondary key
|
|
|
|
|
|
|
|
|
|
if (Math.Abs(firstHitTime - Time.Current) < second_hit_window)
|
2017-11-02 20:55:50 +08:00
|
|
|
|
AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.Great });
|
2017-03-17 16:38:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-20 20:18:21 +08:00
|
|
|
|
public override bool OnReleased(TaikoAction action)
|
|
|
|
|
{
|
|
|
|
|
if (action == firstHitAction)
|
|
|
|
|
firstKeyHeld = false;
|
|
|
|
|
return base.OnReleased(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
2017-11-02 20:55:50 +08:00
|
|
|
|
if (AllJudged)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-03-25 22:43:41 +08:00
|
|
|
|
// Check if we've handled the first key
|
2017-11-02 20:55:50 +08:00
|
|
|
|
if (!SecondHitAllowed)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
2017-03-25 22:43:41 +08:00
|
|
|
|
// First key hasn't been handled yet, attempt to handle it
|
2017-08-20 20:18:21 +08:00
|
|
|
|
bool handled = base.OnPressed(action);
|
2017-03-17 16:38:49 +08:00
|
|
|
|
|
2017-03-25 22:43:41 +08:00
|
|
|
|
if (handled)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
{
|
|
|
|
|
firstHitTime = Time.Current;
|
2017-08-20 20:18:21 +08:00
|
|
|
|
firstHitAction = action;
|
|
|
|
|
firstKeyHeld = true;
|
2017-03-17 16:38:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 22:43:41 +08:00
|
|
|
|
return handled;
|
2017-03-17 16:38:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-25 22:43:41 +08:00
|
|
|
|
// Don't handle represses of the first key
|
2017-08-20 20:18:21 +08:00
|
|
|
|
if (firstHitAction == action)
|
2017-03-17 16:38:49 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2017-08-20 20:18:21 +08:00
|
|
|
|
// Don't handle invalid hit action presses
|
|
|
|
|
if (!HitActions.Contains(action))
|
2017-03-17 16:38:49 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
2017-03-28 09:02:41 +08:00
|
|
|
|
// Assume the intention was to hit the strong hit with both keys only if the first key is still being held down
|
2017-03-25 22:43:41 +08:00
|
|
|
|
return firstKeyHeld && UpdateJudgement(true);
|
|
|
|
|
}
|
2017-03-17 16:38:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|