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
|
|
|
|
|
|
2018-07-02 11:31:41 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2018-06-08 19:13:24 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-06-08 20:41:20 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2018-06-08 19:13:24 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-06-08 14:16:45 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|
|
|
|
{
|
2018-07-02 11:31:41 +08:00
|
|
|
|
public abstract class DrawableManiaHitObject : DrawableHitObject<ManiaHitObject>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-07-02 11:31:41 +08:00
|
|
|
|
/// The <see cref="ManiaAction"/> which causes this <see cref="DrawableManiaHitObject{TObject}"/> to be hit.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// </summary>
|
2018-07-02 11:31:41 +08:00
|
|
|
|
protected readonly IBindable<ManiaAction> Action = new Bindable<ManiaAction>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
2018-07-02 11:31:41 +08:00
|
|
|
|
protected DrawableManiaHitObject(ManiaHitObject hitObject)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-06-07 13:27:59 +08:00
|
|
|
|
|
2018-07-02 11:31:41 +08:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
|
private void load([CanBeNull] IBindable<ManiaAction> action, [NotNull] IScrollingInfo scrollingInfo)
|
2018-06-08 20:41:20 +08:00
|
|
|
|
{
|
2018-07-02 11:31:41 +08:00
|
|
|
|
if (action != null)
|
|
|
|
|
Action.BindTo(action);
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
Direction.BindTo(scrollingInfo.Direction);
|
|
|
|
|
Direction.BindValueChanged(OnDirectionChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void OnDirectionChanged(ScrollingDirection direction)
|
2018-06-08 19:13:24 +08:00
|
|
|
|
{
|
2018-06-11 15:10:27 +08:00
|
|
|
|
Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
2018-06-08 19:13:24 +08:00
|
|
|
|
}
|
2018-07-02 11:31:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject
|
|
|
|
|
where TObject : ManiaHitObject
|
|
|
|
|
{
|
|
|
|
|
public new readonly TObject HitObject;
|
|
|
|
|
|
|
|
|
|
protected DrawableManiaHitObject(TObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
HitObject = hitObject;
|
|
|
|
|
}
|
2018-06-08 19:13:24 +08:00
|
|
|
|
|
2018-06-07 13:27:59 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(150, Easing.In).Expire();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
this.FadeOut(150, Easing.OutQuint).Expire();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|