mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Merge branch 'taiko_drumroll_drawing' into taiko-drawable-generation
Conflicts: osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj
This commit is contained in:
commit
3c21e6538b
@ -75,30 +75,38 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Position = new Vector2(350, 500)
|
||||
});
|
||||
|
||||
Add(new DrumRollCircle(new CirclePiece
|
||||
Add(new DrumRollCirclePiece(new CirclePiece
|
||||
{
|
||||
KiaiMode = kiai
|
||||
})
|
||||
{
|
||||
Width = 250,
|
||||
Width = 0.25f,
|
||||
Position = new Vector2(575, 100)
|
||||
});
|
||||
|
||||
Add(new DrumRollCircle(new StrongCirclePiece
|
||||
Add(new DrumRollCirclePiece(new StrongCirclePiece
|
||||
{
|
||||
KiaiMode = kiai
|
||||
})
|
||||
{
|
||||
Width = 250,
|
||||
Width = 0.25f,
|
||||
Position = new Vector2(575, 300)
|
||||
});
|
||||
}
|
||||
|
||||
private class DrumRollCircle : BaseCircle
|
||||
private class SwellCircle : BaseCircle
|
||||
{
|
||||
public DrumRollCircle(CirclePiece piece)
|
||||
public SwellCircle(CirclePiece piece)
|
||||
: base(piece)
|
||||
{
|
||||
Piece.Add(new TextAwesome
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = SYMBOL_INNER_SIZE,
|
||||
Icon = FontAwesome.fa_asterisk,
|
||||
Shadow = false
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -26,6 +26,8 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
AddButton("Hit!", addHitJudgement);
|
||||
AddButton("Miss :(", addMissJudgement);
|
||||
AddButton("DrumRoll", () => addDrumRoll(false));
|
||||
AddButton("Strong DrumRoll", () => addDrumRoll(true));
|
||||
AddButton("Swell", addSwell);
|
||||
AddButton("Centre", () => addCentreHit(false));
|
||||
AddButton("Strong Centre", () => addCentreHit(true));
|
||||
@ -85,6 +87,18 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
}));
|
||||
}
|
||||
|
||||
private void addDrumRoll(bool strong)
|
||||
{
|
||||
var d = new DrumRoll
|
||||
{
|
||||
StartTime = Time.Current + 1000,
|
||||
Distance = 2000,
|
||||
PreEmpt = 1000,
|
||||
};
|
||||
|
||||
playfield.Add(strong ? new DrawableStrongDrumRoll(d) : new DrawableDrumRoll(d));
|
||||
}
|
||||
|
||||
private void addCentreHit(bool strong)
|
||||
{
|
||||
Hit h = new Hit
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright (c) 2007-2017 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.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Taiko.Judgements;
|
||||
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
@ -11,28 +13,47 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
{
|
||||
private readonly DrumRoll drumRoll;
|
||||
|
||||
private readonly DrumRollCirclePiece circle;
|
||||
|
||||
public DrawableDrumRoll(DrumRoll drumRoll)
|
||||
: base(drumRoll)
|
||||
{
|
||||
this.drumRoll = drumRoll;
|
||||
|
||||
int tickIndex = 0;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Width = (float)(drumRoll.Duration / drumRoll.PreEmpt);
|
||||
|
||||
Add(circle = new DrumRollCirclePiece(CreateCirclePiece()));
|
||||
|
||||
foreach (var tick in drumRoll.Ticks)
|
||||
{
|
||||
var newTick = new DrawableDrumRollTick(tick)
|
||||
{
|
||||
Depth = tickIndex,
|
||||
X = (float)((tick.StartTime - HitObject.StartTime) / drumRoll.Duration)
|
||||
};
|
||||
|
||||
AddNested(newTick);
|
||||
newTick.OnJudgement += onTickJudgement;
|
||||
|
||||
tickIndex++;
|
||||
AddNested(newTick);
|
||||
Add(newTick);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
private void onTickJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> obj)
|
||||
{
|
||||
int countHit = NestedHitObjects.Count(o => o.Judgement.Result == HitResult.Hit);
|
||||
circle.Completion = (float)countHit / NestedHitObjects.Count();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// This is naive, however it's based on the reasoning that the hit target
|
||||
// is further than mid point of the play field, so the time taken to scroll in should always
|
||||
// be greater than the time taken to scroll out to the left of the screen.
|
||||
// Thus, using PreEmpt here is enough for the drum roll to completely scroll out.
|
||||
LifetimeEnd = drumRoll.EndTime + drumRoll.PreEmpt;
|
||||
}
|
||||
|
||||
protected override void CheckJudgement(bool userTriggered)
|
||||
@ -53,5 +74,11 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
else
|
||||
Judgement.Result = HitResult.Miss;
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual CirclePiece CreateCirclePiece() => new CirclePiece();
|
||||
}
|
||||
}
|
||||
|
@ -5,20 +5,67 @@ using OpenTK.Input;
|
||||
using osu.Game.Modes.Taiko.Judgements;
|
||||
using System;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
{
|
||||
public class DrawableDrumRollTick : DrawableTaikoHitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of a tick.
|
||||
/// </summary>
|
||||
private const float tick_size = TaikoHitObject.CIRCLE_RADIUS / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Any tick that is not the first for a drumroll is not filled, but is instead displayed
|
||||
/// as a hollow circle. This is what controls the border width of that circle.
|
||||
/// </summary>
|
||||
private const float tick_border_width = tick_size / 4;
|
||||
|
||||
private readonly DrumRollTick tick;
|
||||
|
||||
private readonly CircularContainer bodyContainer;
|
||||
|
||||
public DrawableDrumRollTick(DrumRollTick tick)
|
||||
: base(tick)
|
||||
{
|
||||
this.tick = tick;
|
||||
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
RelativePositionAxes = Axes.X;
|
||||
Size = new Vector2(tick_size);
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
bodyContainer = new CircularContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = tick_border_width,
|
||||
BorderColour = Color4.White,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = tick.FirstTick ? 1 : 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement();
|
||||
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement { SecondHit = tick.IsStrong };
|
||||
|
||||
protected override void CheckJudgement(bool userTriggered)
|
||||
{
|
||||
@ -38,11 +85,17 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
bodyContainer.ScaleTo(0, 100, EasingTypes.OutQuint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateScrollPosition(double time)
|
||||
{
|
||||
// Drum roll ticks shouldn't move
|
||||
// Ticks don't move
|
||||
}
|
||||
|
||||
protected override bool HandleKeyPress(Key key)
|
||||
|
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes.Taiko.Judgements;
|
||||
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
{
|
||||
public class DrawableStrongDrumRoll : DrawableDrumRoll
|
||||
{
|
||||
public DrawableStrongDrumRoll(DrumRoll drumRoll)
|
||||
: base(drumRoll)
|
||||
{
|
||||
}
|
||||
|
||||
protected override TaikoJudgement CreateJudgement() => new TaikoJudgement { SecondHit = true };
|
||||
|
||||
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece();
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||
: base(hitObject)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.Centre;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
RelativePositionAxes = Axes.X;
|
||||
}
|
||||
|
@ -36,9 +36,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
accentColour = value;
|
||||
|
||||
innerBackground.Colour = AccentColour;
|
||||
|
||||
triangles.ColourLight = AccentColour;
|
||||
triangles.ColourDark = AccentColour.Darken(0.1f);
|
||||
triangles.Colour = AccentColour;
|
||||
|
||||
resetEdgeEffects();
|
||||
}
|
||||
@ -107,6 +105,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourLight = Color4.White,
|
||||
ColourDark = Color4.White.Darken(0.1f)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
{
|
||||
/// <summary>
|
||||
/// A circle piece used for drumrolls.
|
||||
/// </summary>
|
||||
public class DrumRollCirclePiece : Container
|
||||
{
|
||||
private float completion;
|
||||
/// <summary>
|
||||
/// The amount of the drumroll that has been completed, as a percentage of the number
|
||||
/// of ticks in the drumroll. This determines the internal colour of the drumroll.
|
||||
/// </summary>
|
||||
public float Completion
|
||||
{
|
||||
get { return completion; }
|
||||
set
|
||||
{
|
||||
completion = MathHelper.Clamp(value, 0, 1);
|
||||
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
circle.AccentColour = Interpolation.ValueAt(completion, baseColour, finalColour, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly CirclePiece circle;
|
||||
|
||||
private Color4 baseColour;
|
||||
private Color4 finalColour;
|
||||
|
||||
public DrumRollCirclePiece(CirclePiece piece)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
Add(circle = piece);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
circle.AccentColour = baseColour = colours.YellowDark;
|
||||
finalColour = colours.YellowDarker;
|
||||
}
|
||||
}
|
||||
}
|
@ -25,13 +25,13 @@ namespace osu.Game.Modes.Taiko.Objects
|
||||
/// <summary>
|
||||
/// Velocity of the drum roll in positional length units per millisecond.
|
||||
/// </summary>
|
||||
public double Velocity { get; protected set; }
|
||||
public double Velocity { get; protected set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// The distance between ticks of this drumroll.
|
||||
/// <para>Half of this value is the hit window of the ticks.</para>
|
||||
/// </summary>
|
||||
public double TickTimeDistance { get; protected set; }
|
||||
public double TickTimeDistance { get; protected set; } = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Number of drum roll ticks required for a "Good" hit.
|
||||
@ -88,6 +88,7 @@ namespace osu.Game.Modes.Taiko.Objects
|
||||
PreEmpt = PreEmpt,
|
||||
TickTimeDistance = TickTimeDistance,
|
||||
StartTime = t,
|
||||
IsStrong = IsStrong,
|
||||
Sample = new HitSampleInfo
|
||||
{
|
||||
Type = SampleType.None,
|
||||
|
@ -58,6 +58,7 @@
|
||||
<Compile Include="Objects\Drawable\DrawableCentreHit.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableHit.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableStrongCentreHit.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableStrongDrumRoll.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableStrongHit.cs" />
|
||||
<Compile Include="Objects\Drawable\Pieces\RimHitCirclePiece.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableDrumRoll.cs" />
|
||||
@ -65,6 +66,7 @@
|
||||
<Compile Include="Objects\Drawable\DrawableSwell.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableTaikoHitObject.cs" />
|
||||
<Compile Include="Objects\Drawable\Pieces\SwellCirclePiece.cs" />
|
||||
<Compile Include="Objects\Drawable\Pieces\DrumRollCirclePiece.cs" />
|
||||
<Compile Include="Objects\Drawable\Pieces\StrongCirclePiece.cs" />
|
||||
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" />
|
||||
<Compile Include="Objects\DrumRoll.cs" />
|
||||
@ -109,4 +111,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user