Sprites in blinds mod & gameplay improvements

There are now skinnable actual blinds (shoji screen panels)
The black overlay is still behind them to avoid cheating with skins
The blinds don't open linearly anymore, they are health squared now
When easy mod is on, there is always a little gap open
This commit is contained in:
WebFreak001 2018-09-15 23:44:22 +02:00
parent 040a44d42c
commit 5f3c0549c9
4 changed files with 101 additions and 5 deletions

View File

@ -6,6 +6,7 @@
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using System.Linq;
namespace osu.Game.Rulesets.Osu.Mods
{
@ -16,7 +17,8 @@ public class OsuModBlinds : ModBlinds<OsuHitObject>
public override void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)
{
rulesetContainer.Overlays.Add(flashlight = new DrawableOsuBlinds(restrictTo: rulesetContainer.Playfield));
bool hasEasy = rulesetContainer.ActiveMods.Count(mod => mod is ModEasy) > 0;
rulesetContainer.Overlays.Add(flashlight = new DrawableOsuBlinds(restrictTo: rulesetContainer.Playfield, hasEasy: hasEasy));
}
public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)

View File

@ -6,6 +6,10 @@
using osu.Framework.Graphics.Shapes;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Game.Skinning;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
@ -14,10 +18,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
/// </summary>
public class DrawableOsuBlinds : Container
{
/// <summary>
/// Black background boxes behind blind panel textures.
/// </summary>
private Box box1, box2;
private Sprite panelLeft, panelRight;
private Sprite bgPanelLeft, bgPanelRight;
private ISkinSource skin;
private float target = 1;
private readonly float easing = 1;
private readonly Container restrictTo;
private readonly bool hasEasy;
/// <summary>
/// <para>
@ -30,15 +43,21 @@ public class DrawableOsuBlinds : Container
/// Infinity would mean the blinds are always outside the playfield except on 100% health.
/// </para>
/// </summary>
private const float leniency = 0.2f;
private const float leniency = 0.1f;
public DrawableOsuBlinds(Container restrictTo)
/// <summary>
/// Multiplier for adding a gap when the Easy mod is also currently applied.
/// </summary>
private const float easy_position_multiplier = 0.95f;
public DrawableOsuBlinds(Container restrictTo, bool hasEasy)
{
this.restrictTo = restrictTo;
this.hasEasy = hasEasy;
}
[BackgroundDependencyLoader]
private void load()
private void load(ISkinSource skin, TextureStore textures)
{
RelativeSizeAxes = Axes.Both;
Width = 1;
@ -62,6 +81,36 @@ private void load()
Width = 0,
Height = 1
});
Add(bgPanelLeft = new ModBlindsPanelSprite {
Origin = Anchor.TopRight,
Colour = Color4.Gray
});
Add(bgPanelRight = new ModBlindsPanelSprite {
Origin = Anchor.TopLeft,
Colour = Color4.Gray
});
Add(panelLeft = new ModBlindsPanelSprite {
Origin = Anchor.TopRight
});
Add(panelRight = new ModBlindsPanelSprite {
Origin = Anchor.TopLeft
});
this.skin = skin;
skin.SourceChanged += skinChanged;
PanelTexture = textures.Get("Play/osu/blinds-panel");
}
private void skinChanged()
{
PanelTexture = skin.GetTexture("Play/osu/blinds-panel");
}
private static float applyAdjustmentCurve(float value)
{
return value * value;
}
protected override void Update()
@ -71,10 +120,16 @@ protected override void Update()
float rawWidth = end - start;
start -= rawWidth * leniency * 0.5f;
end += rawWidth * leniency * 0.5f;
float width = (end - start) * 0.5f * easing;
float width = (end - start) * 0.5f * applyAdjustmentCurve((hasEasy ? easy_position_multiplier : 1) * easing);
// different values in case the playfield ever moves from center to somewhere else.
box1.Width = start + width;
box2.Width = DrawWidth - end + width;
panelLeft.X = start + width;
panelRight.X = end - width;
bgPanelLeft.X = start;
bgPanelRight.X = end;
}
/// <summary>
@ -92,5 +147,16 @@ public float Value
return target;
}
}
public Texture PanelTexture
{
set
{
panelLeft.Texture = value;
panelRight.Texture = value;
bgPanelLeft.Texture = value;
bgPanelRight.Texture = value;
}
}
}
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public class ModBlindsPanelSprite : Sprite
{
public ModBlindsPanelSprite()
{
RelativeSizeAxes = Axes.None;
Anchor = Anchor.TopLeft;
}
protected override void Update()
{
Height = Parent?.DrawHeight ?? 0;
if (Height == 0 || Texture is null)
Width = 0;
else
Width = Texture.Width / (float)Texture.Height * Height;
}
}
}

View File

@ -328,6 +328,8 @@ protected override void Update()
Playfield.Size = GetAspectAdjustedSize() * PlayfieldArea;
}
public IEnumerable<Mod> ActiveMods { get => Mods; }
/// <summary>
/// Computes the size of the <see cref="Playfield"/> in relative coordinate space after aspect adjustments.
/// </summary>