mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Merge branch 'master' into scrolling-container-origin-adjust
This commit is contained in:
commit
3621362a48
@ -53,7 +53,7 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1215.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1225.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1227.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1227.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -28,9 +28,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(IBeatmap beatmap) => new CatchScoreProcessor(beatmap);
|
||||
|
||||
public override HealthProcessor CreateHealthProcessor(IBeatmap beatmap) => new CatchHealthProcessor(beatmap);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor();
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap, this);
|
||||
|
||||
|
@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Catch.Mods
|
||||
{
|
||||
base.TransferSettings(difficulty);
|
||||
|
||||
CircleSize.Value = CircleSize.Default = difficulty.CircleSize;
|
||||
ApproachRate.Value = ApproachRate.Default = difficulty.ApproachRate;
|
||||
TransferSetting(CircleSize, difficulty.CircleSize);
|
||||
TransferSetting(ApproachRate, difficulty.ApproachRate);
|
||||
}
|
||||
|
||||
protected override void ApplySettings(BeatmapDifficulty difficulty)
|
||||
|
@ -1,38 +0,0 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Scoring
|
||||
{
|
||||
public class CatchHealthProcessor : HealthProcessor
|
||||
{
|
||||
public CatchHealthProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
private float hpDrainRate;
|
||||
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
|
||||
}
|
||||
|
||||
protected override double HealthAdjustmentFactorFor(JudgementResult result)
|
||||
{
|
||||
switch (result.Type)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
return hpDrainRate;
|
||||
|
||||
default:
|
||||
return 10.2 - hpDrainRate; // Award less HP as drain rate is increased
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,12 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Scoring
|
||||
{
|
||||
public class CatchScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public CatchScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
public override HitWindows CreateHitWindows() => new CatchHitWindows();
|
||||
}
|
||||
}
|
||||
|
46
osu.Game.Rulesets.Mania.Tests/SkinnableTestScene.cs
Normal file
46
osu.Game.Rulesets.Mania.Tests/SkinnableTestScene.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public abstract class SkinnableTestScene : OsuGridTestScene
|
||||
{
|
||||
private Skin defaultSkin;
|
||||
|
||||
protected SkinnableTestScene()
|
||||
: base(1, 2)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, SkinManager skinManager)
|
||||
{
|
||||
defaultSkin = skinManager.GetSkin(DefaultLegacySkin.Info);
|
||||
}
|
||||
|
||||
public void SetContents(Func<Drawable> creationFunction)
|
||||
{
|
||||
Cell(0).Child = createProvider(null, creationFunction);
|
||||
Cell(1).Child = createProvider(defaultSkin, creationFunction);
|
||||
}
|
||||
|
||||
private Drawable createProvider(Skin skin, Func<Drawable> creationFunction)
|
||||
{
|
||||
var mainProvider = new SkinProvidingContainer(skin);
|
||||
|
||||
return mainProvider
|
||||
.WithChild(new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider))
|
||||
{
|
||||
Child = creationFunction()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
37
osu.Game.Rulesets.Mania.Tests/TestSceneDrawableJudgement.cs
Normal file
37
osu.Game.Rulesets.Mania.Tests/TestSceneDrawableJudgement.cs
Normal file
@ -0,0 +1,37 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestSceneDrawableJudgement : SkinnableTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(DrawableJudgement),
|
||||
typeof(DrawableManiaJudgement)
|
||||
};
|
||||
|
||||
public TestSceneDrawableJudgement()
|
||||
{
|
||||
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
|
||||
{
|
||||
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
|
||||
new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
314
osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
Normal file
314
osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
Normal file
@ -0,0 +1,314 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestSceneHoldNoteInput : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
private const double time_before_head = 250;
|
||||
private const double time_head = 1500;
|
||||
private const double time_during_hold_1 = 2500;
|
||||
private const double time_tail = 4000;
|
||||
private const double time_after_tail = 5250;
|
||||
|
||||
private List<JudgementResult> judgementResults;
|
||||
private bool allJudgedFired;
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestNoInput()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
assertNoteJudgement(HitResult.Perfect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail, ManiaAction.Key1),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyThenPressAtStartAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_before_head + 10),
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressTooEarlyThenPressAtStartAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_before_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_before_head + 10),
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Perfect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartAndBreak()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTickJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartThenBreakThenRepressAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo x o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAtStartThenBreakThenRepressAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_head, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_head + 10),
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Perfect);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressDuringNoteAndReleaseAfterTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_after_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Miss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// x o o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressDuringNoteAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_during_hold_1, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Perfect);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// -----[ ]-----
|
||||
/// xo o
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestPressAndReleaseAtTail()
|
||||
{
|
||||
performTest(new List<ReplayFrame>
|
||||
{
|
||||
new ManiaReplayFrame(time_tail, ManiaAction.Key1),
|
||||
new ManiaReplayFrame(time_tail + 10),
|
||||
});
|
||||
|
||||
assertHeadJudgement(HitResult.Miss);
|
||||
assertTickJudgement(HitResult.Miss);
|
||||
assertTailJudgement(HitResult.Meh);
|
||||
}
|
||||
|
||||
private void assertHeadJudgement(HitResult result)
|
||||
=> AddAssert($"head judged as {result}", () => judgementResults[0].Type == result);
|
||||
|
||||
private void assertTailJudgement(HitResult result)
|
||||
=> AddAssert($"tail judged as {result}", () => judgementResults[^2].Type == result);
|
||||
|
||||
private void assertNoteJudgement(HitResult result)
|
||||
=> AddAssert($"hold note judged as {result}", () => judgementResults[^1].Type == result);
|
||||
|
||||
private void assertTickJudgement(HitResult result)
|
||||
=> AddAssert($"tick judged as {result}", () => judgementResults[6].Type == result); // arbitrary tick
|
||||
|
||||
private ScoreAccessibleReplayPlayer currentPlayer;
|
||||
|
||||
private void performTest(List<ReplayFrame> frames)
|
||||
{
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<ManiaHitObject>
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
new HoldNote
|
||||
{
|
||||
StartTime = time_head,
|
||||
Duration = time_tail - time_head,
|
||||
Column = 0,
|
||||
}
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo
|
||||
},
|
||||
});
|
||||
|
||||
Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
|
||||
|
||||
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||
|
||||
p.OnLoadComplete += _ =>
|
||||
{
|
||||
p.ScoreProcessor.NewJudgement += result =>
|
||||
{
|
||||
if (currentPlayer == p) judgementResults.Add(result);
|
||||
};
|
||||
p.ScoreProcessor.AllJudged += () =>
|
||||
{
|
||||
if (currentPlayer == p) allJudgedFired = true;
|
||||
};
|
||||
};
|
||||
|
||||
LoadScreen(currentPlayer = p);
|
||||
allJudgedFired = false;
|
||||
judgementResults = new List<JudgementResult>();
|
||||
});
|
||||
|
||||
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||
AddUntilStep("Wait for all judged", () => allJudgedFired);
|
||||
}
|
||||
|
||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
{
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
|
||||
public ScoreAccessibleReplayPlayer(Score score)
|
||||
: base(score, false, false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
osu.Game.Rulesets.Mania.Tests/TestScenePlayer.cs
Normal file
15
osu.Game.Rulesets.Mania.Tests/TestScenePlayer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestScenePlayer : PlayerTestScene
|
||||
{
|
||||
public TestScenePlayer()
|
||||
: base(new ManiaRuleset())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
// Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
|
||||
if (DrawableObject.IsLoaded)
|
||||
{
|
||||
DrawableNote note = position == HoldNotePosition.Start ? DrawableObject.Head : DrawableObject.Tail;
|
||||
DrawableNote note = position == HoldNotePosition.Start ? (DrawableNote)DrawableObject.Head : DrawableObject.Tail;
|
||||
|
||||
Anchor = note.Anchor;
|
||||
Origin = note.Origin;
|
||||
|
@ -26,7 +26,9 @@ using osu.Game.Rulesets.Mania.Configuration;
|
||||
using osu.Game.Rulesets.Mania.Difficulty;
|
||||
using osu.Game.Rulesets.Mania.Edit;
|
||||
using osu.Game.Rulesets.Mania.Scoring;
|
||||
using osu.Game.Rulesets.Mania.Skinning;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania
|
||||
@ -35,9 +37,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(IBeatmap beatmap) => new ManiaScoreProcessor(beatmap);
|
||||
|
||||
public override HealthProcessor CreateHealthProcessor(IBeatmap beatmap) => new ManiaHealthProcessor(beatmap);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this);
|
||||
|
||||
@ -47,6 +47,8 @@ namespace osu.Game.Rulesets.Mania
|
||||
|
||||
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
||||
|
||||
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new ManiaLegacySkinTransformer(source);
|
||||
|
||||
public override IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods)
|
||||
{
|
||||
if (mods.HasFlag(LegacyMods.Nightcore))
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 System.Diagnostics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
@ -21,11 +20,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
public override bool DisplayResult => false;
|
||||
|
||||
public DrawableNote Head => headContainer.Child;
|
||||
public DrawableNote Tail => tailContainer.Child;
|
||||
public DrawableHoldNoteHead Head => headContainer.Child;
|
||||
public DrawableHoldNoteTail Tail => tailContainer.Child;
|
||||
|
||||
private readonly Container<DrawableHeadNote> headContainer;
|
||||
private readonly Container<DrawableTailNote> tailContainer;
|
||||
private readonly Container<DrawableHoldNoteHead> headContainer;
|
||||
private readonly Container<DrawableHoldNoteTail> tailContainer;
|
||||
private readonly Container<DrawableHoldNoteTick> tickContainer;
|
||||
|
||||
private readonly BodyPiece bodyPiece;
|
||||
@ -33,12 +32,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
/// <summary>
|
||||
/// Time at which the user started holding this hold note. Null if the user is not holding this hold note.
|
||||
/// </summary>
|
||||
private double? holdStartTime;
|
||||
public double? HoldStartTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the hold note has been released too early and shouldn't give full score for the release.
|
||||
/// </summary>
|
||||
private bool hasBroken;
|
||||
public bool HasBroken { get; private set; }
|
||||
|
||||
public DrawableHoldNote(HoldNote hitObject)
|
||||
: base(hitObject)
|
||||
@ -49,8 +48,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
bodyPiece = new BodyPiece { RelativeSizeAxes = Axes.X },
|
||||
tickContainer = new Container<DrawableHoldNoteTick> { RelativeSizeAxes = Axes.Both },
|
||||
headContainer = new Container<DrawableHeadNote> { RelativeSizeAxes = Axes.Both },
|
||||
tailContainer = new Container<DrawableTailNote> { RelativeSizeAxes = Axes.Both },
|
||||
headContainer = new Container<DrawableHoldNoteHead> { RelativeSizeAxes = Axes.Both },
|
||||
tailContainer = new Container<DrawableHoldNoteTail> { RelativeSizeAxes = Axes.Both },
|
||||
});
|
||||
|
||||
AccentColour.BindValueChanged(colour =>
|
||||
@ -65,11 +64,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
|
||||
switch (hitObject)
|
||||
{
|
||||
case DrawableHeadNote head:
|
||||
case DrawableHoldNoteHead head:
|
||||
headContainer.Child = head;
|
||||
break;
|
||||
|
||||
case DrawableTailNote tail:
|
||||
case DrawableHoldNoteTail tail:
|
||||
tailContainer.Child = tail;
|
||||
break;
|
||||
|
||||
@ -92,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
switch (hitObject)
|
||||
{
|
||||
case TailNote _:
|
||||
return new DrawableTailNote(this)
|
||||
return new DrawableHoldNoteTail(this)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
@ -100,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
};
|
||||
|
||||
case Note _:
|
||||
return new DrawableHeadNote(this)
|
||||
return new DrawableHoldNoteHead(this)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
@ -110,7 +109,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
case HoldNoteTick tick:
|
||||
return new DrawableHoldNoteTick(tick)
|
||||
{
|
||||
HoldStartTime = () => holdStartTime,
|
||||
HoldStartTime = () => HoldStartTime,
|
||||
AccentColour = { BindTarget = AccentColour }
|
||||
};
|
||||
}
|
||||
@ -125,12 +124,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
bodyPiece.Anchor = bodyPiece.Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (Tail.AllJudged)
|
||||
ApplyResult(r => r.Type = HitResult.Perfect);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -146,146 +139,64 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
base.UpdateStateTransforms(state);
|
||||
}
|
||||
|
||||
protected void BeginHold()
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
holdStartTime = Time.Current;
|
||||
bodyPiece.Hitting = true;
|
||||
}
|
||||
if (Tail.AllJudged)
|
||||
ApplyResult(r => r.Type = HitResult.Perfect);
|
||||
|
||||
protected void EndHold()
|
||||
{
|
||||
holdStartTime = null;
|
||||
bodyPiece.Hitting = false;
|
||||
if (Tail.Result.Type == HitResult.Miss)
|
||||
HasBroken = true;
|
||||
}
|
||||
|
||||
public bool OnPressed(ManiaAction action)
|
||||
{
|
||||
// Make sure the action happened within the body of the hold note
|
||||
if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime)
|
||||
if (AllJudged)
|
||||
return false;
|
||||
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
// The user has pressed during the body of the hold note, after the head note and its hit windows have passed
|
||||
// and within the limited range of the above if-statement. This state will be managed by the head note if the
|
||||
// user has pressed during the hit windows of the head note.
|
||||
BeginHold();
|
||||
beginHoldAt(Time.Current - Head.HitObject.StartTime);
|
||||
Head.UpdateResult();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void beginHoldAt(double timeOffset)
|
||||
{
|
||||
if (timeOffset < -Head.HitObject.HitWindows.WindowFor(HitResult.Miss))
|
||||
return;
|
||||
|
||||
HoldStartTime = Time.Current;
|
||||
bodyPiece.Hitting = true;
|
||||
}
|
||||
|
||||
public bool OnReleased(ManiaAction action)
|
||||
{
|
||||
// Make sure that the user started holding the key during the hold note
|
||||
if (!holdStartTime.HasValue)
|
||||
if (AllJudged)
|
||||
return false;
|
||||
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
EndHold();
|
||||
// Make sure a hold was started
|
||||
if (HoldStartTime == null)
|
||||
return false;
|
||||
|
||||
Tail.UpdateResult();
|
||||
endHold();
|
||||
|
||||
// If the key has been released too early, the user should not receive full score for the release
|
||||
if (!Tail.IsHit)
|
||||
hasBroken = true;
|
||||
HasBroken = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The head note of a hold.
|
||||
/// </summary>
|
||||
private class DrawableHeadNote : DrawableNote
|
||||
private void endHold()
|
||||
{
|
||||
private readonly DrawableHoldNote holdNote;
|
||||
|
||||
public DrawableHeadNote(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Head)
|
||||
{
|
||||
this.holdNote = holdNote;
|
||||
}
|
||||
|
||||
public override bool OnPressed(ManiaAction action)
|
||||
{
|
||||
if (!base.OnPressed(action))
|
||||
return false;
|
||||
|
||||
// If the key has been released too early, the user should not receive full score for the release
|
||||
if (Result.Type == HitResult.Miss)
|
||||
holdNote.hasBroken = true;
|
||||
|
||||
// The head note also handles early hits before the body, but we want accurate early hits to count as the body being held
|
||||
// The body doesn't handle these early early hits, so we have to explicitly set the holding state here
|
||||
holdNote.BeginHold();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The tail note of a hold.
|
||||
/// </summary>
|
||||
private class DrawableTailNote : DrawableNote
|
||||
{
|
||||
/// <summary>
|
||||
/// Lenience of release hit windows. This is to make cases where the hold note release
|
||||
/// is timed alongside presses of other hit objects less awkward.
|
||||
/// Todo: This shouldn't exist for non-LegacyBeatmapDecoder beatmaps
|
||||
/// </summary>
|
||||
private const double release_window_lenience = 1.5;
|
||||
|
||||
private readonly DrawableHoldNote holdNote;
|
||||
|
||||
public DrawableTailNote(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Tail)
|
||||
{
|
||||
this.holdNote = holdNote;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
Debug.Assert(HitObject.HitWindows != null);
|
||||
|
||||
// Factor in the release lenience
|
||||
timeOffset /= release_window_lenience;
|
||||
|
||||
if (!userTriggered)
|
||||
{
|
||||
if (!HitObject.HitWindows.CanBeHit(timeOffset))
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
||||
if (result == HitResult.None)
|
||||
return;
|
||||
|
||||
ApplyResult(r =>
|
||||
{
|
||||
if (holdNote.hasBroken && (result == HitResult.Perfect || result == HitResult.Perfect))
|
||||
result = HitResult.Good;
|
||||
|
||||
r.Type = result;
|
||||
});
|
||||
}
|
||||
|
||||
public override bool OnPressed(ManiaAction action) => false; // Tail doesn't handle key down
|
||||
|
||||
public override bool OnReleased(ManiaAction action)
|
||||
{
|
||||
// Make sure that the user started holding the key during the hold note
|
||||
if (!holdNote.holdStartTime.HasValue)
|
||||
return false;
|
||||
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
UpdateResult(true);
|
||||
|
||||
// Handled by the hold note, which will set holding = false
|
||||
return false;
|
||||
}
|
||||
HoldStartTime = null;
|
||||
bodyPiece.Hitting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
/// <summary>
|
||||
/// The head of a <see cref="DrawableHoldNote"/>.
|
||||
/// </summary>
|
||||
public class DrawableHoldNoteHead : DrawableNote
|
||||
{
|
||||
public DrawableHoldNoteHead(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Head)
|
||||
{
|
||||
}
|
||||
|
||||
public void UpdateResult() => base.UpdateResult(true);
|
||||
|
||||
public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
|
||||
|
||||
public override bool OnReleased(ManiaAction action) => false; // Handled by the hold note
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
// 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 System.Diagnostics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
/// <summary>
|
||||
/// The tail of a <see cref="DrawableHoldNote"/>.
|
||||
/// </summary>
|
||||
public class DrawableHoldNoteTail : DrawableNote
|
||||
{
|
||||
/// <summary>
|
||||
/// Lenience of release hit windows. This is to make cases where the hold note release
|
||||
/// is timed alongside presses of other hit objects less awkward.
|
||||
/// Todo: This shouldn't exist for non-LegacyBeatmapDecoder beatmaps
|
||||
/// </summary>
|
||||
private const double release_window_lenience = 1.5;
|
||||
|
||||
private readonly DrawableHoldNote holdNote;
|
||||
|
||||
public DrawableHoldNoteTail(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Tail)
|
||||
{
|
||||
this.holdNote = holdNote;
|
||||
}
|
||||
|
||||
public void UpdateResult() => base.UpdateResult(true);
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
Debug.Assert(HitObject.HitWindows != null);
|
||||
|
||||
// Factor in the release lenience
|
||||
timeOffset /= release_window_lenience;
|
||||
|
||||
if (!userTriggered)
|
||||
{
|
||||
if (!HitObject.HitWindows.CanBeHit(timeOffset))
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
||||
if (result == HitResult.None)
|
||||
return;
|
||||
|
||||
ApplyResult(r =>
|
||||
{
|
||||
// If the head wasn't hit or the hold note was broken, cap the max score to Meh.
|
||||
if (result > HitResult.Meh && (!holdNote.Head.IsHit || holdNote.HasBroken))
|
||||
result = HitResult.Meh;
|
||||
|
||||
r.Type = result;
|
||||
});
|
||||
}
|
||||
|
||||
public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
|
||||
|
||||
public override bool OnReleased(ManiaAction action) => false; // Handled by the hold note
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Scoring
|
||||
{
|
||||
public class ManiaHealthProcessor : HealthProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// The hit HP multiplier at OD = 0.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_min = 0.75;
|
||||
|
||||
/// <summary>
|
||||
/// The hit HP multiplier at OD = 0.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_mid = 0.85;
|
||||
|
||||
/// <summary>
|
||||
/// The hit HP multiplier at OD = 0.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_max = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The MISS HP multiplier at OD = 0.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_miss_min = 0.5;
|
||||
|
||||
/// <summary>
|
||||
/// The MISS HP multiplier at OD = 5.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_miss_mid = 0.75;
|
||||
|
||||
/// <summary>
|
||||
/// The MISS HP multiplier at OD = 10.
|
||||
/// </summary>
|
||||
private const double hp_multiplier_miss_max = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The MISS HP multiplier. This is multiplied to the miss hp increase.
|
||||
/// </summary>
|
||||
private double hpMissMultiplier = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The HIT HP multiplier. This is multiplied to hit hp increases.
|
||||
/// </summary>
|
||||
private double hpMultiplier = 1;
|
||||
|
||||
public ManiaHealthProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
BeatmapDifficulty difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max);
|
||||
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max);
|
||||
}
|
||||
|
||||
protected override double HealthAdjustmentFactorFor(JudgementResult result)
|
||||
=> result.Type == HitResult.Miss ? hpMissMultiplier : hpMultiplier;
|
||||
}
|
||||
}
|
@ -1,18 +1,12 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Scoring
|
||||
{
|
||||
internal class ManiaScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public ManiaScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
public override HitWindows CreateHitWindows() => new ManiaHitWindows();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
// 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.Textures;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class ManiaLegacySkinTransformer : ISkin
|
||||
{
|
||||
private readonly ISkin source;
|
||||
|
||||
public ManiaLegacySkinTransformer(ISkin source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
case GameplaySkinComponent<HitResult> resultComponent:
|
||||
return getResult(resultComponent);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable getResult(GameplaySkinComponent<HitResult> resultComponent)
|
||||
{
|
||||
switch (resultComponent.Component)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
return this.GetAnimation("mania-hit0", true, true);
|
||||
|
||||
case HitResult.Meh:
|
||||
return this.GetAnimation("mania-hit50", true, true);
|
||||
|
||||
case HitResult.Ok:
|
||||
return this.GetAnimation("mania-hit100", true, true);
|
||||
|
||||
case HitResult.Good:
|
||||
return this.GetAnimation("mania-hit200", true, true);
|
||||
|
||||
case HitResult.Great:
|
||||
return this.GetAnimation("mania-hit300", true, true);
|
||||
|
||||
case HitResult.Perfect:
|
||||
return this.GetAnimation("mania-hit300g", true, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sample) => source.GetSample(sample);
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) =>
|
||||
source.GetConfig<TLookup, TValue>(lookup);
|
||||
}
|
||||
}
|
@ -27,22 +27,5 @@ namespace osu.Game.Rulesets.Osu.Judgements
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
||||
protected override double HealthIncreaseFor(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
return -0.02;
|
||||
|
||||
case HitResult.Meh:
|
||||
case HitResult.Good:
|
||||
case HitResult.Great:
|
||||
return 0.01;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
base.TransferSettings(difficulty);
|
||||
|
||||
CircleSize.Value = CircleSize.Default = difficulty.CircleSize;
|
||||
ApproachRate.Value = ApproachRate.Default = difficulty.ApproachRate;
|
||||
TransferSetting(CircleSize, difficulty.CircleSize);
|
||||
TransferSetting(ApproachRate, difficulty.ApproachRate);
|
||||
}
|
||||
|
||||
protected override void ApplySettings(BeatmapDifficulty difficulty)
|
||||
|
@ -36,9 +36,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(IBeatmap beatmap) => new OsuScoreProcessor(beatmap);
|
||||
|
||||
public override HealthProcessor CreateHealthProcessor(IBeatmap beatmap) => new OsuHealthProcessor(beatmap);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor();
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap, this);
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
public class OsuHealthProcessor : HealthProcessor
|
||||
{
|
||||
public OsuHealthProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
private float hpDrainRate;
|
||||
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate;
|
||||
}
|
||||
|
||||
protected override double HealthAdjustmentFactorFor(JudgementResult result)
|
||||
{
|
||||
switch (result.Type)
|
||||
{
|
||||
case HitResult.Great:
|
||||
return 10.2 - hpDrainRate;
|
||||
|
||||
case HitResult.Good:
|
||||
return 8 - hpDrainRate;
|
||||
|
||||
case HitResult.Meh:
|
||||
return 4 - hpDrainRate;
|
||||
|
||||
// case HitResult.SliderTick:
|
||||
// return Math.Max(7 - hpDrainRate, 0) * 0.01;
|
||||
|
||||
case HitResult.Miss:
|
||||
return hpDrainRate;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement) => new OsuJudgementResult(hitObject, judgement);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
@ -11,11 +10,6 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
internal class OsuScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public OsuScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement) => new OsuJudgementResult(hitObject, judgement);
|
||||
|
||||
public override HitWindows CreateHitWindows() => new OsuHitWindows();
|
||||
|
@ -9,18 +9,17 @@ using osu.Game.Rulesets.Taiko.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
{
|
||||
public class TaikoHealthProcessor : HealthProcessor
|
||||
/// <summary>
|
||||
/// A <see cref="HealthProcessor"/> for the taiko ruleset.
|
||||
/// Taiko fails if the player has not half-filled their health by the end of the map.
|
||||
/// </summary>
|
||||
public class TaikoHealthProcessor : AccumulatingHealthProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// A value used for calculating <see cref="hpMultiplier"/>.
|
||||
/// </summary>
|
||||
private const double object_count_factor = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Taiko fails at the end of the map if the player has not half-filled their HP bar.
|
||||
/// </summary>
|
||||
protected override bool DefaultFailCondition => JudgedHits == MaxHits && Health.Value <= 0.5;
|
||||
|
||||
/// <summary>
|
||||
/// HP multiplier for a successful <see cref="HitResult"/>.
|
||||
/// </summary>
|
||||
@ -31,28 +30,20 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
/// </summary>
|
||||
private double hpMissMultiplier;
|
||||
|
||||
public TaikoHealthProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
public TaikoHealthProcessor()
|
||||
: base(0.5)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
hpMultiplier = 1 / (object_count_factor * beatmap.HitObjects.OfType<Hit>().Count() * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98));
|
||||
|
||||
hpMissMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.0018, 0.0075, 0.0120);
|
||||
}
|
||||
|
||||
protected override double HealthAdjustmentFactorFor(JudgementResult result)
|
||||
=> result.Type == HitResult.Miss ? hpMissMultiplier : hpMultiplier;
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
||||
Health.Value = 0;
|
||||
}
|
||||
protected override double GetHealthIncreaseFor(JudgementResult result)
|
||||
=> base.GetHealthIncreaseFor(result) * (result.Type == HitResult.Miss ? hpMissMultiplier : hpMultiplier);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,12 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
{
|
||||
internal class TaikoScoreProcessor : ScoreProcessor
|
||||
{
|
||||
public TaikoScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
public override HitWindows CreateHitWindows() => new TaikoHitWindows();
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(IBeatmap beatmap) => new TaikoScoreProcessor(beatmap);
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
|
||||
|
||||
public override HealthProcessor CreateHealthProcessor(IBeatmap beatmap) => new TaikoHealthProcessor(beatmap);
|
||||
public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new TaikoHealthProcessor();
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
|
||||
|
||||
|
159
osu.Game.Tests/Gameplay/TestSceneDrainingHealthProcessor.cs
Normal file
159
osu.Game.Tests/Gameplay/TestSceneDrainingHealthProcessor.cs
Normal file
@ -0,0 +1,159 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneDrainingHealthProcessor : OsuTestScene
|
||||
{
|
||||
private Bindable<bool> breakTime;
|
||||
private HealthProcessor processor;
|
||||
private ManualClock clock;
|
||||
|
||||
[Test]
|
||||
public void TestInitialHealthStartsAtOne()
|
||||
{
|
||||
createProcessor(createBeatmap(1000, 2000));
|
||||
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthNotDrainedBeforeGameplayStart()
|
||||
{
|
||||
createProcessor(createBeatmap(1000, 2000));
|
||||
|
||||
setTime(100);
|
||||
assertHealthEqualTo(1);
|
||||
setTime(900);
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthNotDrainedAfterGameplayEnd()
|
||||
{
|
||||
createProcessor(createBeatmap(1000, 2000));
|
||||
setTime(2001); // After the hitobjects
|
||||
setHealth(1); // Reset the current health for assertions to take place
|
||||
|
||||
setTime(2100);
|
||||
assertHealthEqualTo(1);
|
||||
setTime(3000);
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthNotDrainedDuringBreak()
|
||||
{
|
||||
createProcessor(createBeatmap(0, 2000));
|
||||
setBreak(true);
|
||||
|
||||
setTime(700);
|
||||
assertHealthEqualTo(1);
|
||||
setTime(900);
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthDrainedDuringGameplay()
|
||||
{
|
||||
createProcessor(createBeatmap(0, 1000));
|
||||
|
||||
setTime(500);
|
||||
assertHealthNotEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthGainedAfterRewind()
|
||||
{
|
||||
createProcessor(createBeatmap(0, 1000));
|
||||
setTime(500);
|
||||
|
||||
setTime(0);
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthGainedOnHit()
|
||||
{
|
||||
Beatmap beatmap = createBeatmap(0, 1000);
|
||||
|
||||
createProcessor(beatmap);
|
||||
setTime(10); // Decrease health slightly
|
||||
assertHealthNotEqualTo(1);
|
||||
|
||||
AddStep("apply hit result", () => processor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new Judgement()) { Type = HitResult.Perfect }));
|
||||
assertHealthEqualTo(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthRemovedOnRevert()
|
||||
{
|
||||
var beatmap = createBeatmap(0, 1000);
|
||||
JudgementResult result = null;
|
||||
|
||||
createProcessor(beatmap);
|
||||
setTime(10); // Decrease health slightly
|
||||
AddStep("apply hit result", () => processor.ApplyResult(result = new JudgementResult(beatmap.HitObjects[0], new Judgement()) { Type = HitResult.Perfect }));
|
||||
|
||||
AddStep("revert hit result", () => processor.RevertResult(result));
|
||||
assertHealthNotEqualTo(1);
|
||||
}
|
||||
|
||||
private Beatmap createBeatmap(double startTime, double endTime)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
BeatmapInfo = { BaseDifficulty = { DrainRate = 5 } },
|
||||
};
|
||||
|
||||
for (double time = startTime; time <= endTime; time += 100)
|
||||
beatmap.HitObjects.Add(new JudgeableHitObject { StartTime = time });
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
private void createProcessor(Beatmap beatmap) => AddStep("create processor", () =>
|
||||
{
|
||||
breakTime = new Bindable<bool>();
|
||||
|
||||
Child = processor = new DrainingHealthProcessor(beatmap.HitObjects[0].StartTime).With(d =>
|
||||
{
|
||||
d.RelativeSizeAxes = Axes.Both;
|
||||
d.Clock = new FramedClock(clock = new ManualClock());
|
||||
});
|
||||
|
||||
processor.IsBreakTime.BindTo(breakTime);
|
||||
processor.ApplyBeatmap(beatmap);
|
||||
});
|
||||
|
||||
private void setTime(double time) => AddStep($"set time = {time}", () => clock.CurrentTime = time);
|
||||
|
||||
private void setHealth(double health) => AddStep($"set health = {health}", () => processor.Health.Value = health);
|
||||
|
||||
private void setBreak(bool enabled) => AddStep($"{(enabled ? "enable" : "disable")} break", () => breakTime.Value = enabled);
|
||||
|
||||
private void assertHealthEqualTo(double value)
|
||||
=> AddAssert($"health = {value}", () => Precision.AlmostEquals(value, processor.Health.Value, 0.0001f));
|
||||
|
||||
private void assertHealthNotEqualTo(double value)
|
||||
=> AddAssert($"health != {value}", () => !Precision.AlmostEquals(value, processor.Health.Value, 0.0001f));
|
||||
|
||||
private class JudgeableHitObject : HitObject
|
||||
{
|
||||
public override Judgement CreateJudgement() => new Judgement();
|
||||
}
|
||||
}
|
||||
}
|
@ -259,6 +259,9 @@ namespace osu.Game.Database
|
||||
/// <summary>
|
||||
/// Create a SHA-2 hash from the provided archive based on file content of all files matching <see cref="HashableFileTypes"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In the case of no matching files, a hash will be generated from the passed archive's <see cref="ArchiveReader.Name"/>.
|
||||
/// </remarks>
|
||||
private string computeHash(ArchiveReader reader)
|
||||
{
|
||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||
@ -270,7 +273,7 @@ namespace osu.Game.Database
|
||||
s.CopyTo(hashable);
|
||||
}
|
||||
|
||||
return hashable.Length > 0 ? hashable.ComputeSHA2Hash() : null;
|
||||
return hashable.Length > 0 ? hashable.ComputeSHA2Hash() : reader.Name.ComputeSHA2Hash();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
@ -13,15 +14,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour
|
||||
{
|
||||
public const float ICON_WIDTH = ICON_SIZE + icon_spacing;
|
||||
public const float ICON_WIDTH = ICON_SIZE + spacing;
|
||||
|
||||
public const float ICON_SIZE = 25;
|
||||
private const float spacing = 6;
|
||||
private const int text_offset = 2;
|
||||
|
||||
private SpriteIcon iconSprite;
|
||||
private readonly OsuSpriteText titleText, pageText;
|
||||
|
||||
private const float icon_spacing = 10;
|
||||
|
||||
protected IconUsage Icon
|
||||
{
|
||||
set
|
||||
@ -63,26 +64,35 @@ namespace osu.Game.Graphics.UserInterface
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(icon_spacing, 0),
|
||||
Spacing = new Vector2(spacing, 0),
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
CreateIcon(),
|
||||
new FillFlowContainer
|
||||
CreateIcon().With(t =>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(6, 0),
|
||||
Children = new[]
|
||||
{
|
||||
titleText = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
|
||||
},
|
||||
pageText = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
|
||||
}
|
||||
}
|
||||
t.Anchor = Anchor.Centre;
|
||||
t.Origin = Anchor.Centre;
|
||||
}),
|
||||
titleText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Bottom = text_offset }
|
||||
},
|
||||
new Circle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(4),
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
pageText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 20),
|
||||
Margin = new MarginPadding { Bottom = text_offset }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -4,7 +4,6 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osuTK;
|
||||
@ -16,8 +15,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public class ScreenTitleTextureIcon : CompositeDrawable
|
||||
{
|
||||
private const float circle_allowance = 0.8f;
|
||||
|
||||
private readonly string textureName;
|
||||
|
||||
public ScreenTitleTextureIcon(string textureName)
|
||||
@ -26,38 +23,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures, OsuColour colours)
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Size = new Vector2(ScreenTitle.ICON_SIZE / circle_allowance);
|
||||
Size = new Vector2(ScreenTitle.ICON_SIZE);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
InternalChild = new Sprite
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
BorderColour = colours.Violet,
|
||||
BorderThickness = 3,
|
||||
MaskingSmoothness = 1,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get(textureName),
|
||||
Size = new Vector2(circle_allowance),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Violet,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
}
|
||||
},
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get(textureName),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fit
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ using osu.Game.Online.Chat;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Utils;
|
||||
@ -204,6 +205,7 @@ namespace osu.Game
|
||||
|
||||
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);
|
||||
|
||||
SelectedMods.BindValueChanged(modsChanged);
|
||||
Beatmap.BindValueChanged(beatmapChanged, true);
|
||||
}
|
||||
|
||||
@ -403,9 +405,29 @@ namespace osu.Game
|
||||
oldBeatmap.Track.Completed -= currentTrackCompleted;
|
||||
}
|
||||
|
||||
updateModDefaults();
|
||||
|
||||
nextBeatmap?.LoadBeatmapAsync();
|
||||
}
|
||||
|
||||
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||
{
|
||||
updateModDefaults();
|
||||
}
|
||||
|
||||
private void updateModDefaults()
|
||||
{
|
||||
BeatmapDifficulty baseDifficulty = Beatmap.Value.BeatmapInfo.BaseDifficulty;
|
||||
|
||||
if (baseDifficulty != null && SelectedMods.Value.Any(m => m is IApplicableToDifficulty))
|
||||
{
|
||||
var adjustedDifficulty = baseDifficulty.Clone();
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDifficulty>())
|
||||
mod.ReadFromDifficulty(adjustedDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
private void currentTrackCompleted() => Schedule(() =>
|
||||
{
|
||||
if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled)
|
||||
|
@ -47,6 +47,8 @@ namespace osu.Game.Overlays.Changelog
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
TabControl.AccentColour = colours.Violet;
|
||||
TitleBackgroundColour = colours.GreyVioletDarker;
|
||||
ControlBackgroundColour = colours.GreyVioletDark;
|
||||
}
|
||||
|
||||
private ChangelogHeaderTitle title;
|
||||
@ -111,7 +113,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
|
||||
public ChangelogHeaderTitle()
|
||||
{
|
||||
Title = "Changelog";
|
||||
Title = "changelog";
|
||||
Version = null;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
@ -15,7 +14,7 @@ namespace osu.Game.Overlays.News
|
||||
{
|
||||
public class NewsHeader : OverlayHeader
|
||||
{
|
||||
private const string front_page_string = "Front Page";
|
||||
private const string front_page_string = "frontpage";
|
||||
|
||||
private NewsHeaderTitle title;
|
||||
|
||||
@ -33,16 +32,18 @@ namespace osu.Game.Overlays.News
|
||||
ShowFrontPage?.Invoke();
|
||||
};
|
||||
|
||||
Current.ValueChanged += showArticle;
|
||||
Current.ValueChanged += showPost;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
TabControl.AccentColour = colour.Violet;
|
||||
TabControl.AccentColour = colours.Violet;
|
||||
TitleBackgroundColour = colours.GreyVioletDarker;
|
||||
ControlBackgroundColour = colours.GreyVioletDark;
|
||||
}
|
||||
|
||||
private void showArticle(ValueChangedEvent<string> e)
|
||||
private void showPost(ValueChangedEvent<string> e)
|
||||
{
|
||||
if (e.OldValue != null)
|
||||
TabControl.RemoveItem(e.OldValue);
|
||||
@ -52,19 +53,17 @@ namespace osu.Game.Overlays.News
|
||||
TabControl.AddItem(e.NewValue);
|
||||
TabControl.Current.Value = e.NewValue;
|
||||
|
||||
title.IsReadingArticle = true;
|
||||
title.IsReadingPost = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TabControl.Current.Value = front_page_string;
|
||||
title.IsReadingArticle = false;
|
||||
title.IsReadingPost = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new NewsHeaderBackground();
|
||||
|
||||
protected override Drawable CreateContent() => new Container();
|
||||
|
||||
protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle();
|
||||
|
||||
private class NewsHeaderBackground : Sprite
|
||||
@ -84,17 +83,17 @@ namespace osu.Game.Overlays.News
|
||||
|
||||
private class NewsHeaderTitle : ScreenTitle
|
||||
{
|
||||
private const string article_string = "Article";
|
||||
private const string post_string = "post";
|
||||
|
||||
public bool IsReadingArticle
|
||||
public bool IsReadingPost
|
||||
{
|
||||
set => Section = value ? article_string : front_page_string;
|
||||
set => Section = value ? post_string : front_page_string;
|
||||
}
|
||||
|
||||
public NewsHeaderTitle()
|
||||
{
|
||||
Title = "News";
|
||||
IsReadingArticle = false;
|
||||
Title = "news";
|
||||
IsReadingPost = false;
|
||||
}
|
||||
|
||||
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news");
|
||||
|
@ -1,9 +1,12 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -11,59 +14,96 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
protected readonly OverlayHeaderTabControl TabControl;
|
||||
|
||||
private const float cover_height = 150;
|
||||
private const float cover_info_height = 75;
|
||||
private readonly Box titleBackground;
|
||||
private readonly Box controlBackground;
|
||||
private readonly Container background;
|
||||
|
||||
protected Color4 TitleBackgroundColour
|
||||
{
|
||||
set => titleBackground.Colour = value;
|
||||
}
|
||||
|
||||
protected Color4 ControlBackgroundColour
|
||||
{
|
||||
set => controlBackground.Colour = value;
|
||||
}
|
||||
|
||||
protected float BackgroundHeight
|
||||
{
|
||||
set => background.Height = value;
|
||||
}
|
||||
|
||||
protected OverlayHeader()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
new Container
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_height,
|
||||
Masking = true,
|
||||
Child = CreateBackground()
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Y = cover_height,
|
||||
Height = cover_info_height,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Depth = -float.MaxValue,
|
||||
Children = new Drawable[]
|
||||
background = new Container
|
||||
{
|
||||
CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH),
|
||||
TabControl = new OverlayHeaderTabControl
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 80,
|
||||
Masking = true,
|
||||
Child = CreateBackground()
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_info_height - 30,
|
||||
Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }
|
||||
titleBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
CreateTitle().With(title =>
|
||||
{
|
||||
title.Margin = new MarginPadding
|
||||
{
|
||||
Vertical = 10,
|
||||
Left = UserProfileOverlay.CONTENT_X_MARGIN
|
||||
};
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Margin = new MarginPadding { Top = cover_height },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = CreateContent()
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Depth = -float.MaxValue,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
controlBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
TabControl = new OverlayHeaderTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 30,
|
||||
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||
}
|
||||
}
|
||||
},
|
||||
CreateContent()
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateBackground();
|
||||
|
||||
protected abstract Drawable CreateContent();
|
||||
[NotNull]
|
||||
protected virtual Drawable CreateContent() => new Container();
|
||||
|
||||
protected abstract ScreenTitle CreateTitle();
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
public ProfileHeader()
|
||||
{
|
||||
BackgroundHeight = 150;
|
||||
|
||||
User.ValueChanged += e => updateDisplay(e.NewValue);
|
||||
|
||||
TabControl.AddItem("Info");
|
||||
@ -38,6 +40,8 @@ namespace osu.Game.Overlays.Profile
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
TabControl.AccentColour = colours.Seafoam;
|
||||
TitleBackgroundColour = colours.GreySeafoamDarker;
|
||||
ControlBackgroundColour = colours.GreySeafoam;
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() =>
|
||||
@ -101,8 +105,8 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
public ProfileHeaderTitle()
|
||||
{
|
||||
Title = "Player";
|
||||
Section = "Info";
|
||||
Title = "player";
|
||||
Section = "info";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -110,6 +114,8 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
AccentColour = colours.Seafoam;
|
||||
}
|
||||
|
||||
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/profile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,12 @@ namespace osu.Game.Rulesets.Judgements
|
||||
/// </summary>
|
||||
public class Judgement
|
||||
{
|
||||
/// <summary>
|
||||
/// The default health increase for a maximum judgement, as a proportion of total health.
|
||||
/// By default, each maximum judgement restores 5% of total health.
|
||||
/// </summary>
|
||||
protected const double DEFAULT_MAX_HEALTH_INCREASE = 0.05;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum <see cref="HitResult"/> that can be achieved.
|
||||
/// </summary>
|
||||
@ -55,7 +61,32 @@ namespace osu.Game.Rulesets.Judgements
|
||||
/// </summary>
|
||||
/// <param name="result">The <see cref="HitResult"/> to find the numeric health increase for.</param>
|
||||
/// <returns>The numeric health increase of <paramref name="result"/>.</returns>
|
||||
protected virtual double HealthIncreaseFor(HitResult result) => 0;
|
||||
protected virtual double HealthIncreaseFor(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Miss:
|
||||
return -DEFAULT_MAX_HEALTH_INCREASE;
|
||||
|
||||
case HitResult.Meh:
|
||||
return -DEFAULT_MAX_HEALTH_INCREASE * 0.05;
|
||||
|
||||
case HitResult.Ok:
|
||||
return -DEFAULT_MAX_HEALTH_INCREASE * 0.01;
|
||||
|
||||
case HitResult.Good:
|
||||
return DEFAULT_MAX_HEALTH_INCREASE * 0.3;
|
||||
|
||||
case HitResult.Great:
|
||||
return DEFAULT_MAX_HEALTH_INCREASE;
|
||||
|
||||
case HitResult.Perfect:
|
||||
return DEFAULT_MAX_HEALTH_INCREASE * 1.05;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the numeric health increase of a <see cref="JudgementResult"/>.
|
||||
|
@ -10,6 +10,17 @@ namespace osu.Game.Rulesets.Mods
|
||||
/// </summary>
|
||||
public interface IApplicableToDifficulty : IApplicableMod
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when a beatmap is changed. Can be used to read default values.
|
||||
/// Any changes made will not be preserved.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The difficulty to read from.</param>
|
||||
void ReadFromDifficulty(BeatmapDifficulty difficulty);
|
||||
|
||||
/// <summary>
|
||||
/// Called post beatmap conversion. Can be used to apply changes to difficulty attributes.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The difficulty to mutate.</param>
|
||||
void ApplyToDifficulty(BeatmapDifficulty difficulty);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
@ -47,25 +48,48 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
private BeatmapDifficulty difficulty;
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||
public void ReadFromDifficulty(BeatmapDifficulty difficulty)
|
||||
{
|
||||
if (this.difficulty == null || this.difficulty.ID != difficulty.ID)
|
||||
{
|
||||
this.difficulty = difficulty;
|
||||
TransferSettings(difficulty);
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
else
|
||||
ApplySettings(difficulty);
|
||||
}
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty) => ApplySettings(difficulty);
|
||||
|
||||
/// <summary>
|
||||
/// Transfer initial settings from the beatmap to settings.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The beatmap's initial values.</param>
|
||||
protected virtual void TransferSettings(BeatmapDifficulty difficulty)
|
||||
{
|
||||
DrainRate.Value = DrainRate.Default = difficulty.DrainRate;
|
||||
OverallDifficulty.Value = OverallDifficulty.Default = difficulty.OverallDifficulty;
|
||||
TransferSetting(DrainRate, difficulty.DrainRate);
|
||||
TransferSetting(OverallDifficulty, difficulty.OverallDifficulty);
|
||||
}
|
||||
|
||||
private readonly Dictionary<IBindable, bool> userChangedSettings = new Dictionary<IBindable, bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Transfer a setting from <see cref="BeatmapDifficulty"/> to a configuration bindable.
|
||||
/// Only performs the transfer if the user it not currently overriding..
|
||||
/// </summary>
|
||||
protected void TransferSetting<T>(BindableNumber<T> bindable, T beatmapDefault)
|
||||
where T : struct, IComparable<T>, IConvertible, IEquatable<T>
|
||||
{
|
||||
bindable.UnbindEvents();
|
||||
|
||||
userChangedSettings.TryAdd(bindable, false);
|
||||
|
||||
bindable.Default = beatmapDefault;
|
||||
|
||||
// users generally choose a difficulty setting and want it to stick across multiple beatmap changes.
|
||||
// we only want to value transfer if the user hasn't changed the value previously.
|
||||
if (!userChangedSettings[bindable])
|
||||
bindable.Value = beatmapDefault;
|
||||
|
||||
bindable.ValueChanged += _ => userChangedSettings[bindable] = !bindable.IsDefault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
private BindableNumber<double> health;
|
||||
|
||||
public void ReadFromDifficulty(BeatmapDifficulty difficulty) { }
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||
{
|
||||
const float ratio = 0.5f;
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Description => "Everything just got a bit harder...";
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModDifficultyAdjust) };
|
||||
|
||||
public void ReadFromDifficulty(BeatmapDifficulty difficulty) { }
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||
{
|
||||
const float ratio = 1.4f;
|
||||
|
@ -71,16 +71,16 @@ namespace osu.Game.Rulesets
|
||||
public abstract DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ScoreProcessor"/> for a beatmap converted to this ruleset.
|
||||
/// Creates a <see cref="ScoreProcessor"/> for this <see cref="Ruleset"/>.
|
||||
/// </summary>
|
||||
/// <returns>The score processor.</returns>
|
||||
public virtual ScoreProcessor CreateScoreProcessor(IBeatmap beatmap) => new ScoreProcessor(beatmap);
|
||||
public virtual ScoreProcessor CreateScoreProcessor() => new ScoreProcessor();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="HealthProcessor"/> for a beatmap converted to this ruleset.
|
||||
/// Creates a <see cref="HealthProcessor"/> for this <see cref="Ruleset"/>.
|
||||
/// </summary>
|
||||
/// <returns>The health processor.</returns>
|
||||
public virtual HealthProcessor CreateHealthProcessor(IBeatmap beatmap) => new HealthProcessor(beatmap);
|
||||
public virtual HealthProcessor CreateHealthProcessor(double drainStartTime) => new DrainingHealthProcessor(drainStartTime);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||
|
32
osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs
Normal file
32
osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="HealthProcessor"/> that accumulates health and causes a fail if the final health
|
||||
/// is less than a value required to pass the beatmap.
|
||||
/// </summary>
|
||||
public class AccumulatingHealthProcessor : HealthProcessor
|
||||
{
|
||||
protected override bool DefaultFailCondition => JudgedHits == MaxHits && Health.Value < requiredHealth;
|
||||
|
||||
private readonly double requiredHealth;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AccumulatingHealthProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="requiredHealth">The minimum amount of health required to beatmap.</param>
|
||||
public AccumulatingHealthProcessor(double requiredHealth)
|
||||
{
|
||||
this.requiredHealth = requiredHealth;
|
||||
}
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
||||
Health.Value = 0;
|
||||
}
|
||||
}
|
||||
}
|
157
osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs
Normal file
157
osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs
Normal file
@ -0,0 +1,157 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="HealthProcessor"/> which continuously drains health.<br />
|
||||
/// At HP=0, the minimum health reached for a perfect play is 95%.<br />
|
||||
/// At HP=5, the minimum health reached for a perfect play is 70%.<br />
|
||||
/// At HP=10, the minimum health reached for a perfect play is 30%.
|
||||
/// </summary>
|
||||
public class DrainingHealthProcessor : HealthProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// A reasonable allowable error for the minimum health offset from <see cref="targetMinimumHealth"/>. A 1% error is unnoticeable.
|
||||
/// </summary>
|
||||
private const double minimum_health_error = 0.01;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum health target at an HP drain rate of 0.
|
||||
/// </summary>
|
||||
private const double min_health_target = 0.95;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum health target at an HP drain rate of 5.
|
||||
/// </summary>
|
||||
private const double mid_health_target = 0.70;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum health target at an HP drain rate of 10.
|
||||
/// </summary>
|
||||
private const double max_health_target = 0.30;
|
||||
|
||||
private IBeatmap beatmap;
|
||||
|
||||
private double gameplayEndTime;
|
||||
|
||||
private readonly double drainStartTime;
|
||||
|
||||
private readonly List<(double time, double health)> healthIncreases = new List<(double, double)>();
|
||||
private double targetMinimumHealth;
|
||||
private double drainRate = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DrainingHealthProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="drainStartTime">The time after which draining should begin.</param>
|
||||
public DrainingHealthProcessor(double drainStartTime)
|
||||
{
|
||||
this.drainStartTime = drainStartTime;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!IsBreakTime.Value)
|
||||
{
|
||||
// When jumping in and out of gameplay time within a single frame, health should only be drained for the period within the gameplay time
|
||||
double lastGameplayTime = Math.Clamp(Time.Current - Time.Elapsed, drainStartTime, gameplayEndTime);
|
||||
double currentGameplayTime = Math.Clamp(Time.Current, drainStartTime, gameplayEndTime);
|
||||
|
||||
Health.Value -= drainRate * (currentGameplayTime - lastGameplayTime);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
|
||||
if (beatmap.HitObjects.Count > 0)
|
||||
gameplayEndTime = beatmap.HitObjects[^1].GetEndTime();
|
||||
|
||||
targetMinimumHealth = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, min_health_target, mid_health_target, max_health_target);
|
||||
|
||||
base.ApplyBeatmap(beatmap);
|
||||
}
|
||||
|
||||
protected override void ApplyResultInternal(JudgementResult result)
|
||||
{
|
||||
base.ApplyResultInternal(result);
|
||||
healthIncreases.Add((result.HitObject.GetEndTime() + result.TimeOffset, GetHealthIncreaseFor(result)));
|
||||
}
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
||||
drainRate = 1;
|
||||
|
||||
if (storeResults)
|
||||
drainRate = computeDrainRate();
|
||||
|
||||
healthIncreases.Clear();
|
||||
}
|
||||
|
||||
private double computeDrainRate()
|
||||
{
|
||||
if (healthIncreases.Count == 0)
|
||||
return 0;
|
||||
|
||||
int adjustment = 1;
|
||||
double result = 1;
|
||||
|
||||
// Although we expect the following loop to converge within 30 iterations (health within 1/2^31 accuracy of the target),
|
||||
// we'll still keep a safety measure to avoid infinite loops by detecting overflows.
|
||||
while (adjustment > 0)
|
||||
{
|
||||
double currentHealth = 1;
|
||||
double lowestHealth = 1;
|
||||
int currentBreak = -1;
|
||||
|
||||
for (int i = 0; i < healthIncreases.Count; i++)
|
||||
{
|
||||
double currentTime = healthIncreases[i].time;
|
||||
double lastTime = i > 0 ? healthIncreases[i - 1].time : drainStartTime;
|
||||
|
||||
// Subtract any break time from the duration since the last object
|
||||
if (beatmap.Breaks.Count > 0)
|
||||
{
|
||||
// Advance the last break occuring before the current time
|
||||
while (currentBreak + 1 < beatmap.Breaks.Count && beatmap.Breaks[currentBreak + 1].EndTime < currentTime)
|
||||
currentBreak++;
|
||||
|
||||
if (currentBreak >= 0)
|
||||
lastTime = Math.Max(lastTime, beatmap.Breaks[currentBreak].EndTime);
|
||||
}
|
||||
|
||||
// Apply health adjustments
|
||||
currentHealth -= (healthIncreases[i].time - lastTime) * result;
|
||||
lowestHealth = Math.Min(lowestHealth, currentHealth);
|
||||
currentHealth = Math.Min(1, currentHealth + healthIncreases[i].health);
|
||||
|
||||
// Common scenario for when the drain rate is definitely too harsh
|
||||
if (lowestHealth < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// Stop if the resulting health is within a reasonable offset from the target
|
||||
if (Math.Abs(lowestHealth - targetMinimumHealth) <= minimum_health_error)
|
||||
break;
|
||||
|
||||
// This effectively works like a binary search - each iteration the search space moves closer to the target, but may exceed it.
|
||||
adjustment *= 2;
|
||||
result += 1.0 / adjustment * Math.Sign(lowestHealth - targetMinimumHealth);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,12 +4,11 @@
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
public class HealthProcessor : JudgementProcessor
|
||||
public abstract class HealthProcessor : JudgementProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when the <see cref="ScoreProcessor"/> is in a failed state.
|
||||
@ -27,16 +26,16 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
public readonly BindableDouble Health = new BindableDouble(1) { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
/// <summary>
|
||||
/// Whether gameplay is currently in a break.
|
||||
/// </summary>
|
||||
public readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ScoreProcessor has already triggered the failed state.
|
||||
/// </summary>
|
||||
public bool HasFailed { get; private set; }
|
||||
|
||||
public HealthProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyResultInternal(JudgementResult result)
|
||||
{
|
||||
result.HealthAtJudgement = Health.Value;
|
||||
@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
if (HasFailed)
|
||||
return;
|
||||
|
||||
Health.Value += HealthAdjustmentFactorFor(result) * result.Judgement.HealthIncreaseFor(result);
|
||||
Health.Value += GetHealthIncreaseFor(result);
|
||||
|
||||
if (!DefaultFailCondition && FailConditions?.Invoke(this, result) != true)
|
||||
return;
|
||||
@ -62,11 +61,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An adjustment factor which is multiplied into the health increase provided by a <see cref="JudgementResult"/>.
|
||||
/// Retrieves the health increase for a <see cref="JudgementResult"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The <see cref="JudgementResult"/> for which the adjustment should apply.</param>
|
||||
/// <returns>The adjustment factor.</returns>
|
||||
protected virtual double HealthAdjustmentFactorFor(JudgementResult result) => 1;
|
||||
/// <param name="result">The <see cref="JudgementResult"/>.</param>
|
||||
/// <returns>The health increase.</returns>
|
||||
protected virtual double GetHealthIncreaseFor(JudgementResult result) => result.Judgement.HealthIncreaseFor(result);
|
||||
|
||||
/// <summary>
|
||||
/// The default conditions for failing.
|
||||
|
@ -3,13 +3,14 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
public abstract class JudgementProcessor
|
||||
public abstract class JudgementProcessor : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when all <see cref="HitObject"/>s have been judged by this <see cref="JudgementProcessor"/>.
|
||||
@ -36,23 +37,17 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
public bool HasCompleted => JudgedHits == MaxHits;
|
||||
|
||||
protected JudgementProcessor(IBeatmap beatmap)
|
||||
/// <summary>
|
||||
/// Applies a <see cref="IBeatmap"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to read properties from.</param>
|
||||
public virtual void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
ApplyBeatmap(beatmap);
|
||||
|
||||
Reset(false);
|
||||
SimulateAutoplay(beatmap);
|
||||
Reset(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies any properties of the <see cref="IBeatmap"/> which affect scoring to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to read properties from.</param>
|
||||
protected virtual void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
@ -138,7 +133,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
throw new InvalidOperationException($"{GetType().ReadableName()} must provide a {nameof(JudgementResult)} through {nameof(CreateResult)}.");
|
||||
|
||||
result.Type = judgement.MaxResult;
|
||||
|
||||
ApplyResult(result);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
@ -64,15 +63,9 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
private double scoreMultiplier = 1;
|
||||
|
||||
public ScoreProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
public ScoreProcessor()
|
||||
{
|
||||
Debug.Assert(base_portion + combo_portion == 1.0);
|
||||
}
|
||||
|
||||
protected override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyBeatmap(beatmap);
|
||||
|
||||
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
|
||||
Accuracy.ValueChanged += accuracy =>
|
||||
@ -82,12 +75,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
Rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
|
||||
};
|
||||
|
||||
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
||||
{
|
||||
Mode.Value = ScoringMode.Classic;
|
||||
Mode.Disabled = true;
|
||||
}
|
||||
|
||||
Mode.ValueChanged += _ => updateScore();
|
||||
Mods.ValueChanged += mods =>
|
||||
{
|
||||
@ -225,6 +212,12 @@ namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
maxHighestCombo = HighestCombo.Value;
|
||||
maxBaseScore = baseScore;
|
||||
|
||||
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
||||
{
|
||||
Mode.Value = ScoringMode.Classic;
|
||||
Mode.Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
baseScore = 0;
|
||||
|
@ -72,10 +72,9 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
public override Playfield Playfield => playfield.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Place to put drawables above hit objects but below UI.
|
||||
/// </summary>
|
||||
public Container Overlays { get; private set; }
|
||||
private Container overlays;
|
||||
|
||||
public override Container Overlays => overlays;
|
||||
|
||||
public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock;
|
||||
|
||||
@ -185,12 +184,15 @@ namespace osu.Game.Rulesets.UI
|
||||
frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime)
|
||||
{
|
||||
FrameStablePlayback = FrameStablePlayback,
|
||||
Child = KeyBindingInputManager
|
||||
.WithChild(CreatePlayfieldAdjustmentContainer()
|
||||
.WithChild(Playfield)
|
||||
)
|
||||
Children = new Drawable[]
|
||||
{
|
||||
KeyBindingInputManager
|
||||
.WithChild(CreatePlayfieldAdjustmentContainer()
|
||||
.WithChild(Playfield)
|
||||
),
|
||||
overlays = new Container { RelativeSizeAxes = Axes.Both }
|
||||
}
|
||||
},
|
||||
Overlays = new Container { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
|
||||
if ((ResumeOverlay = CreateResumeOverlay()) != null)
|
||||
@ -385,6 +387,11 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
public abstract Playfield Playfield { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Place to put drawables above hit objects but below UI.
|
||||
/// </summary>
|
||||
public abstract Container Overlays { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The frame-stable clock which is being used for playfield display.
|
||||
/// </summary>
|
||||
|
@ -131,10 +131,12 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||
|
||||
ScoreProcessor = ruleset.CreateScoreProcessor(playableBeatmap);
|
||||
ScoreProcessor = ruleset.CreateScoreProcessor();
|
||||
ScoreProcessor.ApplyBeatmap(playableBeatmap);
|
||||
ScoreProcessor.Mods.BindTo(Mods);
|
||||
|
||||
HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap);
|
||||
HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
|
||||
HealthProcessor.ApplyBeatmap(playableBeatmap);
|
||||
|
||||
if (!ScoreProcessor.Mode.Disabled)
|
||||
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||
@ -206,12 +208,6 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
target.AddRange(new[]
|
||||
{
|
||||
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Breaks = working.Beatmap.Breaks
|
||||
},
|
||||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||
@ -266,6 +262,18 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
||||
});
|
||||
|
||||
DrawableRuleset.Overlays.Add(BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Breaks = working.Beatmap.Breaks
|
||||
});
|
||||
|
||||
DrawableRuleset.Overlays.Add(ScoreProcessor);
|
||||
DrawableRuleset.Overlays.Add(HealthProcessor);
|
||||
|
||||
HealthProcessor.IsBreakTime.BindTo(BreakOverlay.IsBreakTime);
|
||||
}
|
||||
|
||||
private void updatePauseOnFocusLostState() =>
|
||||
|
@ -118,8 +118,6 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
idleTracker = new IdleTracker(750)
|
||||
});
|
||||
|
||||
loadNewPlayer();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -127,6 +125,21 @@ namespace osu.Game.Screens.Play
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
}
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
loadNewPlayer();
|
||||
|
||||
content.ScaleTo(0.7f);
|
||||
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
|
||||
|
||||
contentIn();
|
||||
|
||||
info.Delay(750).FadeIn(500);
|
||||
this.Delay(1800).Schedule(pushWhenLoaded);
|
||||
|
||||
if (!muteWarningShownOnce.Value)
|
||||
{
|
||||
@ -179,19 +192,6 @@ namespace osu.Game.Screens.Play
|
||||
content.FadeOut(250);
|
||||
}
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
content.ScaleTo(0.7f);
|
||||
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
|
||||
|
||||
contentIn();
|
||||
|
||||
info.Delay(750).FadeIn(500);
|
||||
this.Delay(1800).Schedule(pushWhenLoaded);
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
{
|
||||
base.LogoArriving(logo, resuming);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -20,15 +20,13 @@ namespace osu.Game.Screens.Play
|
||||
scoreInfo = score.ScoreInfo;
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
var dependencies = base.CreateChildDependencies(parent);
|
||||
|
||||
// these will be reverted thanks to PlayerLoader's lease.
|
||||
Mods.Value = scoreInfo.Mods;
|
||||
Ruleset.Value = scoreInfo.Ruleset;
|
||||
|
||||
return dependencies;
|
||||
base.OnEntering(last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1215.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1225.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1227.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1227.1" />
|
||||
<PackageReference Include="Sentry" Version="1.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -73,8 +73,8 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1215.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1225.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1227.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1227.1" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -82,7 +82,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1225.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1227.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user