Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Blinds" mod #3180

Merged
merged 28 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b011edd
added Overlays container to RulesetContainer
WebFreak001 Aug 5, 2018
b33954d
Implement blinds mod
WebFreak001 Aug 5, 2018
040a44d
Merge branch 'master' of github.com:WebFreak001/osu into mod-fl2
WebFreak001 Sep 15, 2018
5f3c054
Sprites in blinds mod & gameplay improvements
WebFreak001 Sep 15, 2018
91b2587
Make fruit catcher enter and leave what's behind the blinds
WebFreak001 Sep 16, 2018
633e8fa
Style & const fix
WebFreak001 Sep 16, 2018
c9ea5ce
Made blinds open during breaks and start
WebFreak001 Sep 16, 2018
2de3b33
Readonly fixes
WebFreak001 Sep 16, 2018
8a01fc1
Make random in blinds mod the same every replay
WebFreak001 Sep 17, 2018
e0a8157
Merge branch 'master' into mod-fl2
peppy Oct 10, 2018
460c943
Merge branch 'master' into mod-fl2
WebFreak001 Oct 12, 2018
3b08ad0
Merge branch 'master' of https://github.com/ppy/osu into mod-fl2
WebFreak001 Oct 27, 2018
72e82b6
Adjust blinds animations based on player feedback
WebFreak001 Oct 27, 2018
cbd14d5
Merge branch 'master' of https://github.com/ppy/osu into mod-fl2
WebFreak001 Oct 29, 2018
3cb9197
Merge branch 'master' of https://github.com/ppy/osu into mod-fl2
WebFreak001 Dec 6, 2018
46b9870
make target animation call more obvious
WebFreak001 Dec 6, 2018
a14de5b
Remove blinds random NPC
WebFreak001 Dec 6, 2018
6eff7d9
Style fixes
WebFreak001 Dec 6, 2018
808f02b
Merge branch 'master' into mod-fl2
peppy Dec 7, 2018
d379d02
Remove unnecessary base class
peppy Dec 7, 2018
7d9cdf6
Remove unnecessary private field
peppy Dec 7, 2018
4f34d42
Major code refactors
peppy Dec 7, 2018
07f8b8e
Update resources
peppy Dec 20, 2018
bb850da
Remove skinnability for now
peppy Dec 20, 2018
9177a45
Merge branch 'master' into mod-fl2
peppy Dec 20, 2018
d3368df
Simplify changes to RulesetContainer
peppy Dec 20, 2018
ef9d93f
Remove mod multipliers
peppy Dec 20, 2018
ce414ed
Merge branch 'master' into mod-fl2
peppy Dec 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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
{
Expand All @@ -17,15 +16,27 @@ public class OsuModBlinds : ModBlinds<OsuHitObject>

public override void ApplyToRulesetContainer(RulesetContainer<OsuHitObject> rulesetContainer)
{
bool hasEasy = rulesetContainer.ActiveMods.Count(mod => mod is ModEasy) > 0;
rulesetContainer.Overlays.Add(flashlight = new DrawableOsuBlinds(restrictTo: rulesetContainer.Playfield, hasEasy: hasEasy));
bool hasEasy = false;
bool hasHardrock = false;
foreach (var mod in rulesetContainer.ActiveMods)
{
if (mod is ModEasy)
hasEasy = true;
if (mod is ModHardRock)
hasHardrock = true;
}
rulesetContainer.Overlays.Add(flashlight = new DrawableOsuBlinds(restrictTo: rulesetContainer.Playfield, hasEasy: hasEasy, hasHardrock: hasHardrock));
}

public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
scoreProcessor.Health.ValueChanged += val => {
flashlight.Value = (float)val;
};
scoreProcessor.Combo.ValueChanged += val => {
if (val > 0 && val % 30 == 0)
flashlight.TriggerNPC();
};
}
}
}
162 changes: 149 additions & 13 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuBlinds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using System;

namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
Expand All @@ -24,13 +25,27 @@ public class DrawableOsuBlinds : Container
private Box box1, box2;

This comment was marked as off-topic.

private Sprite panelLeft, panelRight;
private Sprite bgPanelLeft, bgPanelRight;

private Drawable bgRandomNpc;
private Drawable randomNpc;
private const float npc_movement_start = 1.5f;
private float npcPosition = npc_movement_start;
private bool animatingNPC;
private Random random;

private ISkinSource skin;

private float targetClamp = 1;
private float target = 1;
private readonly float easing = 1;

private const float black_depth = 10;
private const float bg_panel_depth = 8;
private const float fg_panel_depth = 4;
private const float npc_depth = 6;

private readonly Container restrictTo;
private readonly bool hasEasy;
private readonly bool modEasy, modHardrock;

/// <summary>
/// <para>
Expand All @@ -50,10 +65,12 @@ public class DrawableOsuBlinds : Container
/// </summary>
private const float easy_position_multiplier = 0.95f;

public DrawableOsuBlinds(Container restrictTo, bool hasEasy)
public DrawableOsuBlinds(Container restrictTo, bool hasEasy, bool hasHardrock)
{
this.restrictTo = restrictTo;
this.hasEasy = hasEasy;

modEasy = hasEasy;
modHardrock = hasHardrock;
}

[BackgroundDependencyLoader]
Expand All @@ -70,7 +87,8 @@ private void load(ISkinSource skin, TextureStore textures)
Colour = Color4.Black,
RelativeSizeAxes = Axes.Y,
Width = 0,
Height = 1
Height = 1,
Depth = black_depth
});
Add(box2 = new Box
{
Expand All @@ -79,23 +97,56 @@ private void load(ISkinSource skin, TextureStore textures)
Colour = Color4.Black,
RelativeSizeAxes = Axes.Y,
Width = 0,
Height = 1
Height = 1,
Depth = black_depth
});

Add(bgPanelLeft = new ModBlindsPanelSprite {
Origin = Anchor.TopRight,
Colour = Color4.Gray
Colour = Color4.Gray,
Depth = bg_panel_depth + 1
});
Add(panelLeft = new ModBlindsPanelSprite {
Origin = Anchor.TopRight,
Depth = bg_panel_depth
});

Add(bgPanelRight = new ModBlindsPanelSprite {
Origin = Anchor.TopLeft,
Colour = Color4.Gray
Colour = Color4.Gray,
Depth = fg_panel_depth + 1
});
Add(panelRight = new ModBlindsPanelSprite {
Origin = Anchor.TopLeft,
Depth = fg_panel_depth
});

Add(panelLeft = new ModBlindsPanelSprite {
Origin = Anchor.TopRight

random = new Random();
Add(bgRandomNpc = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.Black,
Width = 512 * 0.4f,
Height = 512 * 0.95f,
RelativePositionAxes = Axes.Y,
X = -512,

This comment was marked as off-topic.

This comment was marked as off-topic.

Y = 0,
Depth = black_depth
});
Add(panelRight = new ModBlindsPanelSprite {
Origin = Anchor.TopLeft
Add(new SkinnableDrawable("Play/Catch/fruit-catcher-idle", name => randomNpc = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = textures.Get(name),
Width = 512,
Height = 512,
RelativePositionAxes = Axes.Y,
X = -512,
Y = 0
}) {
Depth = npc_depth
});

this.skin = skin;
Expand All @@ -108,9 +159,36 @@ private void skinChanged()
PanelTexture = skin.GetTexture("Play/osu/blinds-panel");
}

private float applyGap(float value)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

{
float ret;

This comment was marked as off-topic.

if (modEasy)
{
float multiplier = 0.95f;
ret = value * multiplier;
}
else if (modHardrock)
{
float multiplier = 1.1f;
ret = value * multiplier;
}
else
{
ret = value;
}

if (ret > targetClamp)
return targetClamp;
else if (ret < 0)
return 0;
else
return ret;
}

private static float applyAdjustmentCurve(float value)
{
return value * value;
// lagrange polinominal for (0,0) (0.5,0.35) (1,1) should make a good curve
return 0.6f * value * value + 0.4f * value;
}

protected override void Update()
Expand All @@ -121,7 +199,7 @@ protected override void Update()
start -= rawWidth * leniency * 0.5f;
end += rawWidth * leniency * 0.5f;

float width = (end - start) * 0.5f * applyAdjustmentCurve((hasEasy ? easy_position_multiplier : 1) * easing);
float width = (end - start) * 0.5f * applyAdjustmentCurve(applyGap(easing));
// different values in case the playfield ever moves from center to somewhere else.
box1.Width = start + width;
box2.Width = DrawWidth - end + width;
Expand All @@ -130,6 +208,64 @@ protected override void Update()
panelRight.X = end - width;
bgPanelLeft.X = start;
bgPanelRight.X = end;

float adjustedNpcPosition = npcPosition * rawWidth;
if (randomNpc != null)
randomNpc.X = adjustedNpcPosition;
bgRandomNpc.X = adjustedNpcPosition;
}

public void TriggerNPC()
{
peppy marked this conversation as resolved.
Show resolved Hide resolved
if (animatingNPC)
return;

bool left = (random.Next() & 1) != 0;
bool exit = (random.Next() & 1) != 0;
float start, end;

if (left)
{
start = -npc_movement_start;
end = npc_movement_start;

randomNpc.Scale = new OpenTK.Vector2(1, 1);
}
else
{
start = npc_movement_start;
end = -npc_movement_start;

randomNpc.Scale = new OpenTK.Vector2(-1, 1);
}

// depths for exit from the left and entry from the right
if (left == exit)
{
ChangeChildDepth(bgPanelLeft, fg_panel_depth + 1);
ChangeChildDepth(panelLeft, fg_panel_depth);

ChangeChildDepth(bgPanelRight, bg_panel_depth + 1);
ChangeChildDepth(panelRight, bg_panel_depth);
}
else // depths for entry from the left or exit from the right
{
ChangeChildDepth(bgPanelLeft, bg_panel_depth + 1);
ChangeChildDepth(panelLeft, bg_panel_depth);

ChangeChildDepth(bgPanelRight, fg_panel_depth + 1);
ChangeChildDepth(panelRight, fg_panel_depth);
}

animatingNPC = true;
npcPosition = start;
this.TransformTo(nameof(npcPosition), end, 3000, Easing.OutSine).Finally(_ => animatingNPC = false);

targetClamp = 1;
this.Delay(600).TransformTo(nameof(targetClamp), 0.6f, 300).Delay(500).TransformTo(nameof(targetClamp), 1f, 300);

randomNpc?.FadeIn(250).Delay(2000).FadeOut(500);
bgRandomNpc.FadeIn(250).Delay(2000).FadeOut(500);
}

/// <summary>
Expand Down