Merge remote-tracking branch 'refs/remotes/upstream/master' into fix-depth

This commit is contained in:
Dean Herbert
2016-11-30 12:21:12 +09:00
23 changed files with 528 additions and 215 deletions

View File

@ -13,13 +13,11 @@ namespace osu.Game.Modes.Objects.Drawables
{
public abstract class DrawableHitObject : Container, IStateful<ArmedState>
{
//todo: move to a more central implementation. this logic should not be at a drawable level.
public Action<DrawableHitObject, JudgementInfo> OnHit;
public Action<DrawableHitObject, JudgementInfo> OnMiss;
public event Action<DrawableHitObject, JudgementInfo> OnJudgement;
public Container<DrawableHitObject> ChildObjects;
protected JudgementInfo Judgement;
public JudgementInfo Judgement;
public abstract JudgementInfo CreateJudgementInfo();
@ -73,20 +71,20 @@ namespace osu.Game.Modes.Objects.Drawables
{
default:
State = ArmedState.Hit;
OnHit?.Invoke(this, Judgement);
break;
case HitResult.Miss:
State = ArmedState.Miss;
OnMiss?.Invoke(this, Judgement);
break;
}
OnJudgement?.Invoke(this, Judgement);
return true;
}
protected virtual void CheckJudgement(bool userTriggered)
{
//todo: consider making abstract.
}
protected override void Update()
@ -113,6 +111,7 @@ namespace osu.Game.Modes.Objects.Drawables
public class JudgementInfo
{
public ulong? ComboAtHit;
public HitResult? Result;
public double TimeOffset;
}

View File

@ -18,6 +18,8 @@ namespace osu.Game.Modes
public abstract ScoreOverlay CreateScoreOverlay();
public abstract ScoreProcessor CreateScoreProcessor();
public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects);
public abstract HitObjectParser CreateHitObjectParser();

19
osu.Game/Modes/Score.cs Normal file
View File

@ -0,0 +1,19 @@
//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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Modes
{
public class Score
{
public double TotalScore { get; set; }
public double Accuracy { get; set; }
public double Combo { get; set; }
public double MaxCombo { get; set; }
}
}

View File

@ -0,0 +1,54 @@
//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.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Configuration;
using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes
{
public abstract class ScoreProcessor
{
public virtual Score GetScore() => new Score()
{
TotalScore = TotalScore,
Combo = Combo,
MaxCombo = HighestCombo,
Accuracy = Accuracy
};
public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 };
public readonly BindableInt Combo = new BindableInt();
public readonly BindableInt HighestCombo = new BindableInt();
public readonly List<JudgementInfo> Judgements = new List<JudgementInfo>();
public ScoreProcessor()
{
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
}
public void AddJudgement(JudgementInfo judgement)
{
Judgements.Add(judgement);
UpdateCalculations(judgement);
judgement.ComboAtHit = (ulong)Combo.Value;
}
/// <summary>
/// Update any values that potentially need post-processing on a judgement change.
/// </summary>
/// <param name="newJudgement">A new JudgementInfo that triggered this calculation. May be null.</param>
protected abstract void UpdateCalculations(JudgementInfo newJudgement);
}
}

View File

@ -262,5 +262,13 @@ namespace osu.Game.Modes.UI
(d as ComboCounter).DisplayedCount = CurrentValue;
}
}
public void Set(ulong value)
{
if (value == 0)
Roll();
else
Count = value;
}
}
}

View File

@ -14,11 +14,21 @@ namespace osu.Game.Modes.UI
{
public abstract class HitRenderer : Container
{
public Action<HitObject> OnHit;
public Action<HitObject> OnMiss;
public event Action<JudgementInfo> OnJudgement;
public event Action OnAllJudged;
protected void TriggerOnJudgement(JudgementInfo j)
{
OnJudgement?.Invoke(j);
if (AllObjectsJudged)
OnAllJudged?.Invoke();
}
protected Playfield Playfield;
public bool AllObjectsJudged => Playfield.HitObjects.Children.First()?.Judgement.Result != null; //reverse depth sort means First() instead of Last().
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
}
@ -68,22 +78,13 @@ namespace osu.Game.Modes.UI
if (drawableObject == null) continue;
drawableObject.OnHit = onHit;
drawableObject.OnMiss = onMiss;
drawableObject.OnJudgement += onJudgement;
Playfield.Add(drawableObject);
}
}
private void onMiss(DrawableHitObject obj, JudgementInfo judgement)
{
OnMiss?.Invoke(obj.HitObject);
}
private void onHit(DrawableHitObject obj, JudgementInfo judgement)
{
OnHit?.Invoke(obj.HitObject);
}
private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j);
protected abstract DrawableHitObject GetVisualRepresentation(T h);
}

View File

@ -15,6 +15,7 @@ namespace osu.Game.Modes.UI
public ComboCounter ComboCounter;
public ScoreCounter ScoreCounter;
public PercentageCounter AccuracyCounter;
public Score Score { get; set; }
protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter();
@ -45,5 +46,13 @@ namespace osu.Game.Modes.UI
AccuracyCounter = CreateAccuracyCounter(),
};
}
public void BindProcessor(ScoreProcessor processor)
{
//bind processor bindables to combocounter, score display etc.
processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); };
processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); };
processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); };
}
}
}