1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Introduce back the concept of Rulesets.

This commit is contained in:
Dean Herbert 2016-11-09 19:49:05 +09:00
parent 16a0be44df
commit 099b309645
7 changed files with 125 additions and 43 deletions

View File

@ -0,0 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects;
using osu.Game.GameModes.Play.Osu;
namespace osu.Game.GameModes.Play.Catch
{
class CatchRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu();
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new CatchHitRenderer { Objects = objects };
}
}

View File

@ -0,0 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects;
using osu.Game.GameModes.Play.Osu;
namespace osu.Game.GameModes.Play.Mania
{
class ManiaRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu();
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new ManiaHitRenderer { Objects = objects };
}
}

View File

@ -0,0 +1,18 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects;
namespace osu.Game.GameModes.Play.Osu
{
class OsuRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu();
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new OsuHitRenderer { Objects = objects };
}}

View File

@ -15,8 +15,6 @@ using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using OpenTK.Input;
using MouseState = osu.Framework.Input.MouseState;
@ -72,6 +70,7 @@ namespace osu.Game.GameModes.Play
private InterpolatingFramedClock playerClock;
private IAdjustableClock sourceClock;
private Ruleset Ruleset;
protected override void Load(BaseGame game)
{
@ -120,49 +119,11 @@ namespace osu.Game.GameModes.Play
PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;
switch (usablePlayMode)
{
default:
scoreOverlay = new ScoreOverlayOsu();
Ruleset = Ruleset.GetRuleset(usablePlayMode);
hitRenderer = new OsuHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
break;
case PlayMode.Taiko:
scoreOverlay = new ScoreOverlayOsu();
scoreOverlay = Ruleset.CreateScoreOverlay();
hitRenderer = new TaikoHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
break;
case PlayMode.Catch:
scoreOverlay = new ScoreOverlayOsu();
hitRenderer = new CatchHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
break;
case PlayMode.Mania:
scoreOverlay = new ScoreOverlayOsu();
hitRenderer = new ManiaHitRenderer
{
Objects = beatmap.HitObjects,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
};
break;
}
hitRenderer = Ruleset.CreateHitRendererWith(beatmap.HitObjects);
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };

View File

@ -0,0 +1,38 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects;
using osu.Game.GameModes.Play.Catch;
using osu.Game.GameModes.Play.Mania;
using osu.Game.GameModes.Play.Osu;
using osu.Game.GameModes.Play.Taiko;
namespace osu.Game.GameModes.Play
{
public abstract class Ruleset
{
public abstract ScoreOverlay CreateScoreOverlay();
public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects);
public static Ruleset GetRuleset(PlayMode mode)
{
switch (mode)
{
default:
return new OsuRuleset();
case PlayMode.Catch:
return new CatchRuleset();
case PlayMode.Mania:
return new ManiaRuleset();
case PlayMode.Taiko:
return new TaikoRuleset();
}
}
}
}

View File

@ -0,0 +1,20 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Game.Beatmaps.Objects;
using osu.Game.GameModes.Play.Osu;
namespace osu.Game.GameModes.Play.Taiko
{
class TaikoRuleset : Ruleset
{
public override ScoreOverlay CreateScoreOverlay() => new ScoreOverlayOsu();
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new TaikoHitRenderer { Objects = objects };
}
}

View File

@ -121,13 +121,18 @@
<Compile Include="GameModes\Multiplayer\MatchCreate.cs" />
<Compile Include="GameModes\Multiplayer\MatchSongSelect.cs" />
<Compile Include="GameModes\OsuGameMode.cs" />
<Compile Include="GameModes\Play\Catch\CatchRuleset.cs" />
<Compile Include="GameModes\Play\Mania\ManiaRuleset.cs" />
<Compile Include="GameModes\Play\ModSelect.cs" />
<Compile Include="GameModes\Play\Osu\OsuRuleset.cs" />
<Compile Include="GameModes\Play\Osu\ScoreOverlayOsu.cs" />
<Compile Include="Beatmaps\Drawable\BeatmapGroup.cs" />
<Compile Include="Beatmaps\Drawable\BeatmapPanel.cs" />
<Compile Include="GameModes\Play\Player.cs" />
<Compile Include="GameModes\Charts\ChartListing.cs" />
<Compile Include="GameModes\Play\PlayMode.cs" />
<Compile Include="GameModes\Play\Ruleset.cs" />
<Compile Include="GameModes\Play\Taiko\TaikoRuleset.cs" />
<Compile Include="GameModes\Ranking\Results.cs" />
<Compile Include="GameModes\Direct\OnlineListing.cs" />
<Compile Include="GameModes\Play\PlaySongSelect.cs" />