mirror of
https://github.com/ppy/osu.git
synced 2025-01-16 01:42:58 +08:00
Merge pull request #567 from smoogipooo/taiko_swell_drawing
Taiko swell drawing
This commit is contained in:
commit
2cb64cbf52
@ -4,7 +4,6 @@
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -76,20 +75,16 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new SwellCircle(new CirclePiece
|
Add(new CirclePiece
|
||||||
{
|
{
|
||||||
KiaiMode = kiai
|
Position = new Vector2(100, 500),
|
||||||
})
|
Width = 0,
|
||||||
{
|
AccentColour = Color4.Orange,
|
||||||
Position = new Vector2(100, 500)
|
KiaiMode = kiai,
|
||||||
});
|
Children = new[]
|
||||||
|
{
|
||||||
Add(new SwellCircle(new StrongCirclePiece
|
new SwellSymbolPiece()
|
||||||
{
|
}
|
||||||
KiaiMode = kiai
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Position = new Vector2(350, 500)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Add(new DrumRollCircle(new CirclePiece
|
Add(new DrumRollCircle(new CirclePiece
|
||||||
@ -111,28 +106,6 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SwellCircle : BaseCircle
|
|
||||||
{
|
|
||||||
public SwellCircle(CirclePiece piece)
|
|
||||||
: base(piece)
|
|
||||||
{
|
|
||||||
Piece.Add(new TextAwesome
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
TextSize = CirclePiece.SYMBOL_INNER_SIZE,
|
|
||||||
Icon = FontAwesome.fa_asterisk,
|
|
||||||
Shadow = false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
Piece.AccentColour = colours.YellowDark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DrumRollCircle : BaseCircle
|
private class DrumRollCircle : BaseCircle
|
||||||
{
|
{
|
||||||
public DrumRollCircle(CirclePiece piece)
|
public DrumRollCircle(CirclePiece piece)
|
||||||
|
@ -26,6 +26,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
|
|
||||||
AddButton("Hit!", addHitJudgement);
|
AddButton("Hit!", addHitJudgement);
|
||||||
AddButton("Miss :(", addMissJudgement);
|
AddButton("Miss :(", addMissJudgement);
|
||||||
|
AddButton("Swell", addSwell);
|
||||||
AddButton("Centre", () => addCentreHit(false));
|
AddButton("Centre", () => addCentreHit(false));
|
||||||
AddButton("Strong Centre", () => addCentreHit(true));
|
AddButton("Strong Centre", () => addCentreHit(true));
|
||||||
AddButton("Rim", () => addRimHit(false));
|
AddButton("Rim", () => addRimHit(false));
|
||||||
@ -74,6 +75,16 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addSwell()
|
||||||
|
{
|
||||||
|
playfield.Add(new DrawableSwell(new Swell
|
||||||
|
{
|
||||||
|
StartTime = Time.Current + 1000,
|
||||||
|
EndTime = Time.Current + 5000,
|
||||||
|
PreEmpt = 1000
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
private void addCentreHit(bool strong)
|
private void addCentreHit(bool strong)
|
||||||
{
|
{
|
||||||
Hit h = new Hit
|
Hit h = new Hit
|
||||||
|
@ -1,37 +1,160 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.Taiko.Judgements;
|
using osu.Game.Modes.Taiko.Judgements;
|
||||||
|
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
namespace osu.Game.Modes.Taiko.Objects.Drawable
|
||||||
{
|
{
|
||||||
public class DrawableSwell : DrawableTaikoHitObject
|
public class DrawableSwell : DrawableTaikoHitObject
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when the swell has reached the hit target, i.e. when CurrentTime >= StartTime.
|
||||||
|
/// This is only ever invoked once.
|
||||||
|
/// </summary>
|
||||||
|
public event Action OnStart;
|
||||||
|
|
||||||
|
private const float target_ring_thick_border = 1.4f;
|
||||||
|
private const float target_ring_thin_border = 1f;
|
||||||
|
private const float target_ring_scale = 5f;
|
||||||
|
private const float inner_ring_alpha = 0.65f;
|
||||||
|
|
||||||
|
private readonly Swell swell;
|
||||||
|
|
||||||
|
private readonly Container bodyContainer;
|
||||||
|
private readonly CircularContainer targetRing;
|
||||||
|
private readonly CircularContainer expandingRing;
|
||||||
|
|
||||||
|
private readonly CirclePiece circlePiece;
|
||||||
|
|
||||||
|
private readonly Key[] rimKeys = { Key.D, Key.K };
|
||||||
|
private readonly Key[] centreKeys = { Key.F, Key.J };
|
||||||
|
private Key[] lastKeySet;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of times the user has hit this swell.
|
/// The amount of times the user has hit this swell.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int userHits;
|
private int userHits;
|
||||||
|
|
||||||
private readonly Swell swell;
|
private bool hasStarted;
|
||||||
|
private readonly SwellSymbolPiece symbol;
|
||||||
|
|
||||||
public DrawableSwell(Swell swell)
|
public DrawableSwell(Swell swell)
|
||||||
: base(swell)
|
: base(swell)
|
||||||
{
|
{
|
||||||
this.swell = swell;
|
this.swell = swell;
|
||||||
|
|
||||||
|
Children = new Framework.Graphics.Drawable[]
|
||||||
|
{
|
||||||
|
bodyContainer = new Container
|
||||||
|
{
|
||||||
|
Children = new Framework.Graphics.Drawable[]
|
||||||
|
{
|
||||||
|
expandingRing = new CircularContainer
|
||||||
|
{
|
||||||
|
Name = "Expanding ring",
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Alpha = 0,
|
||||||
|
Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2),
|
||||||
|
BlendingMode = BlendingMode.Additive,
|
||||||
|
Masking = true,
|
||||||
|
Children = new []
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = inner_ring_alpha,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
targetRing = new CircularContainer
|
||||||
|
{
|
||||||
|
Name = "Target ring (thick border)",
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2),
|
||||||
|
Masking = true,
|
||||||
|
BorderThickness = target_ring_thick_border,
|
||||||
|
BlendingMode = BlendingMode.Additive,
|
||||||
|
Children = new Framework.Graphics.Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
AlwaysPresent = true
|
||||||
|
},
|
||||||
|
new CircularContainer
|
||||||
|
{
|
||||||
|
Name = "Target ring (thin border)",
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
BorderThickness = target_ring_thin_border,
|
||||||
|
BorderColour = Color4.White,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
AlwaysPresent = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
circlePiece = new CirclePiece
|
||||||
|
{
|
||||||
|
Children = new []
|
||||||
|
{
|
||||||
|
symbol = new SwellSymbolPiece()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
circlePiece.AccentColour = colours.YellowDark;
|
||||||
|
expandingRing.Colour = colours.YellowLight;
|
||||||
|
targetRing.BorderColour = colours.YellowDark.Opacity(0.25f);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CheckJudgement(bool userTriggered)
|
protected override void CheckJudgement(bool userTriggered)
|
||||||
{
|
{
|
||||||
if (userTriggered)
|
if (userTriggered)
|
||||||
{
|
{
|
||||||
if (Time.Current < HitObject.StartTime)
|
|
||||||
return;
|
|
||||||
|
|
||||||
userHits++;
|
userHits++;
|
||||||
|
|
||||||
|
var completion = (float)userHits / swell.RequiredHits;
|
||||||
|
|
||||||
|
expandingRing.FadeTo(expandingRing.Alpha + MathHelper.Clamp(completion / 16, 0.1f, 0.6f), 50);
|
||||||
|
expandingRing.Delay(50);
|
||||||
|
expandingRing.FadeTo(completion / 8, 2000, EasingTypes.OutQuint);
|
||||||
|
expandingRing.DelayReset();
|
||||||
|
|
||||||
|
symbol.RotateTo((float)(completion * swell.Duration / 8), 4000, EasingTypes.OutQuint);
|
||||||
|
|
||||||
|
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, EasingTypes.OutQuint);
|
||||||
|
|
||||||
if (userHits == swell.RequiredHits)
|
if (userHits == swell.RequiredHits)
|
||||||
{
|
{
|
||||||
Judgement.Result = HitResult.Hit;
|
Judgement.Result = HitResult.Hit;
|
||||||
@ -43,6 +166,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
if (Judgement.TimeOffset < 0)
|
if (Judgement.TimeOffset < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//TODO: THIS IS SHIT AND CAN'T EXIST POST-TAIKO WORLD CUP
|
||||||
if (userHits > swell.RequiredHits / 2)
|
if (userHits > swell.RequiredHits / 2)
|
||||||
{
|
{
|
||||||
Judgement.Result = HitResult.Hit;
|
Judgement.Result = HitResult.Hit;
|
||||||
@ -55,11 +179,42 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
|
|
||||||
protected override void UpdateState(ArmedState state)
|
protected override void UpdateState(ArmedState state)
|
||||||
{
|
{
|
||||||
|
const float preempt = 100;
|
||||||
|
|
||||||
|
Delay(HitObject.StartTime - Time.Current - preempt, true);
|
||||||
|
|
||||||
|
targetRing.ScaleTo(target_ring_scale, preempt * 4, EasingTypes.OutQuint);
|
||||||
|
|
||||||
|
Delay(preempt, true);
|
||||||
|
|
||||||
|
Delay(Judgement.TimeOffset + swell.Duration, true);
|
||||||
|
|
||||||
|
const float out_transition_time = 300;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case ArmedState.Hit:
|
||||||
|
bodyContainer.ScaleTo(1.4f, out_transition_time);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FadeOut(out_transition_time, EasingTypes.Out);
|
||||||
|
|
||||||
|
Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateScrollPosition(double time)
|
protected override void UpdateScrollPosition(double time)
|
||||||
{
|
{
|
||||||
base.UpdateScrollPosition(Math.Min(time, HitObject.StartTime));
|
// Make the swell stop at the hit target
|
||||||
|
double t = Math.Min(HitObject.StartTime, time);
|
||||||
|
|
||||||
|
if (t == HitObject.StartTime && !hasStarted)
|
||||||
|
{
|
||||||
|
OnStart?.Invoke();
|
||||||
|
hasStarted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.UpdateScrollPosition(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool HandleKeyPress(Key key)
|
protected override bool HandleKeyPress(Key key)
|
||||||
@ -67,6 +222,18 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
|
|||||||
if (Judgement.Result.HasValue)
|
if (Judgement.Result.HasValue)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Don't handle keys before the swell starts
|
||||||
|
if (Time.Current < HitObject.StartTime)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Find the keyset which this key corresponds to
|
||||||
|
var keySet = rimKeys.Contains(key) ? rimKeys : centreKeys;
|
||||||
|
|
||||||
|
// Ensure alternating keysets
|
||||||
|
if (keySet == lastKeySet)
|
||||||
|
return false;
|
||||||
|
lastKeySet = keySet;
|
||||||
|
|
||||||
UpdateJudgement(true);
|
UpdateJudgement(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
// 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.Graphics;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The symbol used for swell pieces.
|
||||||
|
/// </summary>
|
||||||
|
public class SwellSymbolPiece : TextAwesome
|
||||||
|
{
|
||||||
|
public SwellSymbolPiece()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
UseFullGlyphHeight = true;
|
||||||
|
TextSize = CirclePiece.SYMBOL_INNER_SIZE;
|
||||||
|
Icon = FontAwesome.fa_asterisk;
|
||||||
|
Shadow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ namespace osu.Game.Modes.Taiko.Objects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of hits required to complete the swell successfully.
|
/// The number of hits required to complete the swell successfully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int RequiredHits { get; protected set; }
|
public int RequiredHits { get; protected set; } = 10;
|
||||||
|
|
||||||
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Game.Modes.Taiko.Objects.Drawable;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko.UI
|
namespace osu.Game.Modes.Taiko.UI
|
||||||
{
|
{
|
||||||
@ -42,7 +43,7 @@ namespace osu.Game.Modes.Taiko.UI
|
|||||||
private readonly Container<DrawableTaikoJudgement> judgementContainer;
|
private readonly Container<DrawableTaikoJudgement> judgementContainer;
|
||||||
|
|
||||||
private readonly Container hitObjectContainer;
|
private readonly Container hitObjectContainer;
|
||||||
//private Container topLevelHitContainer;
|
private readonly Container topLevelHitContainer;
|
||||||
private readonly Container leftBackgroundContainer;
|
private readonly Container leftBackgroundContainer;
|
||||||
private readonly Container rightBackgroundContainer;
|
private readonly Container rightBackgroundContainer;
|
||||||
private readonly Box leftBackground;
|
private readonly Box leftBackground;
|
||||||
@ -143,10 +144,10 @@ namespace osu.Game.Modes.Taiko.UI
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//topLevelHitContainer = new Container
|
topLevelHitContainer = new Container
|
||||||
//{
|
{
|
||||||
// RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
//}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +166,11 @@ namespace osu.Game.Modes.Taiko.UI
|
|||||||
h.Depth = (float)h.HitObject.StartTime;
|
h.Depth = (float)h.HitObject.StartTime;
|
||||||
|
|
||||||
base.Add(h);
|
base.Add(h);
|
||||||
|
|
||||||
|
// 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> judgedObject)
|
public override void OnJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> judgedObject)
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<Compile Include="Objects\Drawable\Pieces\RimHitSymbolPiece.cs" />
|
<Compile Include="Objects\Drawable\Pieces\RimHitSymbolPiece.cs" />
|
||||||
<Compile Include="Objects\Drawable\Pieces\StrongCirclePiece.cs" />
|
<Compile Include="Objects\Drawable\Pieces\StrongCirclePiece.cs" />
|
||||||
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" />
|
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" />
|
||||||
|
<Compile Include="Objects\Drawable\Pieces\SwellSymbolPiece.cs" />
|
||||||
<Compile Include="Objects\DrumRoll.cs" />
|
<Compile Include="Objects\DrumRoll.cs" />
|
||||||
<Compile Include="Objects\DrumRollTick.cs" />
|
<Compile Include="Objects\DrumRollTick.cs" />
|
||||||
<Compile Include="Objects\Hit.cs" />
|
<Compile Include="Objects\Hit.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user