mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 13:33:52 +08:00
Add basic taiko scroller implementation
This commit is contained in:
parent
42ce325c1f
commit
8955b98cbb
Binary file not shown.
After Width: | Height: | Size: 138 KiB |
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
typeof(TaikoHitTarget),
|
||||
typeof(TaikoLegacyHitTarget),
|
||||
typeof(PlayfieldBackgroundRight),
|
||||
typeof(LegacyTaikoScroller),
|
||||
}).ToList();
|
||||
|
||||
[Cached(typeof(IScrollingInfo))]
|
||||
@ -51,6 +52,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Height = 0.6f,
|
||||
}));
|
||||
|
||||
AddRepeatStep("change height", () => this.ChildrenOfType<TaikoPlayfield>().ForEach(p => p.Height = Math.Max(0.2f, (p.Height + 0.2f) % 1f)), 50);
|
||||
|
@ -0,0 +1,16 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
{
|
||||
public class TestSceneTaikoScroller : TaikoSkinnableTestScene
|
||||
{
|
||||
public TestSceneTaikoScroller()
|
||||
{
|
||||
AddStep("Load scroller", () => SetContents(() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoScroller), _ => Drawable.Empty())));
|
||||
}
|
||||
}
|
||||
}
|
83
osu.Game.Rulesets.Taiko/Skinning/LegacyTaikoScroller.cs
Normal file
83
osu.Game.Rulesets.Taiko/Skinning/LegacyTaikoScroller.cs
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
{
|
||||
public class LegacyTaikoScroller : CompositeDrawable
|
||||
{
|
||||
public LegacyTaikoScroller()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (var sprite in InternalChildren)
|
||||
{
|
||||
sprite.X -= (float)Time.Elapsed * 0.1f;
|
||||
|
||||
if (sprite.X + sprite.DrawWidth < 0)
|
||||
sprite.Expire();
|
||||
}
|
||||
|
||||
var last = InternalChildren.LastOrDefault();
|
||||
|
||||
if (last == null || last.ScreenSpaceDrawQuad.TopRight.X < ScreenSpaceDrawQuad.TopRight.X)
|
||||
{
|
||||
AddInternal(new ScrollerSprite { X = last == null ? 0 : last.X + last.DrawWidth });
|
||||
}
|
||||
}
|
||||
|
||||
private class ScrollerSprite : CompositeDrawable
|
||||
{
|
||||
private Sprite passingSprite;
|
||||
private Sprite failingSprite;
|
||||
|
||||
private bool passing = true;
|
||||
|
||||
public bool Passing
|
||||
{
|
||||
get => passing;
|
||||
set
|
||||
{
|
||||
if (value == passing)
|
||||
return;
|
||||
|
||||
passing = value;
|
||||
|
||||
if (passing)
|
||||
{
|
||||
passingSprite.Show();
|
||||
failingSprite.FadeOut(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
failingSprite.FadeIn(200);
|
||||
passingSprite.Delay(200).FadeOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
passingSprite = new Sprite { Texture = skin.GetTexture("taiko-slider") },
|
||||
failingSprite = new Sprite { Texture = skin.GetTexture("taiko-slider-fail"), Alpha = 0 },
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -85,6 +85,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
return new LegacyHitExplosion(sprite);
|
||||
|
||||
return null;
|
||||
|
||||
case TaikoSkinComponents.TaikoScroller:
|
||||
if (GetTexture("taiko-slider") != null)
|
||||
return new LegacyTaikoScroller();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return source.GetDrawableComponent(component);
|
||||
|
@ -18,5 +18,6 @@ namespace osu.Game.Rulesets.Taiko
|
||||
TaikoExplosionMiss,
|
||||
TaikoExplosionGood,
|
||||
TaikoExplosionGreat,
|
||||
TaikoScroller
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoScroller), _ => Drawable.Empty())
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.TopLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 100,
|
||||
},
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundRight), _ => new PlayfieldBackgroundRight()),
|
||||
rightArea = new Container
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user