mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 21:33:00 +08:00
Add very basic argon mania combo counter implementation
This commit is contained in:
parent
8be3f4f632
commit
408287e086
@ -0,0 +1,84 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
||||||
|
{
|
||||||
|
public partial class ArgonManiaComboCounter : ComboCounter, ISerialisableDrawable
|
||||||
|
{
|
||||||
|
private OsuSpriteText text = null!;
|
||||||
|
|
||||||
|
protected override double RollingDuration => 500;
|
||||||
|
protected override Easing RollingEasing => Easing.OutQuint;
|
||||||
|
|
||||||
|
private DrawableManiaRuleset maniaRuleset = null!;
|
||||||
|
|
||||||
|
bool ISerialisableDrawable.SupportsClosestAnchor => false;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(DrawableRuleset ruleset, ScoreProcessor scoreProcessor)
|
||||||
|
{
|
||||||
|
maniaRuleset = (DrawableManiaRuleset)ruleset;
|
||||||
|
|
||||||
|
Current.BindTo(scoreProcessor.Combo);
|
||||||
|
Current.BindValueChanged(combo =>
|
||||||
|
{
|
||||||
|
if (combo.OldValue == 0 && combo.NewValue > 0)
|
||||||
|
text.FadeIn(200, Easing.OutQuint);
|
||||||
|
else if (combo.OldValue > 0 && combo.NewValue == 0)
|
||||||
|
{
|
||||||
|
if (combo.OldValue > 1)
|
||||||
|
text.FlashColour(Color4.Red, 2000, Easing.OutQuint);
|
||||||
|
|
||||||
|
text.FadeOut(200, Easing.InQuint);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
UsesFixedAnchor = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IBindable<ScrollingDirection> direction = null!;
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
text.Alpha = Current.Value > 0 ? 1 : 0;
|
||||||
|
|
||||||
|
direction = maniaRuleset.ScrollingInfo.Direction.GetBoundCopy();
|
||||||
|
direction.BindValueChanged(_ => updateAnchor());
|
||||||
|
|
||||||
|
// two schedules are required so that updateAnchor is executed in the next frame,
|
||||||
|
// which is when the combo counter receives its Y position by the default layout in ArgonManiaSkinTransformer.
|
||||||
|
Schedule(() => Schedule(updateAnchor));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAnchor()
|
||||||
|
{
|
||||||
|
Anchor &= ~(Anchor.y0 | Anchor.y2);
|
||||||
|
Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0;
|
||||||
|
|
||||||
|
// since we flip the vertical anchor when changing scroll direction,
|
||||||
|
// we can use the sign of the Y value as an indicator to make the combo counter displayed correctly.
|
||||||
|
if ((Y < 0 && direction.Value == ScrollingDirection.Down) || (Y > 0 && direction.Value == ScrollingDirection.Up))
|
||||||
|
Y = -Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IHasText CreateText() => text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Torus.With(size: 32, fixedWidth: true),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -2,8 +2,11 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -12,7 +15,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
||||||
{
|
{
|
||||||
public class ManiaArgonSkinTransformer : SkinTransformer
|
public class ManiaArgonSkinTransformer : ArgonSkinTransformer
|
||||||
{
|
{
|
||||||
private readonly ManiaBeatmap beatmap;
|
private readonly ManiaBeatmap beatmap;
|
||||||
|
|
||||||
@ -26,6 +29,34 @@ namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
|||||||
{
|
{
|
||||||
switch (lookup)
|
switch (lookup)
|
||||||
{
|
{
|
||||||
|
case SkinComponentsContainerLookup containerLookup:
|
||||||
|
switch (containerLookup.Target)
|
||||||
|
{
|
||||||
|
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
|
||||||
|
Debug.Assert(containerLookup.Ruleset.ShortName == ManiaRuleset.SHORT_NAME);
|
||||||
|
|
||||||
|
var rulesetHUDComponents = Skin.GetDrawableComponent(lookup);
|
||||||
|
|
||||||
|
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
|
||||||
|
{
|
||||||
|
var combo = container.ChildrenOfType<ArgonManiaComboCounter>().FirstOrDefault();
|
||||||
|
|
||||||
|
if (combo != null)
|
||||||
|
{
|
||||||
|
combo.Anchor = Anchor.TopCentre;
|
||||||
|
combo.Origin = Anchor.Centre;
|
||||||
|
combo.Y = 200;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
{
|
||||||
|
new ArgonManiaComboCounter(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return rulesetHUDComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case GameplaySkinComponentLookup<HitResult> resultComponent:
|
case GameplaySkinComponentLookup<HitResult> resultComponent:
|
||||||
// This should eventually be moved to a skin setting, when supported.
|
// This should eventually be moved to a skin setting, when supported.
|
||||||
if (Skin is ArgonProSkin && resultComponent.Component >= HitResult.Great)
|
if (Skin is ArgonProSkin && resultComponent.Component >= HitResult.Great)
|
||||||
|
Loading…
Reference in New Issue
Block a user