2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public abstract class DrawableHit : DrawableTaikoHitObject<Hit>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of keys which can result in hits for this HitObject.
|
|
|
|
|
/// </summary>
|
2018-08-03 15:12:38 +08:00
|
|
|
|
public abstract TaikoAction[] HitActions { get; }
|
2018-08-02 19:36:08 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// <summary>
|
2018-08-03 15:12:38 +08:00
|
|
|
|
/// The action that caused this <see cref="DrawableHit"/> to be hit.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// </summary>
|
2018-08-03 15:12:38 +08:00
|
|
|
|
public TaikoAction? HitAction { get; private set; }
|
|
|
|
|
|
|
|
|
|
private bool validActionPressed;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
protected DrawableHit(Hit hit)
|
|
|
|
|
: base(hit)
|
|
|
|
|
{
|
|
|
|
|
FillMode = FillMode.Fit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (!HitObject.HitWindows.CanBeHit(timeOffset))
|
2018-08-03 15:12:38 +08:00
|
|
|
|
ApplyResult(r => r.Type = HitResult.Miss);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
|
|
|
|
if (result == HitResult.None)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-08-03 15:12:38 +08:00
|
|
|
|
if (!validActionPressed)
|
|
|
|
|
ApplyResult(r => r.Type = HitResult.Miss);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
else
|
2018-08-03 15:12:38 +08:00
|
|
|
|
ApplyResult(r => r.Type = result);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnPressed(TaikoAction action)
|
|
|
|
|
{
|
2018-08-03 15:12:38 +08:00
|
|
|
|
if (Judged)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
validActionPressed = HitActions.Contains(action);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
// Only count this as handled if the new judgement is a hit
|
2018-08-03 15:12:38 +08:00
|
|
|
|
var result = UpdateJudgement(true);
|
|
|
|
|
|
|
|
|
|
if (IsHit)
|
|
|
|
|
HitAction = action;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnReleased(TaikoAction action)
|
|
|
|
|
{
|
|
|
|
|
if (action == HitAction)
|
|
|
|
|
HitAction = null;
|
|
|
|
|
return base.OnReleased(action);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
Size = BaseSize * Parent.RelativeChildSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
var circlePiece = MainPiece as CirclePiece;
|
|
|
|
|
circlePiece?.FlashBox.FinishTransforms();
|
|
|
|
|
|
|
|
|
|
var offset = !AllJudged ? 0 : Time.Current - HitObject.StartTime;
|
|
|
|
|
using (BeginDelayedSequence(HitObject.StartTime - Time.Current + offset, true))
|
|
|
|
|
{
|
|
|
|
|
switch (State.Value)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
2018-08-03 15:12:38 +08:00
|
|
|
|
validActionPressed = false;
|
2018-06-11 19:44:26 +08:00
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
UnproxyContent();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
this.Delay(HitObject.HitWindows.HalfWindowFor(HitResult.Miss)).Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100)
|
|
|
|
|
.Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2018-06-11 20:54:11 +08:00
|
|
|
|
// If we're far enough away from the left stage, we should bring outselves in front of it
|
2018-06-25 14:55:09 +08:00
|
|
|
|
ProxyContent();
|
2018-06-11 20:45:19 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var flash = circlePiece?.FlashBox;
|
|
|
|
|
if (flash != null)
|
|
|
|
|
{
|
|
|
|
|
flash.FadeTo(0.9f);
|
|
|
|
|
flash.FadeOut(300);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float gravity_time = 300;
|
|
|
|
|
const float gravity_travel_height = 200;
|
|
|
|
|
|
|
|
|
|
this.ScaleTo(0.8f, gravity_time * 2, Easing.OutQuad);
|
|
|
|
|
|
|
|
|
|
this.MoveToY(-gravity_travel_height, gravity_time, Easing.Out)
|
|
|
|
|
.Then()
|
|
|
|
|
.MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In);
|
|
|
|
|
|
|
|
|
|
this.FadeOut(800)
|
|
|
|
|
.Expire();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-03 15:12:38 +08:00
|
|
|
|
|
|
|
|
|
protected override DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => new DrawableStrongHit(hitObject, this);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|