mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 18:27:26 +08:00
Add autoplay toggle (const).
This commit is contained in:
parent
f5f5aa9eac
commit
788cba6f4d
@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
@ -14,6 +15,10 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public Action<HitObject> OnHit;
|
||||
public Action<HitObject> OnMiss;
|
||||
|
||||
protected Playfield Playfield;
|
||||
|
||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.Children.Cast<DrawableHitObject>();
|
||||
}
|
||||
|
||||
public abstract class HitRenderer<T> : HitRenderer
|
||||
@ -31,8 +36,6 @@ namespace osu.Game.GameModes.Play
|
||||
}
|
||||
}
|
||||
|
||||
private Playfield playfield;
|
||||
|
||||
protected abstract Playfield CreatePlayfield();
|
||||
|
||||
protected abstract HitObjectConverter<T> Converter { get; }
|
||||
@ -47,7 +50,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
playfield = CreatePlayfield()
|
||||
Playfield = CreatePlayfield()
|
||||
};
|
||||
|
||||
loadObjects();
|
||||
@ -65,7 +68,7 @@ namespace osu.Game.GameModes.Play
|
||||
drawableObject.OnHit = onHit;
|
||||
drawableObject.OnMiss = onMiss;
|
||||
|
||||
playfield.Add(drawableObject);
|
||||
Playfield.Add(drawableObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,19 +12,17 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
{
|
||||
public class OsuPlayfield : Playfield
|
||||
{
|
||||
protected override Container Content => hitObjectContainer;
|
||||
|
||||
private Container hitObjectContainer;
|
||||
|
||||
public OsuPlayfield()
|
||||
{
|
||||
Size = new Vector2(512, 384);
|
||||
Scale = new Vector2(1.6f);
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
Size = new Vector2(512, 384);
|
||||
|
||||
protected override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
Add(new Box()
|
||||
AddInternal(new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -32,6 +30,11 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f
|
||||
});
|
||||
|
||||
AddInternal(hitObjectContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.GameModes.Backgrounds;
|
||||
using osu.Game.GameModes.Play.Catch;
|
||||
@ -12,13 +11,15 @@ using osu.Game.GameModes.Play.Taiko;
|
||||
using osu.Framework;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.GameModes;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public class Player : OsuGameMode
|
||||
{
|
||||
const bool autoplay = false;
|
||||
|
||||
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
@ -124,6 +125,9 @@ namespace osu.Game.GameModes.Play
|
||||
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
||||
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
||||
|
||||
if (autoplay)
|
||||
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Armed));
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
hitRenderer,
|
||||
|
Loading…
Reference in New Issue
Block a user