Add action support to taiko

This commit is contained in:
Dean Herbert
2017-08-20 21:18:21 +09:00
parent a2c184ea43
commit ff84eb219b
10 changed files with 50 additions and 61 deletions

View File

@ -6,7 +6,6 @@ using System.Linq;
using osu.Framework.Input;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Judgements;
using OpenTK.Input;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private double firstHitTime;
private bool firstKeyHeld;
private Key firstHitKey;
private TaikoAction firstHitAction;
protected DrawableHitStrong(Hit hit)
: base(hit)
@ -46,18 +45,26 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Judgement.SecondHit = true;
}
protected override bool HandleKeyPress(Key key)
public override bool OnReleased(TaikoAction action)
{
if (action == firstHitAction)
firstKeyHeld = false;
return base.OnReleased(action);
}
public override bool OnPressed(TaikoAction action)
{
// Check if we've handled the first key
if (Judgement.Result == HitResult.None)
{
// First key hasn't been handled yet, attempt to handle it
bool handled = base.HandleKeyPress(key);
bool handled = base.OnPressed(action);
if (handled)
{
firstHitTime = Time.Current;
firstHitKey = key;
firstHitAction = action;
firstKeyHeld = true;
}
return handled;
@ -68,22 +75,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return false;
// Don't handle represses of the first key
if (firstHitKey == key)
if (firstHitAction == action)
return false;
// Don't handle invalid hit key presses
if (!HitKeys.Contains(key))
// Don't handle invalid hit action presses
if (!HitActions.Contains(action))
return false;
// Assume the intention was to hit the strong hit with both keys only if the first key is still being held down
return firstKeyHeld && UpdateJudgement(true);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
firstKeyHeld = state.Keyboard.Keys.Contains(firstHitKey);
return base.OnKeyDown(state, args);
}
}
}