2017-02-07 12:59:30 +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
|
2016-12-06 17:54:32 +08:00
|
|
|
|
|
2016-11-19 15:19:26 +08:00
|
|
|
|
using System.ComponentModel;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-07-15 00:18:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-09-12 17:00:41 +08:00
|
|
|
|
using System.Linq;
|
2016-11-19 15:19:26 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2016-11-19 15:19:26 +08:00
|
|
|
|
{
|
2017-09-06 17:05:51 +08:00
|
|
|
|
public class DrawableOsuHitObject : DrawableHitObject<OsuHitObject>
|
2016-11-19 15:19:26 +08:00
|
|
|
|
{
|
2016-12-06 17:54:32 +08:00
|
|
|
|
public const float TIME_PREEMPT = 600;
|
|
|
|
|
public const float TIME_FADEIN = 400;
|
2017-12-27 00:25:18 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of milliseconds used to fade in.
|
|
|
|
|
/// </summary>
|
2017-12-30 14:21:25 +08:00
|
|
|
|
public virtual double FadeInDuration { get; set; } = TIME_FADEIN;
|
2017-12-27 00:25:18 +08:00
|
|
|
|
|
|
|
|
|
public override bool IsPresent => base.IsPresent || State.Value == ArmedState.Idle && Time.Current >= HitObject.StartTime - TIME_PREEMPT;
|
2016-11-28 17:40:54 +08:00
|
|
|
|
|
2017-03-23 14:37:16 +08:00
|
|
|
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
2016-11-26 15:51:51 +08:00
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
2017-03-23 14:37:16 +08:00
|
|
|
|
AccentColour = HitObject.ComboColour;
|
2017-07-10 06:01:25 +08:00
|
|
|
|
Alpha = 0;
|
2016-11-26 15:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 12:27:20 +08:00
|
|
|
|
protected sealed override void UpdateState(ArmedState state)
|
2016-11-25 15:26:50 +08:00
|
|
|
|
{
|
2017-11-09 13:04:59 +08:00
|
|
|
|
double transformTime = HitObject.StartTime - TIME_PREEMPT;
|
2016-11-28 17:40:54 +08:00
|
|
|
|
|
2017-11-09 16:04:04 +08:00
|
|
|
|
base.ApplyTransformsAt(transformTime, true);
|
|
|
|
|
base.ClearTransformsAfter(transformTime, true);
|
2017-07-10 06:01:25 +08:00
|
|
|
|
|
2017-11-09 13:04:59 +08:00
|
|
|
|
using (BeginAbsoluteSequence(transformTime, true))
|
|
|
|
|
{
|
2017-04-27 16:37:38 +08:00
|
|
|
|
UpdatePreemptState();
|
2016-11-28 17:40:54 +08:00
|
|
|
|
|
2017-09-12 17:26:56 +08:00
|
|
|
|
using (BeginDelayedSequence(TIME_PREEMPT + (Judgements.FirstOrDefault()?.TimeOffset ?? 0), true))
|
2017-04-27 16:37:38 +08:00
|
|
|
|
UpdateCurrentState(state);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-28 17:40:54 +08:00
|
|
|
|
|
2017-12-30 00:52:28 +08:00
|
|
|
|
protected virtual void UpdatePreemptState() => this.FadeIn(FadeInDuration);
|
2016-11-28 17:40:54 +08:00
|
|
|
|
|
2017-07-10 06:01:25 +08:00
|
|
|
|
protected virtual void UpdateCurrentState(ArmedState state)
|
2016-11-28 17:40:54 +08:00
|
|
|
|
{
|
2016-11-25 15:26:50 +08:00
|
|
|
|
}
|
2017-08-18 15:04:01 +08:00
|
|
|
|
|
2017-11-09 16:04:04 +08:00
|
|
|
|
// Todo: At some point we need to move these to DrawableHitObject after ensuring that all other Rulesets apply
|
|
|
|
|
// transforms in the same way and don't rely on them not being cleared
|
|
|
|
|
public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null) { }
|
|
|
|
|
public override void ApplyTransformsAt(double time, bool propagateChildren = false) { }
|
|
|
|
|
|
2017-08-18 18:02:08 +08:00
|
|
|
|
private OsuInputManager osuActionInputManager;
|
|
|
|
|
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
2016-11-19 15:19:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 15:26:50 +08:00
|
|
|
|
public enum ComboResult
|
2016-11-19 15:19:26 +08:00
|
|
|
|
{
|
|
|
|
|
[Description(@"")]
|
|
|
|
|
None,
|
|
|
|
|
[Description(@"Good")]
|
|
|
|
|
Good,
|
|
|
|
|
[Description(@"Amazing")]
|
|
|
|
|
Perfect
|
|
|
|
|
}
|
|
|
|
|
}
|