1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Move implementation of HitRender.Converter to base class using an abstract Converter property.

This commit is contained in:
Huo Yaoyuan 2016-10-13 21:14:18 +08:00
parent 80d5fa7243
commit 45a9249306
5 changed files with 19 additions and 17 deletions

View File

@ -1,7 +1,6 @@
//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.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Catch;
@ -11,9 +10,11 @@ namespace osu.Game.GameModes.Play.Catch
{
public class CatchHitRenderer : HitRenderer<CatchBaseHit>
{
protected override Playfield CreatePlayfield() => new CatchPlayfield();
private static readonly CatchConverter converter = new CatchConverter();
protected override List<CatchBaseHit> Convert(List<HitObject> objects) => new CatchConverter().Convert(objects);
protected override HitObjectConverter<CatchBaseHit> Converter => converter;
protected override Playfield CreatePlayfield() => new CatchPlayfield();
protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
}

View File

@ -10,6 +10,7 @@ using osu.Framework;
namespace osu.Game.GameModes.Play
{
public abstract class HitRenderer<T> : Container
where T : HitObject
{
private List<T> objects;
@ -27,7 +28,9 @@ namespace osu.Game.GameModes.Play
protected abstract Playfield CreatePlayfield();
protected abstract List<T> Convert(List<HitObject> objects);
protected abstract HitObjectConverter<T> Converter { get; }
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
public override void Load(BaseGame game)
{

View File

@ -1,12 +1,11 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Mania;
using OpenTK;
using osu.Game.Beatmaps.Objects.Mania.Drawable;
using System.Collections.Generic;
namespace osu.Game.GameModes.Play.Mania
{
@ -17,13 +16,10 @@ namespace osu.Game.GameModes.Play.Mania
public ManiaHitRenderer(int columns = 5)
{
this.columns = columns;
Converter = new ManiaConverter(columns);
}
protected override List<ManiaBaseHit> Convert(List<HitObject> objects)
{
ManiaConverter converter = new ManiaConverter(columns);
return converter.Convert(objects);
}
protected override HitObjectConverter<ManiaBaseHit> Converter { get; }
protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);

View File

@ -1,7 +1,6 @@
//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.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
@ -11,9 +10,11 @@ namespace osu.Game.GameModes.Play.Osu
{
public class OsuHitRenderer : HitRenderer<OsuBaseHit>
{
protected override Playfield CreatePlayfield() => new OsuPlayfield();
private static readonly OsuConverter converter = new OsuConverter();
protected override List<OsuBaseHit> Convert(List<HitObject> objects) => new OsuConverter().Convert(objects);
protected override HitObjectConverter<OsuBaseHit> Converter => converter;
protected override Playfield CreatePlayfield() => new OsuPlayfield();
protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
}

View File

@ -1,7 +1,6 @@
//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.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Taiko;
@ -11,10 +10,12 @@ namespace osu.Game.GameModes.Play.Taiko
{
public class TaikoHitRenderer : HitRenderer<TaikoBaseHit>
{
protected override List<TaikoBaseHit> Convert(List<HitObject> objects) => new TaikoConverter().Convert(objects);
private static readonly TaikoConverter converter = new TaikoConverter();
protected override HitObjectConverter<TaikoBaseHit> Converter => converter;
protected override Playfield CreatePlayfield() => new TaikoPlayfield();
protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
}
}
}