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-09-02 18:58:57 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-09-02 18:58:57 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
2016-09-02 18:58:57 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-04-03 09:20:20 +08:00
|
|
|
|
using System.Linq;
|
2017-09-06 16:02:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
2016-09-02 18:58:57 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.UI
|
2016-09-02 18:58:57 +08:00
|
|
|
|
{
|
2017-09-12 17:19:28 +08:00
|
|
|
|
public class TaikoPlayfield : ScrollingPlayfield
|
2016-09-02 18:58:57 +08:00
|
|
|
|
{
|
2017-03-21 14:09:54 +08:00
|
|
|
|
/// <summary>
|
2017-08-09 12:28:29 +08:00
|
|
|
|
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoRulesetContainer"/>.
|
2017-03-21 14:09:54 +08:00
|
|
|
|
/// </summary>
|
2017-08-03 12:05:07 +08:00
|
|
|
|
public const float DEFAULT_HEIGHT = 178;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The offset from <see cref="left_area_size"/> which the center of the hit target lies at.
|
|
|
|
|
/// </summary>
|
2017-08-03 12:05:07 +08:00
|
|
|
|
public const float HIT_TARGET_OFFSET = 100;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The size of the left area of the playfield. This area contains the input drum.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float left_area_size = 240;
|
|
|
|
|
|
|
|
|
|
|
2017-03-23 13:37:00 +08:00
|
|
|
|
private readonly Container<HitExplosion> hitExplosionContainer;
|
2017-05-24 13:53:28 +08:00
|
|
|
|
private readonly Container<KiaiHitExplosion> kiaiExplosionContainer;
|
2017-03-23 18:00:18 +08:00
|
|
|
|
private readonly Container<DrawableTaikoJudgement> judgementContainer;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
|
2017-08-08 15:01:18 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
2017-03-29 08:02:49 +08:00
|
|
|
|
private readonly Container topLevelHitContainer;
|
2017-05-23 15:42:17 +08:00
|
|
|
|
|
2017-08-21 14:36:01 +08:00
|
|
|
|
private readonly Container barlineContainer;
|
|
|
|
|
|
2017-05-23 15:42:17 +08:00
|
|
|
|
private readonly Container overlayBackgroundContainer;
|
|
|
|
|
private readonly Container backgroundContainer;
|
|
|
|
|
|
|
|
|
|
private readonly Box overlayBackground;
|
|
|
|
|
private readonly Box background;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
|
2016-09-02 18:58:57 +08:00
|
|
|
|
public TaikoPlayfield()
|
2017-08-08 15:01:18 +08:00
|
|
|
|
: base(Axes.X)
|
2016-09-02 18:58:57 +08:00
|
|
|
|
{
|
2017-07-11 21:58:06 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-08-03 06:46:19 +08:00
|
|
|
|
backgroundContainer = new Container
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Name = "Transparent playfield background",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-08-03 06:46:19 +08:00
|
|
|
|
background = new Box
|
2017-05-11 16:18:22 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Alpha = 0.6f
|
2017-05-11 16:18:22 +08:00
|
|
|
|
},
|
2017-08-03 06:46:19 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Right area",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-08-03 12:05:07 +08:00
|
|
|
|
Padding = new MarginPadding { Left = left_area_size },
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-21 14:09:54 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
2017-08-21 14:36:01 +08:00
|
|
|
|
Name = "Masked elements before hit objects",
|
2017-03-21 14:09:54 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
|
|
|
|
Masking = true,
|
2017-03-21 14:09:54 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-08-03 06:46:19 +08:00
|
|
|
|
hitExplosionContainer = new Container<HitExplosion>
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-08-03 12:05:07 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
2017-09-07 21:46:21 +08:00
|
|
|
|
Blending = BlendingMode.Additive,
|
2017-03-21 14:09:54 +08:00
|
|
|
|
},
|
2017-08-03 06:46:19 +08:00
|
|
|
|
new HitTarget
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-03-21 14:09:54 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-08-03 12:05:07 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit
|
2017-08-21 14:36:01 +08:00
|
|
|
|
}
|
2017-04-10 13:28:01 +08:00
|
|
|
|
}
|
2017-03-21 14:09:54 +08:00
|
|
|
|
},
|
2017-08-21 14:36:01 +08:00
|
|
|
|
barlineContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET }
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Hit objects",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
|
|
|
|
Masking = true
|
|
|
|
|
},
|
2017-08-03 06:46:19 +08:00
|
|
|
|
kiaiExplosionContainer = new Container<KiaiHitExplosion>
|
|
|
|
|
{
|
|
|
|
|
Name = "Kiai hit explosions",
|
2017-08-03 12:05:07 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fit,
|
2017-08-03 06:46:19 +08:00
|
|
|
|
Margin = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
2017-09-07 21:46:21 +08:00
|
|
|
|
Blending = BlendingMode.Additive
|
2017-08-03 06:46:19 +08:00
|
|
|
|
},
|
|
|
|
|
judgementContainer = new Container<DrawableTaikoJudgement>
|
|
|
|
|
{
|
|
|
|
|
Name = "Judgements",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Margin = new MarginPadding { Left = HIT_TARGET_OFFSET },
|
2017-09-07 21:46:21 +08:00
|
|
|
|
Blending = BlendingMode.Additive
|
2017-08-03 06:46:19 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
overlayBackgroundContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Left overlay",
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Size = new Vector2(left_area_size, 1),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
overlayBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new InputDrum
|
|
|
|
|
{
|
2017-08-03 06:49:25 +08:00
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Scale = new Vector2(0.9f),
|
|
|
|
|
Margin = new MarginPadding { Right = 20 }
|
2017-08-03 06:46:19 +08:00
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 10,
|
|
|
|
|
Colour = Framework.Graphics.Colour.ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.6f), Color4.Black.Opacity(0)),
|
|
|
|
|
},
|
2017-03-21 14:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-08-03 12:05:07 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Name = "Border",
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
MaskingSmoothness = 0,
|
|
|
|
|
BorderThickness = 2,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-21 14:09:54 +08:00
|
|
|
|
topLevelHitContainer = new Container
|
|
|
|
|
{
|
2017-04-10 13:28:01 +08:00
|
|
|
|
Name = "Top level hit objects",
|
2017-03-21 14:09:54 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-08-09 15:46:08 +08:00
|
|
|
|
|
|
|
|
|
VisibleTimeRange.Value = 6000;
|
2016-09-02 18:58:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-03-21 14:09:54 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2016-09-02 18:58:57 +08:00
|
|
|
|
{
|
2017-05-23 15:42:17 +08:00
|
|
|
|
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
|
|
|
|
overlayBackground.Colour = colours.Gray1;
|
2016-09-02 18:58:57 +08:00
|
|
|
|
|
2017-05-23 15:42:17 +08:00
|
|
|
|
backgroundContainer.BorderColour = colours.Gray1;
|
|
|
|
|
background.Colour = colours.Gray0;
|
2017-03-21 14:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-12 17:19:28 +08:00
|
|
|
|
public override void Add(DrawableHitObject h)
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-09-13 15:17:01 +08:00
|
|
|
|
h.Depth = (float)h.HitObject.StartTime;
|
|
|
|
|
|
2017-03-21 14:09:54 +08:00
|
|
|
|
base.Add(h);
|
2017-03-29 08:01:40 +08:00
|
|
|
|
|
2017-08-21 14:36:01 +08:00
|
|
|
|
var barline = h as DrawableBarLine;
|
|
|
|
|
if (barline != null)
|
|
|
|
|
barlineContainer.Add(barline.CreateProxy());
|
|
|
|
|
|
2017-03-29 08:01:40 +08:00
|
|
|
|
// Swells should be moved at the very top of the playfield when they reach the hit target
|
|
|
|
|
var swell = h as DrawableSwell;
|
|
|
|
|
if (swell != null)
|
|
|
|
|
swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy());
|
2017-03-21 14:09:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
2017-03-21 14:09:54 +08:00
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
if (judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null)
|
2017-03-21 15:33:25 +08:00
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
judgementContainer.Add(new DrawableTaikoJudgement(judgedObject, judgement)
|
|
|
|
|
{
|
2017-09-12 17:43:28 +08:00
|
|
|
|
Anchor = judgement.IsHit ? Anchor.TopLeft : Anchor.CentreLeft,
|
|
|
|
|
Origin = judgement.IsHit ? Anchor.BottomCentre : Anchor.Centre,
|
2017-09-06 16:02:13 +08:00
|
|
|
|
RelativePositionAxes = Axes.X,
|
2017-09-12 17:43:28 +08:00
|
|
|
|
X = judgement.IsHit ? judgedObject.Position.X : 0,
|
2017-09-06 16:02:13 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2017-04-03 09:20:20 +08:00
|
|
|
|
|
2017-09-12 17:43:28 +08:00
|
|
|
|
if (!judgement.IsHit)
|
2017-04-03 09:20:20 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2017-05-24 13:53:28 +08:00
|
|
|
|
bool isRim = judgedObject.HitObject is RimHit;
|
|
|
|
|
|
2017-09-12 17:43:28 +08:00
|
|
|
|
if (judgement is TaikoStrongHitJudgement)
|
|
|
|
|
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == judgedObject)?.VisualiseSecondHit();
|
|
|
|
|
else
|
2017-04-03 09:20:20 +08:00
|
|
|
|
{
|
2017-08-09 16:26:59 +08:00
|
|
|
|
if (judgedObject.X >= -0.05f && judgedObject is DrawableHit)
|
2017-04-03 09:20:20 +08:00
|
|
|
|
{
|
|
|
|
|
// If we're far enough away from the left stage, we should bring outselves in front of it
|
|
|
|
|
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
2017-05-24 13:53:28 +08:00
|
|
|
|
|
2017-09-12 17:43:28 +08:00
|
|
|
|
if (judgedObject.HitObject.Kiai)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject, isRim));
|
2017-04-03 09:20:20 +08:00
|
|
|
|
}
|
2016-09-02 18:58:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-21 14:36:01 +08:00
|
|
|
|
}
|