2017-02-07 12:59:30 +08: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-09-02 17:35:49 +08:00
|
|
|
|
|
2016-12-06 20:14:38 +08:00
|
|
|
|
using OpenTK;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
using osu.Game.Beatmaps.Samples;
|
2017-02-16 01:55:49 +08:00
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
2017-03-13 18:15:25 +08:00
|
|
|
|
using osu.Game.Modes.Objects.Types;
|
2017-02-15 17:48:29 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-03-15 11:52:25 +08:00
|
|
|
|
using osu.Game.Modes.Objects;
|
2017-03-16 16:24:41 +08:00
|
|
|
|
using osu.Game.Database;
|
2016-09-02 17:35:49 +08:00
|
|
|
|
|
2016-11-14 17:54:24 +08:00
|
|
|
|
namespace osu.Game.Modes.Osu.Objects
|
2016-09-02 17:35:49 +08:00
|
|
|
|
{
|
2017-03-15 11:52:25 +08:00
|
|
|
|
public class Slider : OsuHitObject, IHasCurve
|
2016-09-02 17:35:49 +08:00
|
|
|
|
{
|
2017-04-03 13:10:20 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Scoring distance with a speed-adjusted beat length of 1 second.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float base_scoring_distance = 100;
|
|
|
|
|
|
2017-03-15 11:52:25 +08:00
|
|
|
|
public IHasCurve CurveObject { get; set; }
|
|
|
|
|
|
|
|
|
|
public SliderCurve Curve => CurveObject.Curve;
|
|
|
|
|
|
|
|
|
|
public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity;
|
2017-03-13 18:15:25 +08:00
|
|
|
|
public double Duration => EndTime - StartTime;
|
2016-11-28 14:31:54 +08:00
|
|
|
|
|
2017-03-06 10:11:29 +08:00
|
|
|
|
public override Vector2 EndPosition => PositionAt(1);
|
|
|
|
|
|
2017-03-15 11:52:25 +08:00
|
|
|
|
public Vector2 PositionAt(double progress) => CurveObject.PositionAt(progress);
|
|
|
|
|
public double ProgressAt(double progress) => CurveObject.ProgressAt(progress);
|
|
|
|
|
public int RepeatAt(double progress) => CurveObject.RepeatAt(progress);
|
2017-03-06 10:11:29 +08:00
|
|
|
|
|
2017-03-15 11:52:25 +08:00
|
|
|
|
public List<Vector2> ControlPoints => CurveObject.ControlPoints;
|
|
|
|
|
public CurveType CurveType => CurveObject.CurveType;
|
|
|
|
|
public double Distance => CurveObject.Distance;
|
|
|
|
|
|
|
|
|
|
public int RepeatCount => CurveObject.RepeatCount;
|
2016-12-06 20:14:38 +08:00
|
|
|
|
|
2017-02-09 15:29:21 +08:00
|
|
|
|
private int stackHeight;
|
|
|
|
|
public override int StackHeight
|
|
|
|
|
{
|
|
|
|
|
get { return stackHeight; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
stackHeight = value;
|
2017-02-14 17:40:37 +08:00
|
|
|
|
Curve.Offset = StackOffset;
|
2017-02-09 15:29:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 17:45:50 +08:00
|
|
|
|
public double Velocity;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
public double TickDistance;
|
2016-11-28 17:45:50 +08:00
|
|
|
|
|
2017-03-16 23:38:40 +08:00
|
|
|
|
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
2016-11-28 17:45:50 +08:00
|
|
|
|
{
|
2017-03-16 16:24:41 +08:00
|
|
|
|
base.ApplyDefaults(timing, difficulty);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
2017-04-03 13:10:20 +08:00
|
|
|
|
double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / timing.SpeedMultiplierAt(StartTime);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
2017-04-03 13:10:20 +08:00
|
|
|
|
Velocity = scoringDistance / timing.BeatLengthAt(StartTime);
|
|
|
|
|
TickDistance = scoringDistance / difficulty.SliderTickRate;
|
2016-11-28 17:45:50 +08:00
|
|
|
|
}
|
2016-09-02 17:35:49 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
public IEnumerable<SliderTick> Ticks
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-16 12:20:30 +08:00
|
|
|
|
if (TickDistance == 0) yield break;
|
|
|
|
|
|
2017-03-15 11:52:25 +08:00
|
|
|
|
var length = Curve.Distance;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
var tickDistance = Math.Min(TickDistance, length);
|
|
|
|
|
var repeatDuration = length / Velocity;
|
|
|
|
|
|
|
|
|
|
var minDistanceFromEnd = Velocity * 0.01;
|
|
|
|
|
|
|
|
|
|
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
|
|
|
|
{
|
|
|
|
|
var repeatStartTime = StartTime + repeat * repeatDuration;
|
|
|
|
|
var reversed = repeat % 2 == 1;
|
|
|
|
|
|
|
|
|
|
for (var d = tickDistance; d <= length; d += tickDistance)
|
|
|
|
|
{
|
|
|
|
|
if (d > length - minDistanceFromEnd)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
var distanceProgress = d / length;
|
|
|
|
|
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
|
|
|
|
|
|
|
|
|
yield return new SliderTick
|
|
|
|
|
{
|
|
|
|
|
RepeatIndex = repeat,
|
|
|
|
|
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
2017-02-16 16:02:36 +08:00
|
|
|
|
Position = Curve.PositionAt(distanceProgress),
|
2017-02-13 03:38:05 +08:00
|
|
|
|
StackHeight = StackHeight,
|
|
|
|
|
Scale = Scale,
|
2017-03-13 18:15:25 +08:00
|
|
|
|
ComboColour = ComboColour,
|
2017-02-13 03:38:05 +08:00
|
|
|
|
Sample = new HitSampleInfo
|
|
|
|
|
{
|
|
|
|
|
Type = SampleType.None,
|
|
|
|
|
Set = SampleSet.Soft,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-02 17:35:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|