2020-08-03 19:13:02 +00:00
|
|
|
// 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.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2020-08-23 07:28:05 +00:00
|
|
|
using static osu.Game.Skinning.LegacySkinConfiguration;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning
|
|
|
|
{
|
2020-08-19 05:39:40 +00:00
|
|
|
/// <summary>
|
2020-09-22 03:27:47 +00:00
|
|
|
/// A combo counter implementation that visually behaves almost similar to stable's osu!catch combo counter.
|
2020-08-19 05:39:40 +00:00
|
|
|
/// </summary>
|
2020-08-19 05:00:57 +00:00
|
|
|
public class LegacyComboCounter : CompositeDrawable, ICatchComboCounter
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
|
|
|
private readonly LegacyRollingCounter counter;
|
|
|
|
|
2020-09-22 03:24:26 +00:00
|
|
|
private readonly LegacyRollingCounter explosion;
|
|
|
|
|
2020-08-23 07:28:05 +00:00
|
|
|
public LegacyComboCounter(ISkin skin)
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2020-09-22 03:24:26 +00:00
|
|
|
var fontName = skin.GetConfig<LegacySetting, string>(LegacySetting.ComboPrefix)?.Value ?? "score";
|
|
|
|
var fontOverlap = skin.GetConfig<LegacySetting, float>(LegacySetting.ComboOverlap)?.Value ?? -2f;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
Alpha = 0f;
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
Scale = new Vector2(0.8f);
|
|
|
|
|
2020-09-22 03:24:26 +00:00
|
|
|
InternalChildren = new Drawable[]
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2020-09-22 03:24:26 +00:00
|
|
|
explosion = new LegacyRollingCounter(skin, fontName, fontOverlap)
|
|
|
|
{
|
|
|
|
Alpha = 0.65f,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(1.5f),
|
|
|
|
},
|
|
|
|
counter = new LegacyRollingCounter(skin, fontName, fontOverlap)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
2020-08-03 19:13:02 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-09-22 03:35:18 +00:00
|
|
|
private int lastDisplayedCombo;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:35:18 +00:00
|
|
|
public void UpdateCombo(int combo, Color4? hitObjectColour = null)
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2020-09-22 03:35:18 +00:00
|
|
|
if (combo == lastDisplayedCombo)
|
|
|
|
return;
|
|
|
|
|
2020-08-22 09:20:50 +00:00
|
|
|
// There may still be existing transforms to the counter (including value change after 250ms),
|
|
|
|
// finish them immediately before new transforms.
|
2020-09-22 03:54:21 +00:00
|
|
|
counter.SetCountWithoutRolling(lastDisplayedCombo);
|
|
|
|
|
|
|
|
lastDisplayedCombo = combo;
|
2020-08-22 09:20:50 +00:00
|
|
|
|
2020-08-03 19:13:02 +00:00
|
|
|
// Combo fell to zero, roll down and fade out the counter.
|
|
|
|
if (combo == 0)
|
|
|
|
{
|
|
|
|
counter.Current.Value = 0;
|
2020-09-22 03:24:26 +00:00
|
|
|
explosion.Current.Value = 0;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:54:21 +00:00
|
|
|
this.FadeOut(400, Easing.Out);
|
2020-08-03 19:13:02 +00:00
|
|
|
}
|
2020-09-22 03:54:21 +00:00
|
|
|
else
|
2020-08-03 19:13:02 +00:00
|
|
|
{
|
2020-09-22 03:54:21 +00:00
|
|
|
this.FadeInFromZero().Delay(1000).FadeOut(300);
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:54:21 +00:00
|
|
|
counter.ScaleTo(1.5f)
|
|
|
|
.ScaleTo(0.8f, 250, Easing.Out)
|
|
|
|
.OnComplete(c => c.SetCountWithoutRolling(combo));
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:54:21 +00:00
|
|
|
counter.Delay(250)
|
|
|
|
.ScaleTo(1f)
|
|
|
|
.ScaleTo(1.1f, 60).Then().ScaleTo(1f, 30);
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:54:21 +00:00
|
|
|
explosion.Colour = hitObjectColour ?? Color4.White;
|
2020-08-03 19:13:02 +00:00
|
|
|
|
2020-09-22 03:54:21 +00:00
|
|
|
explosion.SetCountWithoutRolling(combo);
|
|
|
|
explosion.ScaleTo(1.5f)
|
|
|
|
.ScaleTo(1.9f, 400, Easing.Out)
|
|
|
|
.FadeOutFromOne(400);
|
|
|
|
}
|
2020-08-03 19:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|