mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add basic flow for hitobject judgement.
This commit is contained in:
@ -50,7 +50,7 @@ namespace osu.Desktop.VisualTests.Tests
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Depth = -i,
|
Depth = -i,
|
||||||
State = ArmedState.Armed,
|
State = ArmedState.Hit,
|
||||||
};
|
};
|
||||||
|
|
||||||
approachContainer.Add(d.ApproachCircle.CreateProxy());
|
approachContainer.Add(d.ApproachCircle.CreateProxy());
|
||||||
|
@ -39,7 +39,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
circle = new CirclePiece
|
circle = new CirclePiece
|
||||||
{
|
{
|
||||||
Colour = osuObject.Colour,
|
Colour = osuObject.Colour,
|
||||||
Hit = Hit,
|
Hit = () => Hit(new JudgementInfo {
|
||||||
|
UserTriggered = true,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
number = new NumberPiece(),
|
number = new NumberPiece(),
|
||||||
ring = new RingPiece(),
|
ring = new RingPiece(),
|
||||||
@ -73,7 +75,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
Flush(true); //move to DrawableHitObject
|
Flush(true); //move to DrawableHitObject
|
||||||
ApproachCircle.Flush(true);
|
ApproachCircle.Flush(true);
|
||||||
|
|
||||||
double t = HitTime ?? osuObject.StartTime;
|
double t = osuObject.EndTime + (Judgement?.TimeOffset ?? 0);
|
||||||
|
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
|
|
||||||
@ -103,14 +105,26 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case ArmedState.Disarmed:
|
case ArmedState.Idle:
|
||||||
Delay(osuObject.Duration + 200);
|
Delay(osuObject.Duration + 500);
|
||||||
FadeOut(200);
|
FadeOut(500);
|
||||||
|
|
||||||
explosion?.Expire();
|
explosion?.Expire();
|
||||||
explosion = null;
|
explosion = null;
|
||||||
break;
|
break;
|
||||||
case ArmedState.Armed:
|
case ArmedState.Miss:
|
||||||
|
ring.FadeOut();
|
||||||
|
circle.FadeOut();
|
||||||
|
number.FadeOut();
|
||||||
|
|
||||||
|
explosion?.Expire();
|
||||||
|
explosion = null;
|
||||||
|
|
||||||
|
Schedule(() => Add(explosion = new HitExplosion(HitResult.Miss)));
|
||||||
|
|
||||||
|
FadeOut(800);
|
||||||
|
break;
|
||||||
|
case ArmedState.Hit:
|
||||||
const double flash_in = 30;
|
const double flash_in = 30;
|
||||||
|
|
||||||
flash.FadeTo(0.8f, flash_in);
|
flash.FadeTo(0.8f, flash_in);
|
||||||
@ -119,7 +133,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
|
|
||||||
explode.FadeIn(flash_in);
|
explode.FadeIn(flash_in);
|
||||||
|
|
||||||
Schedule(() => Add(explosion = new HitExplosion(Judgement.Hit300)));
|
Schedule(() => Add(explosion = new HitExplosion(Judgement.Result)));
|
||||||
|
|
||||||
Delay(flash_in, true);
|
Delay(flash_in, true);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
Add(new CirclePiece
|
Add(new CirclePiece
|
||||||
{
|
{
|
||||||
Colour = h.Colour,
|
Colour = h.Colour,
|
||||||
Hit = Hit,
|
Hit = () => Hit(new JudgementInfo()),
|
||||||
Position = h.Curve.PositionAt(i) - h.Position //non-relative?
|
Position = h.Curve.PositionAt(i) - h.Position //non-relative?
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
private SpriteText line1;
|
private SpriteText line1;
|
||||||
private SpriteText line2;
|
private SpriteText line2;
|
||||||
|
|
||||||
public HitExplosion(Judgement judgement, ComboJudgement comboJudgement = ComboJudgement.None)
|
public HitExplosion(HitResult hitResult, ComboResult comboResult = ComboResult.None)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
@ -27,13 +27,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Text = judgement.GetDescription(),
|
Text = hitResult.GetDescription(),
|
||||||
Font = @"Venera",
|
Font = @"Venera",
|
||||||
TextSize = 20,
|
TextSize = 20,
|
||||||
},
|
},
|
||||||
line2 = new SpriteText
|
line2 = new SpriteText
|
||||||
{
|
{
|
||||||
Text = comboJudgement.GetDescription(),
|
Text = comboResult.GetDescription(),
|
||||||
Font = @"Venera",
|
Font = @"Venera",
|
||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
}
|
}
|
||||||
|
41
osu.Game.Mode.Osu/OsuHitJudgementResolver.cs
Normal file
41
osu.Game.Mode.Osu/OsuHitJudgementResolver.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Osu
|
||||||
|
{
|
||||||
|
class OsuHitJudgementResolver : HitJudgementResolver
|
||||||
|
{
|
||||||
|
double hit50 = 150;
|
||||||
|
double hit100 = 80;
|
||||||
|
double hit300 = 30;
|
||||||
|
public override void CheckJudgement(DrawableHitObject h, JudgementInfo info)
|
||||||
|
{
|
||||||
|
DrawableHitCircle circle = h as DrawableHitCircle;
|
||||||
|
if (circle != null)
|
||||||
|
{
|
||||||
|
if (!info.UserTriggered)
|
||||||
|
{
|
||||||
|
if (info.TimeOffset > hit50)
|
||||||
|
info.Result = HitResult.Miss;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double hitOffset = Math.Abs(info.TimeOffset);
|
||||||
|
|
||||||
|
if (hitOffset < hit300)
|
||||||
|
info.Result = HitResult.Hit300;
|
||||||
|
else if (hitOffset < hit100)
|
||||||
|
info.Result = HitResult.Hit100;
|
||||||
|
else if (hitOffset < hit50)
|
||||||
|
info.Result = HitResult.Hit50;
|
||||||
|
else
|
||||||
|
info.Result = HitResult.Miss;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,8 @@ namespace osu.Game.Modes.Osu
|
|||||||
{
|
{
|
||||||
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
||||||
|
|
||||||
|
public override HitJudgementResolver CreateHitJudgement() => new OsuHitJudgementResolver();
|
||||||
|
|
||||||
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new OsuHitRenderer { Objects = objects };
|
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new OsuHitRenderer { Objects = objects };
|
||||||
|
|
||||||
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
|
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
|
||||||
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
||||||
|
<Compile Include="OsuHitJudgementResolver.cs" />
|
||||||
<Compile Include="UI\OsuComboCounter.cs" />
|
<Compile Include="UI\OsuComboCounter.cs" />
|
||||||
<Compile Include="UI\OsuHitRenderer.cs" />
|
<Compile Include="UI\OsuHitRenderer.cs" />
|
||||||
<Compile Include="UI\OsuPlayfield.cs" />
|
<Compile Include="UI\OsuPlayfield.cs" />
|
||||||
|
@ -4,28 +4,34 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
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 osu.Game.Modes.Objects.Drawables;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Modes
|
namespace osu.Game.Modes
|
||||||
{
|
{
|
||||||
public class HitJudgementResolver
|
public class HitJudgementResolver
|
||||||
{
|
{
|
||||||
public JudgementResult CheckJudgement(HitObject h) => new JudgementResult { Combo = ComboJudgement.None, Judgement = Judgement.Hit300 };
|
public virtual void CheckJudgement(DrawableHitObject h, JudgementInfo info)
|
||||||
|
{
|
||||||
|
info.Result = HitResult.Hit300;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct JudgementResult
|
public class JudgementInfo
|
||||||
{
|
{
|
||||||
public ComboJudgement Combo;
|
public bool UserTriggered;
|
||||||
public Judgement Judgement;
|
public ComboResult Combo;
|
||||||
public float TimeOffset;
|
public HitResult Result;
|
||||||
|
public double TimeOffset;
|
||||||
public Vector2 PositionOffset;
|
public Vector2 PositionOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ComboJudgement
|
public enum ComboResult
|
||||||
{
|
{
|
||||||
[Description(@"")]
|
[Description(@"")]
|
||||||
None,
|
None,
|
||||||
@ -35,8 +41,9 @@ namespace osu.Game.Modes
|
|||||||
Perfect
|
Perfect
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Judgement
|
public enum HitResult
|
||||||
{
|
{
|
||||||
|
Ignore,
|
||||||
[Description(@"Miss")]
|
[Description(@"Miss")]
|
||||||
Miss,
|
Miss,
|
||||||
[Description(@"50")]
|
[Description(@"50")]
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//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 System;
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
@ -13,11 +14,11 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
public Action<DrawableHitObject> OnHit;
|
public Action<DrawableHitObject> OnHit;
|
||||||
public Action<DrawableHitObject> OnMiss;
|
public Action<DrawableHitObject> OnMiss;
|
||||||
|
|
||||||
public Func<DrawableHitObject, bool> AllowHit;
|
public Action<DrawableHitObject, JudgementInfo> CheckJudgement;
|
||||||
|
|
||||||
public Container<DrawableHitObject> ChildObjects;
|
public Container<DrawableHitObject> ChildObjects;
|
||||||
|
|
||||||
public JudgementResult Result;
|
public JudgementInfo Judgement;
|
||||||
|
|
||||||
public HitObject HitObject;
|
public HitObject HitObject;
|
||||||
|
|
||||||
@ -41,36 +42,47 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double? HitTime;
|
/// <summary>
|
||||||
|
/// Process a hit of this hitobject. Carries out judgement.
|
||||||
protected virtual bool Hit()
|
/// </summary>
|
||||||
|
/// <param name="judgement">Preliminary judgement information provided by the hit source.</param>
|
||||||
|
/// <returns>Whether a hit was processed.</returns>
|
||||||
|
protected bool Hit(JudgementInfo judgement)
|
||||||
{
|
{
|
||||||
if (State != ArmedState.Disarmed)
|
if (State != ArmedState.Idle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AllowHit?.Invoke(this) == false)
|
judgement.TimeOffset = Time.Current - HitObject.EndTime;
|
||||||
|
|
||||||
|
CheckJudgement?.Invoke(this, judgement);
|
||||||
|
|
||||||
|
if (judgement.Result == HitResult.Ignore)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HitTime = Time.Current;
|
Judgement = judgement;
|
||||||
|
|
||||||
State = ArmedState.Armed;
|
switch (judgement.Result)
|
||||||
return true;
|
{
|
||||||
|
default:
|
||||||
|
State = ArmedState.Hit;
|
||||||
|
OnHit?.Invoke(this);
|
||||||
|
break;
|
||||||
|
case HitResult.Miss:
|
||||||
|
State = ArmedState.Miss;
|
||||||
|
OnMiss?.Invoke(this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool counted;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Time.Current >= HitObject.EndTime && !counted)
|
if (Time.Current >= HitObject.EndTime && Judgement == null)
|
||||||
{
|
Hit(new JudgementInfo());
|
||||||
counted = true;
|
|
||||||
if (state == ArmedState.Armed)
|
|
||||||
OnHit?.Invoke(this);
|
|
||||||
else
|
|
||||||
OnMiss?.Invoke(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void UpdateState(ArmedState state);
|
protected abstract void UpdateState(ArmedState state);
|
||||||
@ -78,7 +90,8 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
|
|
||||||
public enum ArmedState
|
public enum ArmedState
|
||||||
{
|
{
|
||||||
Disarmed,
|
Idle,
|
||||||
Armed
|
Hit,
|
||||||
|
Miss
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,11 +86,16 @@ namespace osu.Game.Screens.Play
|
|||||||
var scoreOverlay = ruleset.CreateScoreOverlay();
|
var scoreOverlay = ruleset.CreateScoreOverlay();
|
||||||
var hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
var hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
||||||
|
|
||||||
|
var hitJudgement = ruleset.CreateHitJudgement();
|
||||||
|
|
||||||
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
||||||
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
||||||
|
|
||||||
if (Autoplay)
|
if (Autoplay)
|
||||||
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Armed));
|
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.State = ArmedState.Hit));
|
||||||
|
|
||||||
|
//bind DrawableHitObjects to HitJudgement
|
||||||
|
hitRenderer.Schedule(() => hitRenderer.DrawableObjects.ForEach(h => h.CheckJudgement = hitJudgement.CheckJudgement));
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user