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.Osu.Objects;
using osu.Game.Modes.Osu.Objects.Drawables;
using osu.Framework.Graphics.Containers;
namespace osu.Desktop.VisualTests.Tests
{
@ -34,6 +35,10 @@ 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++)
@ -44,13 +49,16 @@ namespace osu.Desktop.VisualTests.Tests
Position = new Vector2((i - count / 2) * 14),
};
Add(new DrawableHitCircle(h)
DrawableHitCircle d = new DrawableHitCircle(h)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = -i,
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>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Modes.Objects.Drawables;
@ -11,9 +12,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
public class DrawableHitCircle : DrawableHitObject
{
private OsuBaseHit osuObject;
private OsuHitObject osuObject;
private ApproachCircle approachCircle;
public ApproachCircle ApproachCircle;
private CirclePiece circle;
private RingPiece ring;
private FlashPiece flash;
@ -25,11 +26,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
public DrawableHitCircle(HitCircle h) : base(h)
{
osuObject = h;
}
protected override void LoadComplete()
{
base.LoadComplete();
Origin = Anchor.Centre;
Position = osuObject.Position;
@ -52,11 +48,16 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
Colour = osuObject.Colour,
},
approachCircle = new ApproachCircle()
ApproachCircle = new ApproachCircle()
{
Colour = osuObject.Colour,
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
//may not be so correct
Size = circle.DrawSize;
@ -70,26 +71,33 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject
approachCircle.Flush(true);
ApproachCircle.Flush(true);
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 = 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 });
const float preempt = 600;
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, true);
Delay(t - Time.Current - preempt, 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);

View File

@ -3,7 +3,7 @@
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
{
public abstract class OsuBaseHit : HitObject
public abstract class OsuHitObject : HitObject
{
public Vector2 Position { get; set; }

View File

@ -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;
}

View File

@ -15,17 +15,17 @@ 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:
case OsuHitObject.HitObjectType.Circle:
result = new HitCircle();
break;
case OsuBaseHit.HitObjectType.Slider:
case OsuHitObject.HitObjectType.Slider:
Slider s = new Slider();
CurveTypes curveType = CurveTypes.Catmull;
@ -89,7 +89,7 @@ namespace osu.Game.Modes.Osu.Objects
result = s;
break;
case OsuBaseHit.HitObjectType.Spinner:
case OsuHitObject.HitObjectType.Spinner:
result = new Spinner();
break;
default:

View File

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

View File

@ -3,7 +3,7 @@
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.Drawables;
using osu.Game.Modes.UI;
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)
protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h)
{
if (h is 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.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;
@ -13,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
{
@ -35,24 +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,
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)
{
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="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" />

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

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

View File

@ -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)

View File

@ -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

View File

@ -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);
}
}
}