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 osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using System.Collections.Generic;
|
2018-06-11 20:45:19 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|
|
|
|
{
|
2018-06-11 20:45:19 +08:00
|
|
|
|
public abstract class DrawableTaikoHitObject : DrawableHitObject<TaikoHitObject>, IKeyBindingHandler<TaikoAction>
|
|
|
|
|
{
|
|
|
|
|
protected readonly Container Content;
|
2018-06-17 16:56:46 +08:00
|
|
|
|
private readonly Container proxiedContent;
|
2018-06-11 20:45:19 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container nonProxiedContent;
|
|
|
|
|
|
|
|
|
|
protected DrawableTaikoHitObject(TaikoHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
InternalChildren = new[]
|
|
|
|
|
{
|
|
|
|
|
nonProxiedContent = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = Content = new Container { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
},
|
2018-11-15 19:26:12 +08:00
|
|
|
|
proxiedContent = new ProxiedContentContainer { RelativeSizeAxes = Axes.Both }
|
2018-06-11 20:45:19 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-06-17 16:56:46 +08:00
|
|
|
|
/// <see cref="proxiedContent"/> is proxied into an upper layer. We don't want to get masked away otherwise <see cref="proxiedContent"/> would too.
|
2018-06-11 20:45:19 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
|
|
|
|
|
|
2018-06-17 23:27:18 +08:00
|
|
|
|
private bool isProxied;
|
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Moves <see cref="Content"/> to a layer proxied above the playfield.
|
2018-06-17 23:27:18 +08:00
|
|
|
|
/// Does nothing is content is already proxied.
|
2018-06-11 20:45:19 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
protected void ProxyContent()
|
|
|
|
|
{
|
2018-06-17 23:27:18 +08:00
|
|
|
|
if (isProxied) return;
|
|
|
|
|
isProxied = true;
|
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
nonProxiedContent.Remove(Content);
|
2018-06-17 16:56:46 +08:00
|
|
|
|
proxiedContent.Add(Content);
|
2018-06-11 20:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Moves <see cref="Content"/> to the normal hitobject layer.
|
2018-06-17 23:27:18 +08:00
|
|
|
|
/// Does nothing is content is not currently proxied.
|
2018-06-11 20:45:19 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
protected void UnproxyContent()
|
|
|
|
|
{
|
2018-06-17 23:27:18 +08:00
|
|
|
|
if (!isProxied) return;
|
|
|
|
|
isProxied = false;
|
|
|
|
|
|
2018-06-17 16:56:46 +08:00
|
|
|
|
proxiedContent.Remove(Content);
|
2018-06-11 20:45:19 +08:00
|
|
|
|
nonProxiedContent.Add(Content);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-17 16:56:46 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a proxy for the content of this <see cref="DrawableTaikoHitObject"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Drawable CreateProxiedContent() => proxiedContent.CreateProxy();
|
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
public abstract bool OnPressed(TaikoAction action);
|
|
|
|
|
public virtual bool OnReleased(TaikoAction action) => false;
|
2018-11-15 19:26:12 +08:00
|
|
|
|
|
|
|
|
|
private class ProxiedContentContainer : Container
|
|
|
|
|
{
|
2018-11-19 16:05:51 +08:00
|
|
|
|
public override double LifetimeStart => Parent?.LifetimeStart ?? base.LifetimeStart;
|
|
|
|
|
public override double LifetimeEnd => Parent?.LifetimeEnd ?? base.LifetimeEnd;
|
2018-11-15 19:26:12 +08:00
|
|
|
|
}
|
2018-06-11 20:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class DrawableTaikoHitObject<TaikoHitType> : DrawableTaikoHitObject
|
2018-04-13 17:19:50 +08:00
|
|
|
|
where TaikoHitType : TaikoHitObject
|
|
|
|
|
{
|
|
|
|
|
public override Vector2 OriginPosition => new Vector2(DrawHeight / 2);
|
|
|
|
|
|
|
|
|
|
protected readonly Vector2 BaseSize;
|
|
|
|
|
|
|
|
|
|
protected readonly TaikoPiece MainPiece;
|
|
|
|
|
|
|
|
|
|
public new TaikoHitType HitObject;
|
|
|
|
|
|
|
|
|
|
protected DrawableTaikoHitObject(TaikoHitType hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
HitObject = hitObject;
|
|
|
|
|
|
|
|
|
|
Anchor = Anchor.CentreLeft;
|
|
|
|
|
Origin = Anchor.Custom;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Size = BaseSize = new Vector2(HitObject.IsStrong ? TaikoHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE);
|
|
|
|
|
|
2018-06-11 20:45:19 +08:00
|
|
|
|
Content.Add(MainPiece = CreateMainPiece());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
MainPiece.KiaiMode = HitObject.Kiai;
|
2018-08-03 15:11:57 +08:00
|
|
|
|
|
|
|
|
|
var strongObject = HitObject.NestedHitObjects.OfType<StrongHitObject>().FirstOrDefault();
|
|
|
|
|
if (strongObject != null)
|
|
|
|
|
{
|
2018-08-14 13:29:49 +08:00
|
|
|
|
var strongHit = CreateStrongHit(strongObject);
|
|
|
|
|
|
|
|
|
|
AddNested(strongHit);
|
|
|
|
|
AddInternal(strongHit);
|
2018-08-03 15:11:57 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Normal and clap samples are handled by the drum
|
|
|
|
|
protected override IEnumerable<SampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != SampleInfo.HIT_NORMAL && s.Name != SampleInfo.HIT_CLAP);
|
|
|
|
|
|
|
|
|
|
protected override string SampleNamespace => "Taiko";
|
|
|
|
|
|
|
|
|
|
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
2018-08-03 15:11:57 +08:00
|
|
|
|
|
2018-08-03 15:56:46 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates the handler for this <see cref="DrawableHitObject"/>'s <see cref="StrongHitObject"/>.
|
|
|
|
|
/// This is only invoked if <see cref="TaikoHitObject.IsStrong"/> is true for <see cref="HitObject"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="hitObject">The strong hitobject.</param>
|
|
|
|
|
/// <returns>The strong hitobject handler.</returns>
|
2018-08-14 13:28:05 +08:00
|
|
|
|
protected virtual DrawableStrongNestedHit CreateStrongHit(StrongHitObject hitObject) => null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|