1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:43:21 +08:00

Standardise some naming and make hitcircles feel better.

This commit is contained in:
Dean Herbert 2016-11-19 19:07:57 +09:00
parent d359057db6
commit 3ac89216bd
18 changed files with 112 additions and 62 deletions

View File

@ -11,6 +11,7 @@ using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.Graphics.Containers;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -34,6 +35,10 @@ namespace osu.Desktop.VisualTests.Tests
ourClock.ProcessFrame(); ourClock.ProcessFrame();
Container approachContainer = new Container { Depth = float.MaxValue, };
Add(approachContainer);
const int count = 10; const int count = 10;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -44,13 +49,16 @@ namespace osu.Desktop.VisualTests.Tests
Position = new Vector2((i - count / 2) * 14), Position = new Vector2((i - count / 2) * 14),
}; };
Add(new DrawableHitCircle(h) DrawableHitCircle d = new DrawableHitCircle(h)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Depth = -i, Depth = -i,
State = ArmedState.Armed, State = ArmedState.Armed,
}); };
approachContainer.Add(d.ApproachCircle.CreateProxy());
Add(d);
} }
} }

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations; using osu.Framework.Graphics.Transformations;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
@ -11,9 +12,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
public class DrawableHitCircle : DrawableHitObject public class DrawableHitCircle : DrawableHitObject
{ {
private OsuBaseHit osuObject; private OsuHitObject osuObject;
private ApproachCircle approachCircle; public ApproachCircle ApproachCircle;
private CirclePiece circle; private CirclePiece circle;
private RingPiece ring; private RingPiece ring;
private FlashPiece flash; private FlashPiece flash;
@ -25,11 +26,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
public DrawableHitCircle(HitCircle h) : base(h) public DrawableHitCircle(HitCircle h) : base(h)
{ {
osuObject = h; osuObject = h;
}
protected override void LoadComplete()
{
base.LoadComplete();
Origin = Anchor.Centre; Origin = Anchor.Centre;
Position = osuObject.Position; Position = osuObject.Position;
@ -52,11 +48,16 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
Colour = osuObject.Colour, Colour = osuObject.Colour,
}, },
approachCircle = new ApproachCircle() ApproachCircle = new ApproachCircle()
{ {
Colour = osuObject.Colour, Colour = osuObject.Colour,
} }
}; };
}
protected override void LoadComplete()
{
base.LoadComplete();
//may not be so correct //may not be so correct
Size = circle.DrawSize; Size = circle.DrawSize;
@ -70,26 +71,33 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
if (!IsLoaded) return; if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject Flush(true); //move to DrawableHitObject
approachCircle.Flush(true); ApproachCircle.Flush(true);
double t = HitTime ?? osuObject.StartTime; double t = HitTime ?? osuObject.StartTime;
Alpha = 0; Alpha = 0;
//sane defaults //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; explode.Alpha = 0;
Scale = new Vector2(0.5f); //this will probably need to be moved to DrawableHitObject at some point. Scale = new Vector2(0.5f); //this will probably need to be moved to DrawableHitObject at some point.
//always-present transforms const float preempt = 600;
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 fadein = 400;
//set transform delay to t==hitTime Delay(t - Time.Current - preempt, true);
Delay(t - Time.Current, true);
approachCircle.FadeOut(); FadeIn(fadein);
ApproachCircle.FadeIn(Math.Min(fadein * 2, preempt));
ApproachCircle.ScaleTo(0.6f, preempt);
Delay(preempt, true);
ApproachCircle.FadeOut();
glow.FadeOut(400); glow.FadeOut(400);

View File

@ -3,7 +3,7 @@
namespace osu.Game.Modes.Osu.Objects namespace osu.Game.Modes.Osu.Objects
{ {
public class HitCircle : OsuBaseHit public class HitCircle : OsuHitObject
{ {
} }
} }

View File

@ -8,7 +8,7 @@ using OpenTK;
namespace osu.Game.Modes.Osu.Objects namespace osu.Game.Modes.Osu.Objects
{ {
public abstract class OsuBaseHit : HitObject public abstract class OsuHitObject : HitObject
{ {
public Vector2 Position { get; set; } public Vector2 Position { get; set; }

View File

@ -6,14 +6,14 @@ using osu.Game.Modes.Objects;
namespace osu.Game.Modes.Osu.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) foreach (HitObject h in input)
output.Add(h as OsuBaseHit); output.Add(h as OsuHitObject);
return output; return output;
} }

View File

@ -15,17 +15,17 @@ namespace osu.Game.Modes.Osu.Objects
public override HitObject Parse(string text) public override HitObject Parse(string text)
{ {
string[] split = text.Split(','); string[] split = text.Split(',');
var type = (OsuBaseHit.HitObjectType)int.Parse(split[3]); var type = (OsuHitObject.HitObjectType)int.Parse(split[3]);
bool combo = type.HasFlag(OsuBaseHit.HitObjectType.NewCombo); bool combo = type.HasFlag(OsuHitObject.HitObjectType.NewCombo);
type &= (OsuBaseHit.HitObjectType)0xF; type &= (OsuHitObject.HitObjectType)0xF;
type &= ~OsuBaseHit.HitObjectType.NewCombo; type &= ~OsuHitObject.HitObjectType.NewCombo;
OsuBaseHit result; OsuHitObject result;
switch (type) switch (type)
{ {
case OsuBaseHit.HitObjectType.Circle: case OsuHitObject.HitObjectType.Circle:
result = new HitCircle(); result = new HitCircle();
break; break;
case OsuBaseHit.HitObjectType.Slider: case OsuHitObject.HitObjectType.Slider:
Slider s = new Slider(); Slider s = new Slider();
CurveTypes curveType = CurveTypes.Catmull; CurveTypes curveType = CurveTypes.Catmull;
@ -89,7 +89,7 @@ namespace osu.Game.Modes.Osu.Objects
result = s; result = s;
break; break;
case OsuBaseHit.HitObjectType.Spinner: case OsuHitObject.HitObjectType.Spinner:
result = new Spinner(); result = new Spinner();
break; break;
default: default:

View File

@ -6,7 +6,7 @@ using OpenTK;
namespace osu.Game.Modes.Osu.Objects namespace osu.Game.Modes.Osu.Objects
{ {
public class Slider : OsuBaseHit public class Slider : OsuHitObject
{ {
public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length; public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length;

View File

@ -3,7 +3,7 @@
namespace osu.Game.Modes.Osu.Objects namespace osu.Game.Modes.Osu.Objects
{ {
public class Spinner : OsuBaseHit public class Spinner : OsuHitObject
{ {
} }
} }

View File

@ -6,18 +6,17 @@ using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using OsuBaseHit = osu.Game.Modes.Osu.Objects.OsuBaseHit; using OsuConverter = osu.Game.Modes.Osu.Objects.OsuHitObjectConverter;
using OsuConverter = osu.Game.Modes.Osu.Objects.OsuConverter;
namespace osu.Game.Modes.Osu.UI 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 Playfield CreatePlayfield() => new OsuPlayfield();
protected override DrawableHitObject GetVisualRepresentation(OsuBaseHit h) protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h)
{ {
if (h is HitCircle) if (h is HitCircle)
return new DrawableHitCircle(h as HitCircle); return new DrawableHitCircle(h as HitCircle);

View File

@ -5,6 +5,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Modes.Objects.Drawables; 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 osu.Game.Modes.UI;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -13,9 +15,7 @@ namespace osu.Game.Modes.Osu.UI
{ {
public class OsuPlayfield : Playfield public class OsuPlayfield : Playfield
{ {
protected override Container<Drawable> Content => hitObjectContainer; private Container approachCircles;
private Container hitObjectContainer;
public override Vector2 Size public override Vector2 Size
{ {
@ -35,24 +35,33 @@ namespace osu.Game.Modes.Osu.UI
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Size = new Vector2(0.75f); Size = new Vector2(0.75f);
AddInternal(new Box AddInternal(new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, new Box
Anchor = Anchor.Centre, {
Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black, Anchor = Anchor.Centre,
Alpha = 0.5f, Origin = Anchor.Centre,
}); Colour = Color4.Black,
Depth = float.MinValue,
AddInternal(hitObjectContainer = new HitObjectContainer Alpha = 0.5f,
{ },
RelativeSizeAxes = Axes.Both, approachCircles = new Container
{
RelativeSizeAxes = Axes.Both,
}
}); });
} }
class HitObjectContainer : Container public override void Add(DrawableHitObject h)
{ {
protected override Vector2 DrawScale => new Vector2(DrawSize.X / 512); DrawableHitCircle c = h as DrawableHitCircle;
if (c != null)
{
approachCircles.Add(c.ApproachCircle.CreateProxy());
}
base.Add(h);
} }
} }
} }

View File

@ -58,8 +58,8 @@
<Compile Include="OsuRuleset.cs" /> <Compile Include="OsuRuleset.cs" />
<Compile Include="Objects\HitCircle.cs" /> <Compile Include="Objects\HitCircle.cs" />
<Compile Include="Objects\Drawables\DrawableHitCircle.cs" /> <Compile Include="Objects\Drawables\DrawableHitCircle.cs" />
<Compile Include="Objects\OsuBaseHit.cs" /> <Compile Include="Objects\OsuHitObject.cs" />
<Compile Include="Objects\OsuConverter.cs" /> <Compile Include="Objects\OsuHitObjectConverter.cs" />
<Compile Include="Objects\Slider.cs" /> <Compile Include="Objects\Slider.cs" />
<Compile Include="Objects\Spinner.cs" /> <Compile Include="Objects\Spinner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch.Objects
if (h == null) if (h == null)
{ {
OsuBaseHit o = i as OsuBaseHit; OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Catch", i); if (o == null) throw new HitObjectConvertException(@"Catch", i);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Modes.Mania.Objects
if (h == null) if (h == null)
{ {
OsuBaseHit o = i as OsuBaseHit; OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Mania", i); if (o == null) throw new HitObjectConvertException(@"Mania", i);

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko.Objects
if (h == null) if (h == null)
{ {
OsuBaseHit o = i as OsuBaseHit; OsuHitObject o = i as OsuHitObject;
if (o == null) throw new HitObjectConvertException(@"Taiko", i); if (o == null) throw new HitObjectConvertException(@"Taiko", i);

View File

@ -8,6 +8,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using OpenTK;
namespace osu.Game.Modes namespace osu.Game.Modes
{ {
@ -20,6 +21,8 @@ namespace osu.Game.Modes
{ {
public ComboJudgement Combo; public ComboJudgement Combo;
public Judgement Judgement; public Judgement Judgement;
public float TimeOffset;
public Vector2 PositionOffset;
} }
public enum ComboJudgement public enum ComboJudgement

View File

@ -15,6 +15,10 @@ namespace osu.Game.Modes.Objects.Drawables
public Func<DrawableHitObject, bool> AllowHit; public Func<DrawableHitObject, bool> AllowHit;
public Container<DrawableHitObject> ChildObjects;
public JudgementResult Result;
public HitObject HitObject; public HitObject HitObject;
public DrawableHitObject(HitObject hitObject) public DrawableHitObject(HitObject hitObject)

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.UI
protected Playfield Playfield; protected Playfield Playfield;
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.Children.Cast<DrawableHitObject>(); public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
} }
public abstract class HitRenderer<T> : HitRenderer public abstract class HitRenderer<T> : HitRenderer

View File

@ -1,11 +1,30 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Modes.Objects.Drawables;
using OpenTK;
namespace osu.Game.Modes.UI 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);
}
} }
} }