mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 13:22:57 +08:00
Merge pull request #177 from peppy/play-mode-improvements
Add simple implementation of HitExplosions.
This commit is contained in:
commit
9d88bb4736
@ -1 +1 @@
|
||||
Subproject commit f57175bf2035602b9451562167ddcee978c60620
|
||||
Subproject commit 3163342d5b00f7cd125fdca71f8cc1590a6237cf
|
@ -1 +1 @@
|
||||
Subproject commit 10dd6161a65972c53e310e26a09c92cffca33a08
|
||||
Subproject commit 911564f95a1b7820671cb17fadcd11bab8ba144e
|
@ -5,6 +5,11 @@ using System;
|
||||
using osu.Framework.Desktop;
|
||||
using osu.Framework.Desktop.Platform;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Catch;
|
||||
using osu.Game.Modes.Mania;
|
||||
using osu.Game.Modes.Osu;
|
||||
using osu.Game.Modes.Taiko;
|
||||
|
||||
namespace osu.Desktop.VisualTests
|
||||
{
|
||||
@ -15,6 +20,11 @@ namespace osu.Desktop.VisualTests
|
||||
{
|
||||
using (BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests"))
|
||||
{
|
||||
Ruleset.Register(new OsuRuleset());
|
||||
Ruleset.Register(new TaikoRuleset());
|
||||
Ruleset.Register(new ManiaRuleset());
|
||||
Ruleset.Register(new CatchRuleset());
|
||||
|
||||
host.Add(new VisualTestGame());
|
||||
host.Run();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
int time = 500;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
objects.Add(new Circle()
|
||||
objects.Add(new HitCircle()
|
||||
{
|
||||
StartTime = time,
|
||||
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384))
|
||||
|
@ -11,6 +11,7 @@ using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
@ -34,23 +35,30 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
ourClock.ProcessFrame();
|
||||
|
||||
Container approachContainer = new Container { Depth = float.MaxValue, };
|
||||
|
||||
Add(approachContainer);
|
||||
|
||||
const int count = 10;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var h = new Circle
|
||||
var h = new HitCircle
|
||||
{
|
||||
StartTime = ourClock.CurrentTime + 1000 + i * 80,
|
||||
Position = new Vector2((i - count / 2) * 14),
|
||||
};
|
||||
|
||||
Add(new DrawableCircle(h)
|
||||
DrawableHitCircle d = new DrawableHitCircle(h)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Depth = -i,
|
||||
State = ArmedState.Armed,
|
||||
});
|
||||
};
|
||||
|
||||
approachContainer.Add(d.ApproachCircle.CreateProxy());
|
||||
Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,11 @@ using osu.Game.Beatmaps.Formats;
|
||||
using OpenTK;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Screens.Play;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
@ -38,10 +40,11 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
int time = 1500;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
objects.Add(new Circle()
|
||||
objects.Add(new HitCircle()
|
||||
{
|
||||
StartTime = time,
|
||||
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)),
|
||||
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
|
||||
i % 4 < 2 ? 0 : 384),
|
||||
NewCombo = i % 4 == 0
|
||||
});
|
||||
|
||||
@ -57,6 +60,12 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
decoder.Process(b);
|
||||
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Framework.Graphics.Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
});
|
||||
|
||||
Add(new Player
|
||||
{
|
||||
Beatmap = new WorkingBeatmap(b)
|
||||
|
@ -53,7 +53,6 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding(10),
|
||||
InnerCountMargin = new MarginPadding(10),
|
||||
Count = 0,
|
||||
TextSize = 40,
|
||||
};
|
||||
|
@ -2,80 +2,66 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
public class DrawableCircle : DrawableHitObject
|
||||
public class DrawableHitCircle : DrawableHitObject
|
||||
{
|
||||
private Sprite approachCircle;
|
||||
private CircleLayer circle;
|
||||
private RingLayer ring;
|
||||
private FlashLayer flash;
|
||||
private ExplodeLayer explode;
|
||||
private NumberLayer number;
|
||||
private GlowLayer glow;
|
||||
private OsuBaseHit h;
|
||||
private OsuHitObject osuObject;
|
||||
|
||||
public DrawableCircle(Circle h) : base(h)
|
||||
public ApproachCircle ApproachCircle;
|
||||
private CirclePiece circle;
|
||||
private RingPiece ring;
|
||||
private FlashPiece flash;
|
||||
private ExplodePiece explode;
|
||||
private NumberPiece number;
|
||||
private GlowPiece glow;
|
||||
private HitExplosion explosion;
|
||||
|
||||
public DrawableHitCircle(HitCircle h) : base(h)
|
||||
{
|
||||
this.h = h;
|
||||
osuObject = h;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
RelativePositionAxes = Axes.Both;
|
||||
Position = new Vector2(h.Position.X / 512, h.Position.Y / 384);
|
||||
Position = osuObject.Position;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
glow = new GlowLayer
|
||||
glow = new GlowPiece
|
||||
{
|
||||
Colour = h.Colour
|
||||
Colour = osuObject.Colour
|
||||
},
|
||||
circle = new CircleLayer
|
||||
circle = new CirclePiece
|
||||
{
|
||||
Colour = h.Colour,
|
||||
Colour = osuObject.Colour,
|
||||
Hit = Hit,
|
||||
},
|
||||
number = new NumberLayer(),
|
||||
ring = new RingLayer(),
|
||||
flash = new FlashLayer(),
|
||||
explode = new ExplodeLayer
|
||||
number = new NumberPiece(),
|
||||
ring = new RingPiece(),
|
||||
flash = new FlashPiece(),
|
||||
explode = new ExplodePiece
|
||||
{
|
||||
Colour = h.Colour,
|
||||
Colour = osuObject.Colour,
|
||||
},
|
||||
approachCircle = new Sprite
|
||||
ApproachCircle = new ApproachCircle()
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = h.Colour
|
||||
Colour = osuObject.Colour,
|
||||
}
|
||||
};
|
||||
|
||||
//may not be so correct
|
||||
Size = circle.DrawSize;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BaseGame game)
|
||||
{
|
||||
approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
//may not be so correct
|
||||
Size = circle.DrawSize;
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
UpdateState(State);
|
||||
}
|
||||
@ -85,29 +71,44 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
if (!IsLoaded) return;
|
||||
|
||||
Flush(true); //move to DrawableHitObject
|
||||
ApproachCircle.Flush(true);
|
||||
|
||||
double t = HitTime ?? h.StartTime;
|
||||
double t = HitTime ?? osuObject.StartTime;
|
||||
|
||||
Alpha = 0;
|
||||
|
||||
//sane defaults
|
||||
ring.Alpha = circle.Alpha = number.Alpha = approachCircle.Alpha = glow.Alpha = 1;
|
||||
ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1;
|
||||
ApproachCircle.Alpha = 0;
|
||||
ApproachCircle.Scale = new Vector2(2);
|
||||
explode.Alpha = 0;
|
||||
Scale = Vector2.One;
|
||||
Scale = new Vector2(0.5f); //this will probably need to be moved to DrawableHitObject at some point.
|
||||
|
||||
//always-present transforms
|
||||
Transforms.Add(new TransformAlpha { StartTime = t - 1000, EndTime = t - 800, StartValue = 0, EndValue = 1 });
|
||||
approachCircle.Transforms.Add(new TransformScale { StartTime = t - 1000, EndTime = t, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) });
|
||||
const float preempt = 600;
|
||||
|
||||
//set transform delay to t==hitTime
|
||||
Delay(t - Time.Current, true);
|
||||
const float fadein = 400;
|
||||
|
||||
Delay(t - Time.Current - preempt, true);
|
||||
|
||||
FadeIn(fadein);
|
||||
|
||||
ApproachCircle.FadeIn(Math.Min(fadein * 2, preempt));
|
||||
ApproachCircle.ScaleTo(0.6f, preempt);
|
||||
|
||||
Delay(preempt, true);
|
||||
|
||||
ApproachCircle.FadeOut();
|
||||
|
||||
approachCircle.FadeOut();
|
||||
glow.FadeOut(400);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Disarmed:
|
||||
Delay(h.Duration + 200);
|
||||
Delay(osuObject.Duration + 200);
|
||||
FadeOut(200);
|
||||
|
||||
explosion?.Expire();
|
||||
explosion = null;
|
||||
break;
|
||||
case ArmedState.Armed:
|
||||
const double flash_in = 30;
|
||||
@ -118,6 +119,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
explode.FadeIn(flash_in);
|
||||
|
||||
Schedule(() => Add(explosion = new HitExplosion(Judgement.Hit300)));
|
||||
|
||||
Delay(flash_in, true);
|
||||
|
||||
//after the flash, we can hide some elements that were behind it
|
||||
@ -130,210 +133,5 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class NumberLayer : Container
|
||||
{
|
||||
private Sprite number;
|
||||
|
||||
public NumberLayer()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
number = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
number.Texture = textures.Get(@"Play/osu/number@2x");
|
||||
}
|
||||
}
|
||||
|
||||
private class GlowLayer : Container
|
||||
{
|
||||
private Sprite layer;
|
||||
|
||||
public GlowLayer()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
layer = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Alpha = 0.5f
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
layer.Texture = textures.Get(@"Play/osu/ring-glow@2x");
|
||||
}
|
||||
}
|
||||
|
||||
private class RingLayer : Container
|
||||
{
|
||||
private Sprite ring;
|
||||
|
||||
public RingLayer()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ring = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
ring.Texture = textures.Get(@"Play/osu/ring@2x");
|
||||
}
|
||||
}
|
||||
|
||||
private class FlashLayer : Container
|
||||
{
|
||||
public FlashLayer()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = Size.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class ExplodeLayer : Container
|
||||
{
|
||||
public ExplodeLayer()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Triangles
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class CircleLayer : Container
|
||||
{
|
||||
|
||||
private Sprite disc;
|
||||
private Triangles triangles;
|
||||
|
||||
public Func<bool> Hit;
|
||||
|
||||
public CircleLayer()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
Masking = true;
|
||||
CornerRadius = DrawSize.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
disc = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
triangles = new Triangles
|
||||
{
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
disc.Texture = textures.Get(@"Play/osu/disc@2x");
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
Hit?.Invoke();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class Triangles : Container
|
||||
{
|
||||
private Texture tex;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
tex = textures.Get(@"Play/osu/triangle@2x");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Add(new Sprite
|
||||
{
|
||||
Texture = tex,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||
Alpha = RNG.NextSingle() * 0.3f
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (Drawable d in Children)
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs
Normal file
50
osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
class DrawableSlider : DrawableHitObject
|
||||
{
|
||||
public DrawableSlider(Slider h) : base(h)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
RelativePositionAxes = Axes.Both;
|
||||
Position = new Vector2(h.Position.X / 512, h.Position.Y / 384);
|
||||
|
||||
for (float i = 0; i <= 1; i += 0.1f)
|
||||
{
|
||||
Add(new CirclePiece
|
||||
{
|
||||
Colour = h.Colour,
|
||||
Hit = Hit,
|
||||
Position = h.Curve.PositionAt(i) - h.Position //non-relative?
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
UpdateState(State);
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
Flush(true); //move to DrawableHitObject
|
||||
|
||||
Alpha = 0;
|
||||
|
||||
Delay(HitObject.StartTime - 200 - Time.Current, true);
|
||||
|
||||
FadeIn(200);
|
||||
Delay(200 + HitObject.Duration);
|
||||
FadeOut(200);
|
||||
}
|
||||
}
|
||||
}
|
50
osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs
Normal file
50
osu.Game.Mode.Osu/Objects/Drawables/HitExplosion.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
public class HitExplosion : FlowContainer
|
||||
{
|
||||
private SpriteText line1;
|
||||
private SpriteText line2;
|
||||
|
||||
public HitExplosion(Judgement judgement, ComboJudgement comboJudgement = ComboJudgement.None)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Direction = FlowDirection.VerticalOnly;
|
||||
Spacing = new Vector2(0, 2);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
line1 = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = judgement.GetDescription(),
|
||||
Font = @"Venera",
|
||||
TextSize = 20,
|
||||
},
|
||||
line2 = new SpriteText
|
||||
{
|
||||
Text = comboJudgement.GetDescription(),
|
||||
Font = @"Venera",
|
||||
TextSize = 14,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
line1.TransformSpacingTo(14, 1800, EasingTypes.OutQuint);
|
||||
line2.TransformSpacingTo(14, 1800, EasingTypes.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
35
osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs
Normal file
35
osu.Game.Mode.Osu/Objects/Drawables/Pieces/ApproachCircle.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class ApproachCircle : Container
|
||||
{
|
||||
private Sprite approachCircle;
|
||||
|
||||
public ApproachCircle()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
approachCircle = new Sprite()
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
approachCircle.Texture = textures.Get(@"Play/osu/approachcircle@2x");
|
||||
}
|
||||
}
|
||||
}
|
56
osu.Game.Mode.Osu/Objects/Drawables/Pieces/CirclePiece.cs
Normal file
56
osu.Game.Mode.Osu/Objects/Drawables/Pieces/CirclePiece.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class CirclePiece : Container
|
||||
{
|
||||
|
||||
private Sprite disc;
|
||||
private Triangles triangles;
|
||||
|
||||
public Func<bool> Hit;
|
||||
|
||||
public CirclePiece()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
Masking = true;
|
||||
CornerRadius = DrawSize.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
disc = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
triangles = new Triangles
|
||||
{
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
disc.Texture = textures.Get(@"Play/osu/disc@2x");
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
Hit?.Invoke();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
29
osu.Game.Mode.Osu/Objects/Drawables/Pieces/ExplodePiece.cs
Normal file
29
osu.Game.Mode.Osu/Objects/Drawables/Pieces/ExplodePiece.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class ExplodePiece : Container
|
||||
{
|
||||
public ExplodePiece()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Triangles
|
||||
{
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
32
osu.Game.Mode.Osu/Objects/Drawables/Pieces/FlashPiece.cs
Normal file
32
osu.Game.Mode.Osu/Objects/Drawables/Pieces/FlashPiece.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class FlashPiece : Container
|
||||
{
|
||||
public FlashPiece()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = Size.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
36
osu.Game.Mode.Osu/Objects/Drawables/Pieces/GlowPiece.cs
Normal file
36
osu.Game.Mode.Osu/Objects/Drawables/Pieces/GlowPiece.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class GlowPiece : Container
|
||||
{
|
||||
private Sprite layer;
|
||||
|
||||
public GlowPiece()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
layer = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Alpha = 0.5f
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
layer.Texture = textures.Get(@"Play/osu/ring-glow@2x");
|
||||
}
|
||||
}
|
||||
}
|
35
osu.Game.Mode.Osu/Objects/Drawables/Pieces/NumberPiece.cs
Normal file
35
osu.Game.Mode.Osu/Objects/Drawables/Pieces/NumberPiece.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class NumberPiece : Container
|
||||
{
|
||||
private Sprite number;
|
||||
|
||||
public NumberPiece()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
number = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
number.Texture = textures.Get(@"Play/osu/number@2x");
|
||||
}
|
||||
}
|
||||
}
|
34
osu.Game.Mode.Osu/Objects/Drawables/Pieces/RingPiece.cs
Normal file
34
osu.Game.Mode.Osu/Objects/Drawables/Pieces/RingPiece.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class RingPiece : Container
|
||||
{
|
||||
private Sprite ring;
|
||||
|
||||
public RingPiece()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ring = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
ring.Texture = textures.Get(@"Play/osu/ring@2x");
|
||||
}
|
||||
}
|
||||
}
|
46
osu.Game.Mode.Osu/Objects/Drawables/Pieces/Triangles.cs
Normal file
46
osu.Game.Mode.Osu/Objects/Drawables/Pieces/Triangles.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.MathUtils;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class Triangles : Container
|
||||
{
|
||||
private Texture triangle;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
triangle = textures.Get(@"Play/osu/triangle@2x");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Add(new Sprite
|
||||
{
|
||||
Texture = triangle,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||
Alpha = RNG.NextSingle() * 0.3f
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (Drawable d in Children)
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class Circle : OsuBaseHit
|
||||
public class HitCircle : OsuHitObject
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public abstract class OsuBaseHit : HitObject
|
||||
public abstract class OsuHitObject : HitObject
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
|
@ -6,14 +6,14 @@ using osu.Game.Modes.Objects;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class OsuConverter : HitObjectConverter<OsuBaseHit>
|
||||
public class OsuHitObjectConverter : HitObjectConverter<OsuHitObject>
|
||||
{
|
||||
public override List<OsuBaseHit> Convert(List<HitObject> input)
|
||||
public override List<OsuHitObject> Convert(List<HitObject> input)
|
||||
{
|
||||
List<OsuBaseHit> output = new List<OsuBaseHit>();
|
||||
List<OsuHitObject> output = new List<OsuHitObject>();
|
||||
|
||||
foreach (HitObject h in input)
|
||||
output.Add(h as OsuBaseHit);
|
||||
output.Add(h as OsuHitObject);
|
||||
|
||||
return output;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -14,20 +15,81 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
public override HitObject Parse(string text)
|
||||
{
|
||||
string[] split = text.Split(',');
|
||||
var type = (OsuBaseHit.HitObjectType)int.Parse(split[3]);
|
||||
bool combo = type.HasFlag(OsuBaseHit.HitObjectType.NewCombo);
|
||||
type &= (OsuBaseHit.HitObjectType)0xF;
|
||||
type &= ~OsuBaseHit.HitObjectType.NewCombo;
|
||||
OsuBaseHit result;
|
||||
var type = (OsuHitObject.HitObjectType)int.Parse(split[3]);
|
||||
bool combo = type.HasFlag(OsuHitObject.HitObjectType.NewCombo);
|
||||
type &= (OsuHitObject.HitObjectType)0xF;
|
||||
type &= ~OsuHitObject.HitObjectType.NewCombo;
|
||||
OsuHitObject result;
|
||||
switch (type)
|
||||
{
|
||||
case OsuBaseHit.HitObjectType.Circle:
|
||||
result = new Circle();
|
||||
case OsuHitObject.HitObjectType.Circle:
|
||||
result = new HitCircle();
|
||||
break;
|
||||
case OsuBaseHit.HitObjectType.Slider:
|
||||
result = new Slider();
|
||||
case OsuHitObject.HitObjectType.Slider:
|
||||
Slider s = new Slider();
|
||||
|
||||
CurveTypes curveType = CurveTypes.Catmull;
|
||||
int repeatCount = 0;
|
||||
double length = 0;
|
||||
List<Vector2> points = new List<Vector2>();
|
||||
|
||||
points.Add(new Vector2(int.Parse(split[0]), int.Parse(split[1])));
|
||||
|
||||
string[] pointsplit = split[5].Split('|');
|
||||
for (int i = 0; i < pointsplit.Length; i++)
|
||||
{
|
||||
if (pointsplit[i].Length == 1)
|
||||
{
|
||||
switch (pointsplit[i])
|
||||
{
|
||||
case @"C":
|
||||
curveType = CurveTypes.Catmull;
|
||||
break;
|
||||
case @"B":
|
||||
curveType = CurveTypes.Bezier;
|
||||
break;
|
||||
case @"L":
|
||||
curveType = CurveTypes.Linear;
|
||||
break;
|
||||
case @"P":
|
||||
curveType = CurveTypes.PerfectCurve;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] temp = pointsplit[i].Split(':');
|
||||
Vector2 v = new Vector2(
|
||||
(int)Convert.ToDouble(temp[0], CultureInfo.InvariantCulture),
|
||||
(int)Convert.ToDouble(temp[1], CultureInfo.InvariantCulture)
|
||||
);
|
||||
points.Add(v);
|
||||
}
|
||||
|
||||
repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture);
|
||||
|
||||
if (repeatCount > 9000)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("wacky man");
|
||||
}
|
||||
|
||||
if (split.Length > 7)
|
||||
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
|
||||
|
||||
s.RepeatCount = repeatCount;
|
||||
|
||||
s.Curve = new SliderCurve
|
||||
{
|
||||
Path = points,
|
||||
Length = length,
|
||||
CurveType = curveType
|
||||
};
|
||||
|
||||
s.Curve.Calculate();
|
||||
|
||||
result = s;
|
||||
break;
|
||||
case OsuBaseHit.HitObjectType.Spinner:
|
||||
case OsuHitObject.HitObjectType.Spinner:
|
||||
result = new Spinner();
|
||||
break;
|
||||
default:
|
||||
|
@ -6,10 +6,200 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class Slider : OsuBaseHit
|
||||
public class Slider : OsuHitObject
|
||||
{
|
||||
public List<Vector2> Path;
|
||||
public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length;
|
||||
|
||||
public int RepeatCount;
|
||||
|
||||
public SliderCurve Curve;
|
||||
|
||||
}
|
||||
|
||||
public class SliderCurve
|
||||
{
|
||||
public double Length;
|
||||
|
||||
public List<Vector2> Path;
|
||||
|
||||
public CurveTypes CurveType;
|
||||
|
||||
private List<Vector2> calculatedPath;
|
||||
|
||||
public void Calculate()
|
||||
{
|
||||
switch (CurveType)
|
||||
{
|
||||
case CurveTypes.Linear:
|
||||
calculatedPath = Path;
|
||||
break;
|
||||
default:
|
||||
var bezier = new BezierApproximator(Path);
|
||||
calculatedPath = bezier.CreateBezier();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 PositionAt(double progress)
|
||||
{
|
||||
int index = (int)(progress * (calculatedPath.Count - 1));
|
||||
|
||||
Vector2 pos = calculatedPath[index];
|
||||
if (index != progress)
|
||||
pos += (calculatedPath[index + 1] - pos) * (float)(progress - index);
|
||||
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
public class BezierApproximator
|
||||
{
|
||||
private int count;
|
||||
private List<Vector2> controlPoints;
|
||||
private Vector2[] subdivisionBuffer1;
|
||||
private Vector2[] subdivisionBuffer2;
|
||||
|
||||
private const float TOLERANCE = 0.5f;
|
||||
private const float TOLERANCE_SQ = TOLERANCE * TOLERANCE;
|
||||
|
||||
public BezierApproximator(List<Vector2> controlPoints)
|
||||
{
|
||||
this.controlPoints = controlPoints;
|
||||
count = controlPoints.Count;
|
||||
|
||||
subdivisionBuffer1 = new Vector2[count];
|
||||
subdivisionBuffer2 = new Vector2[count * 2 - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the 2nd order derivative (approximated using finite elements) is within tolerable bounds.
|
||||
/// NOTE: The 2nd order derivative of a 2d curve represents its curvature, so intuitively this function
|
||||
/// checks (as the name suggests) whether our approximation is _locally_ "flat". More curvy parts
|
||||
/// need to have a denser approximation to be more "flat".
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points to check for flatness.</param>
|
||||
/// <returns>Whether the control points are flat enough.</returns>
|
||||
private static bool IsFlatEnough(Vector2[] controlPoints)
|
||||
{
|
||||
for (int i = 1; i < controlPoints.Length - 1; i++)
|
||||
if ((controlPoints[i - 1] - 2 * controlPoints[i] + controlPoints[i + 1]).LengthSquared > TOLERANCE_SQ)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subdivides n control points representing a bezier curve into 2 sets of n control points, each
|
||||
/// describing a bezier curve equivalent to a half of the original curve. Effectively this splits
|
||||
/// the original curve into 2 curves which result in the original curve when pieced back together.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points to split.</param>
|
||||
/// <param name="l">Output: The control points corresponding to the left half of the curve.</param>
|
||||
/// <param name="r">Output: The control points corresponding to the right half of the curve.</param>
|
||||
private void Subdivide(Vector2[] controlPoints, Vector2[] l, Vector2[] r)
|
||||
{
|
||||
Vector2[] midpoints = subdivisionBuffer1;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
midpoints[i] = controlPoints[i];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
l[i] = midpoints[0];
|
||||
r[count - i - 1] = midpoints[count - i - 1];
|
||||
|
||||
for (int j = 0; j < count - i - 1; j++)
|
||||
midpoints[j] = (midpoints[j] + midpoints[j + 1]) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This uses <a href="https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm">De Casteljau's algorithm</a> to obtain an optimal
|
||||
/// piecewise-linear approximation of the bezier curve with the same amount of points as there are control points.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points describing the bezier curve to be approximated.</param>
|
||||
/// <param name="output">The points representing the resulting piecewise-linear approximation.</param>
|
||||
private void Approximate(Vector2[] controlPoints, List<Vector2> output)
|
||||
{
|
||||
Vector2[] l = subdivisionBuffer2;
|
||||
Vector2[] r = subdivisionBuffer1;
|
||||
|
||||
Subdivide(controlPoints, l, r);
|
||||
|
||||
for (int i = 0; i < count - 1; ++i)
|
||||
l[count + i] = r[i + 1];
|
||||
|
||||
output.Add(controlPoints[0]);
|
||||
for (int i = 1; i < count - 1; ++i)
|
||||
{
|
||||
int index = 2 * i;
|
||||
Vector2 p = 0.25f * (l[index - 1] + 2 * l[index] + l[index + 1]);
|
||||
output.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a piecewise-linear approximation of a bezier curve, by adaptively repeatedly subdividing
|
||||
/// the control points until their approximation error vanishes below a given threshold.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points describing the curve.</param>
|
||||
/// <returns>A list of vectors representing the piecewise-linear approximation.</returns>
|
||||
public List<Vector2> CreateBezier()
|
||||
{
|
||||
List<Vector2> output = new List<Vector2>();
|
||||
|
||||
if (count == 0)
|
||||
return output;
|
||||
|
||||
Stack<Vector2[]> toFlatten = new Stack<Vector2[]>();
|
||||
Stack<Vector2[]> freeBuffers = new Stack<Vector2[]>();
|
||||
|
||||
// "toFlatten" contains all the curves which are not yet approximated well enough.
|
||||
// We use a stack to emulate recursion without the risk of running into a stack overflow.
|
||||
// (More specifically, we iteratively and adaptively refine our curve with a
|
||||
// <a href="https://en.wikipedia.org/wiki/Depth-first_search">Depth-first search</a>
|
||||
// over the tree resulting from the subdivisions we make.)
|
||||
toFlatten.Push(controlPoints.ToArray());
|
||||
|
||||
Vector2[] leftChild = subdivisionBuffer2;
|
||||
|
||||
while (toFlatten.Count > 0)
|
||||
{
|
||||
Vector2[] parent = toFlatten.Pop();
|
||||
if (IsFlatEnough(parent))
|
||||
{
|
||||
// If the control points we currently operate on are sufficiently "flat", we use
|
||||
// an extension to De Casteljau's algorithm to obtain a piecewise-linear approximation
|
||||
// of the bezier curve represented by our control points, consisting of the same amount
|
||||
// of points as there are control points.
|
||||
Approximate(parent, output);
|
||||
freeBuffers.Push(parent);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we do not yet have a sufficiently "flat" (in other words, detailed) approximation we keep
|
||||
// subdividing the curve we are currently operating on.
|
||||
Vector2[] rightChild = freeBuffers.Count > 0 ? freeBuffers.Pop() : new Vector2[count];
|
||||
Subdivide(parent, leftChild, rightChild);
|
||||
|
||||
// We re-use the buffer of the parent for one of the children, so that we save one allocation per iteration.
|
||||
for (int i = 0; i < count; ++i)
|
||||
parent[i] = leftChild[i];
|
||||
|
||||
toFlatten.Push(rightChild);
|
||||
toFlatten.Push(parent);
|
||||
}
|
||||
|
||||
output.Add(controlPoints[count - 1]);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CurveTypes
|
||||
{
|
||||
Catmull,
|
||||
Bezier,
|
||||
Linear,
|
||||
PerfectCurve
|
||||
};
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class Spinner : OsuBaseHit
|
||||
public class Spinner : OsuHitObject
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -16,25 +16,15 @@ namespace osu.Game.Modes.Osu.UI
|
||||
|
||||
protected virtual float PopOutSmallScale => 1.1f;
|
||||
protected virtual bool CanPopOutWhileRolling => false;
|
||||
|
||||
public MarginPadding InnerCountMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayedCountSpriteText.Margin;
|
||||
}
|
||||
set
|
||||
{
|
||||
DisplayedCountSpriteText.Margin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OsuComboCounter()
|
||||
{
|
||||
PopOutSpriteText.Origin = Origin;
|
||||
PopOutSpriteText.Anchor = Anchor;
|
||||
|
||||
Add(PopOutSpriteText);
|
||||
public Vector2 PopOutScale = new Vector2(2.5f);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
PopOutCount.Origin = Origin;
|
||||
PopOutCount.Anchor = Anchor;
|
||||
}
|
||||
|
||||
protected override string FormatCount(ulong count)
|
||||
@ -44,15 +34,15 @@ namespace osu.Game.Modes.Osu.UI
|
||||
|
||||
protected virtual void TransformPopOut(ulong newValue)
|
||||
{
|
||||
PopOutSpriteText.Text = FormatCount(newValue);
|
||||
PopOutCount.Text = FormatCount(newValue);
|
||||
|
||||
PopOutSpriteText.ScaleTo(PopOutScale);
|
||||
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
|
||||
PopOutSpriteText.MoveTo(Vector2.Zero);
|
||||
PopOutCount.ScaleTo(PopOutScale);
|
||||
PopOutCount.FadeTo(PopOutInitialAlpha);
|
||||
PopOutCount.MoveTo(Vector2.Zero);
|
||||
|
||||
PopOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||
PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
||||
PopOutSpriteText.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||
PopOutCount.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||
PopOutCount.FadeOut(PopOutDuration, PopOutEasing);
|
||||
PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||
}
|
||||
|
||||
protected virtual void TransformPopOutRolling(ulong newValue)
|
||||
|
@ -3,21 +3,27 @@
|
||||
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Game.Modes.UI;
|
||||
using Circle = osu.Game.Modes.Osu.Objects.Circle;
|
||||
using DrawableCircle = osu.Game.Modes.Osu.Objects.Drawables.DrawableCircle;
|
||||
using OsuBaseHit = osu.Game.Modes.Osu.Objects.OsuBaseHit;
|
||||
using OsuConverter = osu.Game.Modes.Osu.Objects.OsuConverter;
|
||||
using OsuConverter = osu.Game.Modes.Osu.Objects.OsuHitObjectConverter;
|
||||
|
||||
namespace osu.Game.Modes.Osu.UI
|
||||
{
|
||||
public class OsuHitRenderer : HitRenderer<OsuBaseHit>
|
||||
public class OsuHitRenderer : HitRenderer<OsuHitObject>
|
||||
{
|
||||
protected override HitObjectConverter<OsuBaseHit> Converter => new OsuConverter();
|
||||
protected override HitObjectConverter<OsuHitObject> Converter => new OsuHitObjectConverter();
|
||||
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
protected override DrawableHitObject GetVisualRepresentation(OsuBaseHit h)
|
||||
=> h is Circle ? new DrawableCircle(h as Circle) : null;
|
||||
protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h)
|
||||
{
|
||||
if (h is HitCircle)
|
||||
return new DrawableHitCircle(h as HitCircle);
|
||||
if (h is Slider)
|
||||
return new DrawableSlider(h as Slider);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Game.Modes.UI;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
@ -12,9 +15,7 @@ namespace osu.Game.Modes.Osu.UI
|
||||
{
|
||||
public class OsuPlayfield : Playfield
|
||||
{
|
||||
protected override Container<Drawable> Content => hitObjectContainer;
|
||||
|
||||
private Container hitObjectContainer;
|
||||
private Container approachCircles;
|
||||
|
||||
public override Vector2 Size
|
||||
{
|
||||
@ -34,26 +35,33 @@ namespace osu.Game.Modes.Osu.UI
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Size = new Vector2(0.75f);
|
||||
|
||||
AddInternal(new Box
|
||||
AddInternal(new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
});
|
||||
|
||||
AddInternal(hitObjectContainer = new HitObjectContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = Color4.Black,
|
||||
Depth = float.MinValue,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
approachCircles = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class HitObjectContainer : Container
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
public override Vector2 ChildScale => new Vector2(0.625f);
|
||||
DrawableHitCircle c = h as DrawableHitCircle;
|
||||
if (c != null)
|
||||
{
|
||||
approachCircles.Add(c.ApproachCircle.CreateProxy());
|
||||
}
|
||||
|
||||
base.Add(h);
|
||||
}
|
||||
}
|
||||
}
|
@ -41,6 +41,16 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Objects\Drawables\Pieces\ApproachCircle.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
|
||||
<Compile Include="Objects\Drawables\DrawableSlider.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\ExplodePiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\FlashPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\GlowPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\HitExplosion.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\NumberPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
||||
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
|
||||
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
||||
<Compile Include="UI\OsuComboCounter.cs" />
|
||||
<Compile Include="UI\OsuHitRenderer.cs" />
|
||||
@ -48,8 +58,8 @@
|
||||
<Compile Include="OsuRuleset.cs" />
|
||||
<Compile Include="Objects\HitCircle.cs" />
|
||||
<Compile Include="Objects\Drawables\DrawableHitCircle.cs" />
|
||||
<Compile Include="Objects\OsuBaseHit.cs" />
|
||||
<Compile Include="Objects\OsuConverter.cs" />
|
||||
<Compile Include="Objects\OsuHitObject.cs" />
|
||||
<Compile Include="Objects\OsuHitObjectConverter.cs" />
|
||||
<Compile Include="Objects\Slider.cs" />
|
||||
<Compile Include="Objects\Spinner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@ -70,6 +80,7 @@
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch.Objects
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = i as OsuBaseHit;
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Catch", i);
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Modes.Catch.UI
|
||||
{
|
||||
if (!IsRolling)
|
||||
{
|
||||
PopOutSpriteText.Colour = DisplayedCountSpriteText.Colour;
|
||||
PopOutCount.Colour = DisplayedCountSpriteText.Colour;
|
||||
FadeOut(FadeOutDuration);
|
||||
}
|
||||
base.OnCountRolling(currentValue, newValue);
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Modes.Catch.UI
|
||||
/// <param name="colour">Last grabbed fruit colour.</param>
|
||||
public void CatchFruit(Color4 colour)
|
||||
{
|
||||
PopOutSpriteText.Colour = colour;
|
||||
PopOutCount.Colour = colour;
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Modes.Mania.Objects
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = i as OsuBaseHit;
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Mania", i);
|
||||
|
||||
|
@ -29,9 +29,9 @@ namespace osu.Game.Modes.Mania.UI
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
PopOutSpriteText.Anchor = Anchor.BottomCentre;
|
||||
PopOutSpriteText.Origin = Anchor.Centre;
|
||||
PopOutSpriteText.FadeColour(PopOutColor, 0);
|
||||
PopOutCount.Anchor = Anchor.BottomCentre;
|
||||
PopOutCount.Origin = Anchor.Centre;
|
||||
PopOutCount.FadeColour(PopOutColor, 0);
|
||||
OriginalColour = DisplayedCountSpriteText.Colour;
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@ namespace osu.Game.Modes.Mania.UI
|
||||
{
|
||||
if (!IsRolling && newValue < currentValue)
|
||||
{
|
||||
PopOutSpriteText.Text = FormatCount(currentValue);
|
||||
PopOutCount.Text = FormatCount(currentValue);
|
||||
|
||||
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
|
||||
PopOutSpriteText.ScaleTo(1.0f);
|
||||
PopOutCount.FadeTo(PopOutInitialAlpha);
|
||||
PopOutCount.ScaleTo(1.0f);
|
||||
|
||||
PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
|
||||
PopOutSpriteText.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing);
|
||||
PopOutCount.FadeOut(PopOutDuration, PopOutEasing);
|
||||
PopOutCount.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing);
|
||||
}
|
||||
|
||||
base.OnCountRolling(currentValue, newValue);
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = i as OsuBaseHit;
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Taiko", i);
|
||||
|
||||
|
@ -136,7 +136,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
||||
Assert.AreEqual(956, slider.StartTime);
|
||||
Assert.AreEqual(SampleType.None, slider.Sample.Type);
|
||||
var circle = beatmap.HitObjects[1] as Circle;
|
||||
var circle = beatmap.HitObjects[1] as HitCircle;
|
||||
Assert.IsNotNull(circle);
|
||||
Assert.AreEqual(new Vector2(304, 56), circle.Position);
|
||||
Assert.AreEqual(1285, circle.StartTime);
|
||||
|
51
osu.Game/Modes/HitJudgementResolver.cs
Normal file
51
osu.Game/Modes/HitJudgementResolver.cs
Normal file
@ -0,0 +1,51 @@
|
||||
//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.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public class HitJudgementResolver
|
||||
{
|
||||
public JudgementResult CheckJudgement(HitObject h) => new JudgementResult { Combo = ComboJudgement.None, Judgement = Judgement.Hit300 };
|
||||
}
|
||||
|
||||
public struct JudgementResult
|
||||
{
|
||||
public ComboJudgement Combo;
|
||||
public Judgement Judgement;
|
||||
public float TimeOffset;
|
||||
public Vector2 PositionOffset;
|
||||
}
|
||||
|
||||
public enum ComboJudgement
|
||||
{
|
||||
[Description(@"")]
|
||||
None,
|
||||
[Description(@"Good")]
|
||||
Good,
|
||||
[Description(@"Amazing")]
|
||||
Perfect
|
||||
}
|
||||
|
||||
public enum Judgement
|
||||
{
|
||||
[Description(@"Miss")]
|
||||
Miss,
|
||||
[Description(@"50")]
|
||||
Hit50,
|
||||
[Description(@"100")]
|
||||
Hit100,
|
||||
[Description(@"300")]
|
||||
Hit300,
|
||||
[Description(@"500")]
|
||||
Hit500
|
||||
}
|
||||
}
|
@ -15,6 +15,10 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
|
||||
public Func<DrawableHitObject, bool> AllowHit;
|
||||
|
||||
public Container<DrawableHitObject> ChildObjects;
|
||||
|
||||
public JudgementResult Result;
|
||||
|
||||
public HitObject HitObject;
|
||||
|
||||
public DrawableHitObject(HitObject hitObject)
|
||||
@ -53,12 +57,6 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
UpdateState(state);
|
||||
}
|
||||
|
||||
private bool counted;
|
||||
|
||||
protected override void Update()
|
||||
|
@ -22,6 +22,8 @@ namespace osu.Game.Modes
|
||||
|
||||
public abstract HitObjectParser CreateHitObjectParser();
|
||||
|
||||
public virtual HitJudgementResolver CreateHitJudgement() => new HitJudgementResolver();
|
||||
|
||||
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
|
||||
|
||||
protected abstract PlayMode PlayMode { get; }
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.MathUtils;
|
||||
@ -16,7 +17,7 @@ namespace osu.Game.Modes.UI
|
||||
get; protected set;
|
||||
}
|
||||
|
||||
protected SpriteText PopOutSpriteText;
|
||||
protected SpriteText PopOutCount;
|
||||
|
||||
protected virtual double PopOutDuration => 150;
|
||||
protected virtual float PopOutScale => 2.0f;
|
||||
@ -86,7 +87,7 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
textSize = value;
|
||||
DisplayedCountSpriteText.TextSize = TextSize;
|
||||
PopOutSpriteText.TextSize = TextSize;
|
||||
PopOutCount.TextSize = TextSize;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,13 +104,19 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
Alpha = 0,
|
||||
},
|
||||
PopOutSpriteText = new SpriteText
|
||||
PopOutCount = new SpriteText
|
||||
{
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding(0.05f),
|
||||
}
|
||||
};
|
||||
|
||||
TextSize = 80;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
DisplayedCountSpriteText.Text = FormatCount(Count);
|
||||
DisplayedCountSpriteText.Anchor = Anchor;
|
||||
@ -192,13 +199,12 @@ namespace osu.Game.Modes.UI
|
||||
|
||||
private void updateCount(ulong value, bool rolling = false)
|
||||
{
|
||||
ulong prevCount = count;
|
||||
count = value;
|
||||
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
ulong prevCount = count;
|
||||
|
||||
if (!rolling)
|
||||
{
|
||||
Flush(false, typeof(TransformComboRoll));
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Modes.UI
|
||||
|
||||
protected Playfield Playfield;
|
||||
|
||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.Children.Cast<DrawableHitObject>();
|
||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
||||
}
|
||||
|
||||
public abstract class HitRenderer<T> : HitRenderer
|
||||
|
@ -1,11 +1,30 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
public class Playfield : Container
|
||||
public abstract class Playfield : Container
|
||||
{
|
||||
public HitObjectContainer HitObjects;
|
||||
|
||||
public virtual void Add(DrawableHitObject h) => HitObjects.Add(h);
|
||||
|
||||
public Playfield()
|
||||
{
|
||||
AddInternal(HitObjects = new HitObjectContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
}
|
||||
|
||||
public class HitObjectContainer : Container<DrawableHitObject>
|
||||
{
|
||||
protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ namespace osu.Game
|
||||
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
|
||||
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));
|
||||
|
||||
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera"));
|
||||
|
||||
OszArchiveReader.Register();
|
||||
|
||||
Dependencies.Cache(API = new APIAccess
|
||||
|
@ -13,7 +13,6 @@ using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.UI;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using OpenTK.Input;
|
||||
using MouseState = osu.Framework.Input.MouseState;
|
||||
@ -30,45 +29,14 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
||||
PlayerInputManager inputManager;
|
||||
|
||||
class PlayerInputManager : UserInputManager
|
||||
{
|
||||
public PlayerInputManager(BasicGameHost host)
|
||||
: base(host)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateMouseState(InputState state)
|
||||
{
|
||||
base.UpdateMouseState(state);
|
||||
|
||||
MouseState mouse = (MouseState)state.Mouse;
|
||||
|
||||
foreach (Key k in state.Keyboard.Keys)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case Key.Z:
|
||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
|
||||
break;
|
||||
case Key.X:
|
||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PlayMode PreferredPlayMode;
|
||||
|
||||
protected override IFrameBasedClock Clock => playerClock;
|
||||
|
||||
private InterpolatingFramedClock playerClock;
|
||||
private IAdjustableClock sourceClock;
|
||||
private Ruleset Ruleset;
|
||||
|
||||
private Ruleset ruleset;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game)
|
||||
@ -102,9 +70,6 @@ namespace osu.Game.Screens.Play
|
||||
sourceClock.Start();
|
||||
});
|
||||
|
||||
HitRenderer hitRenderer;
|
||||
ScoreOverlay scoreOverlay;
|
||||
|
||||
var beatmap = Beatmap.Beatmap;
|
||||
|
||||
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
|
||||
@ -116,11 +81,10 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;
|
||||
|
||||
Ruleset = Ruleset.GetRuleset(usablePlayMode);
|
||||
ruleset = Ruleset.GetRuleset(usablePlayMode);
|
||||
|
||||
scoreOverlay = Ruleset.CreateScoreOverlay();
|
||||
|
||||
hitRenderer = Ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
||||
var scoreOverlay = ruleset.CreateScoreOverlay();
|
||||
var hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
||||
|
||||
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
||||
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
||||
@ -130,7 +94,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
inputManager = new PlayerInputManager(game.Host)
|
||||
new PlayerInputManager(game.Host)
|
||||
{
|
||||
PassThrough = false,
|
||||
Children = new Drawable[]
|
||||
@ -147,5 +111,34 @@ namespace osu.Game.Screens.Play
|
||||
base.Update();
|
||||
playerClock.ProcessFrame();
|
||||
}
|
||||
|
||||
class PlayerInputManager : UserInputManager
|
||||
{
|
||||
public PlayerInputManager(BasicGameHost host)
|
||||
: base(host)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateMouseState(InputState state)
|
||||
{
|
||||
base.UpdateMouseState(state);
|
||||
|
||||
MouseState mouse = (MouseState)state.Mouse;
|
||||
|
||||
foreach (Key k in state.Keyboard.Keys)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case Key.Z:
|
||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
|
||||
break;
|
||||
case Key.X:
|
||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Modes\HitJudgementResolver.cs" />
|
||||
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||
<Compile Include="Overlays\DragBar.cs" />
|
||||
<Compile Include="Overlays\MusicController.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user