mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Change fail effect to be less distracting
This commit is contained in:
parent
4976f80b71
commit
947745d87e
@ -1,11 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
@ -40,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public void TestLayerFading()
|
public void TestLayerFading()
|
||||||
{
|
{
|
||||||
AddSliderStep("current health", 0.0, 1.0, 1.0, val => layer.Current.Value = val);
|
AddSliderStep("current health", 0.0, 1.0, 1.0, val => layer.Current.Value = val);
|
||||||
var box = layer.ChildrenOfType<Box>().First();
|
var box = layer.Child;
|
||||||
|
|
||||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.10);
|
AddStep("set health to 0.10", () => layer.Current.Value = 0.10);
|
||||||
AddWaitStep("wait for fade to finish", 5);
|
AddWaitStep("wait for fade to finish", 5);
|
||||||
|
@ -4,12 +4,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
{
|
{
|
||||||
@ -22,8 +26,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private const int fade_time = 400;
|
private const int fade_time = 400;
|
||||||
|
|
||||||
private readonly Box box;
|
|
||||||
|
|
||||||
private Bindable<bool> enabled;
|
private Bindable<bool> enabled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,20 +33,43 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double LowHealthThreshold = 0.20f;
|
public double LowHealthThreshold = 0.20f;
|
||||||
|
|
||||||
|
private readonly Container boxes;
|
||||||
|
|
||||||
public FailingLayer()
|
public FailingLayer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Child = box = new Box
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
boxes = new Container
|
||||||
Alpha = 0
|
{
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0)),
|
||||||
|
Height = 0.2f,
|
||||||
|
},
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.2f,
|
||||||
|
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0), Color4.White),
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour color, OsuConfigManager config)
|
private void load(OsuColour color, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
box.Colour = color.Red;
|
boxes.Colour = color.Red;
|
||||||
|
|
||||||
enabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
enabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
||||||
enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
|
enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
|
||||||
}
|
}
|
||||||
@ -53,6 +78,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
base.BindHealthProcessor(processor);
|
base.BindHealthProcessor(processor);
|
||||||
|
|
||||||
|
// don't display ever if the ruleset is not using a draining health display.
|
||||||
if (!(processor is DrainingHealthProcessor))
|
if (!(processor is DrainingHealthProcessor))
|
||||||
{
|
{
|
||||||
enabled.UnbindBindings();
|
enabled.UnbindBindings();
|
||||||
@ -62,7 +88,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
box.Alpha = (float)Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, fade_time), box.Alpha,
|
boxes.Alpha = (float)Interpolation.ValueAt(Math.Clamp(Clock.ElapsedFrameTime, 0, fade_time), boxes.Alpha,
|
||||||
Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha), 0, fade_time, Easing.Out);
|
Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha), 0, fade_time, Easing.Out);
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
|
Loading…
Reference in New Issue
Block a user