2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-19 10:44:03 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2016-11-14 09:03:20 +00:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2017-01-10 08:01:53 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-01-27 12:57:22 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2016-10-19 10:44:03 +00:00
|
|
|
|
|
2016-11-14 09:54:24 +00:00
|
|
|
|
namespace osu.Game.Modes.UI
|
2016-10-19 10:44:03 +00:00
|
|
|
|
{
|
|
|
|
|
public abstract class ScoreOverlay : Container
|
|
|
|
|
{
|
|
|
|
|
public KeyCounterCollection KeyCounter;
|
|
|
|
|
public ComboCounter ComboCounter;
|
|
|
|
|
public ScoreCounter ScoreCounter;
|
|
|
|
|
public PercentageCounter AccuracyCounter;
|
2017-01-18 03:08:16 +00:00
|
|
|
|
public HealthDisplay HealthDisplay;
|
2016-11-29 06:41:48 +00:00
|
|
|
|
public Score Score { get; set; }
|
2016-10-19 10:44:03 +00:00
|
|
|
|
|
|
|
|
|
protected abstract KeyCounterCollection CreateKeyCounter();
|
|
|
|
|
protected abstract ComboCounter CreateComboCounter();
|
|
|
|
|
protected abstract PercentageCounter CreateAccuracyCounter();
|
|
|
|
|
protected abstract ScoreCounter CreateScoreCounter();
|
2017-01-18 03:08:16 +00:00
|
|
|
|
protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay
|
2017-01-10 08:01:53 +00:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(0.5f, 20),
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Padding = new MarginPadding(5)
|
|
|
|
|
};
|
2016-10-19 10:44:03 +00:00
|
|
|
|
|
|
|
|
|
public virtual void OnHit(HitObject h)
|
|
|
|
|
{
|
|
|
|
|
ComboCounter?.Increment();
|
|
|
|
|
ScoreCounter?.Increment(300);
|
|
|
|
|
AccuracyCounter?.Set(Math.Min(1, AccuracyCounter.Count + 0.01f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void OnMiss(HitObject h)
|
|
|
|
|
{
|
|
|
|
|
ComboCounter?.Roll();
|
|
|
|
|
AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScoreOverlay()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[] {
|
|
|
|
|
KeyCounter = CreateKeyCounter(),
|
|
|
|
|
ComboCounter = CreateComboCounter(),
|
|
|
|
|
ScoreCounter = CreateScoreCounter(),
|
|
|
|
|
AccuracyCounter = CreateAccuracyCounter(),
|
2017-01-18 03:08:16 +00:00
|
|
|
|
HealthDisplay = CreateHealthDisplay(),
|
2016-10-19 10:44:03 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2016-11-29 11:30:16 +00:00
|
|
|
|
|
|
|
|
|
public void BindProcessor(ScoreProcessor processor)
|
|
|
|
|
{
|
2016-11-29 12:28:43 +00:00
|
|
|
|
//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); };
|
2017-01-24 10:04:03 +00:00
|
|
|
|
HealthDisplay?.Current.Weld(processor.Health);
|
2016-11-29 11:30:16 +00:00
|
|
|
|
}
|
2016-10-19 10:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|