2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-03-20 17:25:12 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-04-04 11:38:55 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2017-03-28 09:33:23 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-12-31 04:23:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-09-06 16:02:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
2017-03-17 15:55:57 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
2017-04-05 09:01:40 +08:00
|
|
|
|
public abstract class DrawableHit : DrawableTaikoHitObject<Hit>
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of keys which can result in hits for this HitObject.
|
|
|
|
|
/// </summary>
|
2017-08-20 20:18:21 +08:00
|
|
|
|
protected abstract TaikoAction[] HitActions { get; }
|
2017-03-17 15:55:57 +08:00
|
|
|
|
|
2017-11-02 20:55:50 +08:00
|
|
|
|
/// <summary>
|
2017-11-02 20:58:29 +08:00
|
|
|
|
/// Whether a second hit is allowed to be processed. This occurs once this hit object has been hit successfully.
|
2017-11-02 20:55:50 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
protected bool SecondHitAllowed { get; private set; }
|
|
|
|
|
|
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-08-03 12:24:13 +08:00
|
|
|
|
FillMode = FillMode.Fit;
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
if (timeOffset > HitObject.HitWindowGood)
|
|
|
|
|
AddJudgement(new TaikoJudgement { Result = HitResult.Miss });
|
2017-03-17 15:55:57 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
double hitOffset = Math.Abs(timeOffset);
|
2017-03-17 15:55:57 +08:00
|
|
|
|
|
2017-04-05 09:01:40 +08:00
|
|
|
|
if (hitOffset > HitObject.HitWindowMiss)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!validKeyPressed)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new TaikoJudgement { Result = HitResult.Miss });
|
2017-04-05 09:01:40 +08:00
|
|
|
|
else if (hitOffset < HitObject.HitWindowGood)
|
2017-11-02 20:55:50 +08:00
|
|
|
|
{
|
|
|
|
|
AddJudgement(new TaikoJudgement
|
|
|
|
|
{
|
|
|
|
|
Result = hitOffset < HitObject.HitWindowGreat ? HitResult.Great : HitResult.Good,
|
|
|
|
|
Final = !HitObject.IsStrong
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
SecondHitAllowed = true;
|
|
|
|
|
}
|
2017-03-17 15:55:57 +08:00
|
|
|
|
else
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new TaikoJudgement { Result = HitResult.Miss });
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-20 20:18:21 +08:00
|
|
|
|
public override bool OnPressed(TaikoAction action)
|
2017-03-17 15:55:57 +08:00
|
|
|
|
{
|
2017-08-20 20:18:21 +08:00
|
|
|
|
validKeyPressed = HitActions.Contains(action);
|
2017-03-17 15:55:57 +08:00
|
|
|
|
|
2017-12-08 16:42:10 +08:00
|
|
|
|
// Only count this as handled if the new judgement is a hit
|
2017-12-26 13:18:38 +08:00
|
|
|
|
return UpdateJudgement(true);
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
2017-03-28 09:33:23 +08:00
|
|
|
|
|
2017-08-22 19:51:53 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
Size = BaseSize * Parent.RelativeChildSize;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 09:33:23 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
2017-04-07 15:55:51 +08:00
|
|
|
|
var circlePiece = MainPiece as CirclePiece;
|
2017-07-21 23:24:09 +08:00
|
|
|
|
circlePiece?.FlashBox.FinishTransforms();
|
2017-04-07 15:55:51 +08:00
|
|
|
|
|
2017-09-06 16:44:51 +08:00
|
|
|
|
var offset = !AllJudged ? 0 : Time.Current - HitObject.StartTime;
|
2017-09-06 16:02:13 +08:00
|
|
|
|
using (BeginDelayedSequence(HitObject.StartTime - Time.Current + offset, true))
|
2017-03-28 09:33:23 +08:00
|
|
|
|
{
|
2017-11-02 20:21:07 +08:00
|
|
|
|
switch (State.Value)
|
2017-07-17 23:16:15 +08:00
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.HitWindowMiss).Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100)
|
|
|
|
|
.Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
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;
|
|
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
|
Content.ScaleTo(0.8f, gravity_time * 2, Easing.OutQuad);
|
2017-07-17 23:16:15 +08:00
|
|
|
|
|
2017-08-03 12:48:54 +08:00
|
|
|
|
this.MoveToY(-gravity_travel_height, gravity_time, Easing.Out)
|
2017-07-17 23:16:15 +08:00
|
|
|
|
.Then()
|
2017-07-23 02:50:25 +08:00
|
|
|
|
.MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In);
|
2017-07-17 23:16:15 +08:00
|
|
|
|
|
2017-08-03 12:48:54 +08:00
|
|
|
|
this.FadeOut(800)
|
|
|
|
|
.Expire();
|
|
|
|
|
|
2017-07-17 23:16:15 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-28 09:33:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-17 15:55:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|