2017-03-17 17:54:44 +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;
|
|
|
|
|
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
|
|
|
|
|
{
|
2017-03-17 18:25:55 +08:00
|
|
|
|
public class DrawableBash : DrawableTaikoHitObject
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of keys which this HitObject will accept. These are the standard Taiko keys for now.
|
|
|
|
|
/// These should be moved to bindings later.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<Key> validKeys { get; } = new List<Key>(new[] { Key.D, Key.F, Key.J, Key.K });
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The amount of times the user has hit this bash.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int userHits;
|
|
|
|
|
|
2017-03-17 18:25:55 +08:00
|
|
|
|
private Bash bash;
|
|
|
|
|
|
2017-03-17 17:59:21 +08:00
|
|
|
|
public DrawableBash(Bash bash)
|
|
|
|
|
: base(bash)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
2017-03-17 18:25:55 +08:00
|
|
|
|
this.bash = bash;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (Time.Current < HitObject.StartTime)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
userHits++;
|
|
|
|
|
|
2017-03-17 18:25:55 +08:00
|
|
|
|
if (userHits == bash.RequiredHits)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-22 00:55:31 +08:00
|
|
|
|
Judgement.TaikoResult = TaikoHitResult.Great;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Judgement.TimeOffset < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-03-17 18:25:55 +08:00
|
|
|
|
if (userHits > bash.RequiredHits / 2)
|
2017-03-17 17:54:44 +08:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-22 00:55:31 +08:00
|
|
|
|
Judgement.TaikoResult = TaikoHitResult.Good;
|
2017-03-17 17:54:44 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
UpdateScrollPosition(Math.Min(Time.Current, 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|