2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-10-10 15:34:01 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects
|
|
|
|
|
{
|
2017-11-28 17:37:41 +08:00
|
|
|
|
public class JuiceStream : CatchHitObject, IHasCurve
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-10-12 21:27:22 +08:00
|
|
|
|
/// Positional distance that results in a duration of one second, before any speed adjustments.
|
2017-10-10 15:34:01 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
private const float base_scoring_distance = 100;
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
public int RepeatCount { get; set; }
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
|
|
|
|
public double Velocity;
|
|
|
|
|
public double TickDistance;
|
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
|
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
|
|
|
|
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
|
|
|
|
|
|
|
|
|
double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
|
|
|
|
|
|
|
|
|
|
Velocity = scoringDistance / timingPoint.BeatLength;
|
|
|
|
|
TickDistance = scoringDistance / difficulty.SliderTickRate;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
protected override void CreateNestedHitObjects()
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
base.CreateNestedHitObjects();
|
2017-10-11 19:11:29 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
createTicks();
|
|
|
|
|
}
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
private void createTicks()
|
|
|
|
|
{
|
|
|
|
|
if (TickDistance == 0)
|
|
|
|
|
return;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
var length = Curve.Distance;
|
|
|
|
|
var tickDistance = Math.Min(TickDistance, length);
|
2018-01-23 12:37:25 +08:00
|
|
|
|
var spanDuration = length / Velocity;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
var minDistanceFromEnd = Velocity * 0.01;
|
2017-10-11 19:11:29 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
AddNested(new Fruit
|
|
|
|
|
{
|
|
|
|
|
Samples = Samples,
|
|
|
|
|
ComboColour = ComboColour,
|
|
|
|
|
StartTime = StartTime,
|
|
|
|
|
X = X
|
|
|
|
|
});
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
for (var span = 0; span < this.SpanCount(); span++)
|
2017-12-22 20:42:54 +08:00
|
|
|
|
{
|
2018-01-23 12:37:25 +08:00
|
|
|
|
var spanStartTime = StartTime + span * spanDuration;
|
|
|
|
|
var reversed = span % 2 == 1;
|
2017-12-22 20:42:54 +08:00
|
|
|
|
|
|
|
|
|
for (var d = tickDistance; d <= length; d += tickDistance)
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
if (d > length - minDistanceFromEnd)
|
|
|
|
|
break;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
var timeProgress = d / length;
|
|
|
|
|
var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
var lastTickTime = spanStartTime + timeProgress * spanDuration;
|
2017-12-22 20:42:54 +08:00
|
|
|
|
AddNested(new Droplet
|
2017-10-10 15:34:01 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
StartTime = lastTickTime,
|
|
|
|
|
ComboColour = ComboColour,
|
2018-02-24 01:59:55 +08:00
|
|
|
|
X = X + Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
|
2017-12-25 14:35:28 +08:00
|
|
|
|
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
2017-12-22 20:42:54 +08:00
|
|
|
|
{
|
|
|
|
|
Bank = s.Bank,
|
|
|
|
|
Name = @"slidertick",
|
|
|
|
|
Volume = s.Volume
|
|
|
|
|
}))
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
double tinyTickInterval = tickDistance / length * spanDuration;
|
2017-12-22 20:42:54 +08:00
|
|
|
|
while (tinyTickInterval > 100)
|
|
|
|
|
tinyTickInterval /= 2;
|
2017-10-11 18:10:07 +08:00
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
for (double t = 0; t < spanDuration; t += tinyTickInterval)
|
2017-12-22 20:42:54 +08:00
|
|
|
|
{
|
2018-01-23 12:37:25 +08:00
|
|
|
|
double progress = reversed ? 1 - t / spanDuration : t / spanDuration;
|
2017-10-11 19:11:29 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
AddNested(new TinyDroplet
|
2017-10-11 18:10:07 +08:00
|
|
|
|
{
|
2018-01-23 12:37:25 +08:00
|
|
|
|
StartTime = spanStartTime + t,
|
2017-10-11 18:10:07 +08:00
|
|
|
|
ComboColour = ComboColour,
|
2018-02-24 01:59:55 +08:00
|
|
|
|
X = X + Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
|
2017-12-25 14:35:28 +08:00
|
|
|
|
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
2017-12-22 20:42:54 +08:00
|
|
|
|
{
|
|
|
|
|
Bank = s.Bank,
|
|
|
|
|
Name = @"slidertick",
|
|
|
|
|
Volume = s.Volume
|
|
|
|
|
}))
|
2017-10-11 19:11:29 +08:00
|
|
|
|
});
|
2017-10-10 15:34:01 +08:00
|
|
|
|
}
|
2017-10-11 19:11:29 +08:00
|
|
|
|
|
2017-12-22 20:42:54 +08:00
|
|
|
|
AddNested(new Fruit
|
|
|
|
|
{
|
|
|
|
|
Samples = Samples,
|
|
|
|
|
ComboColour = ComboColour,
|
2018-01-23 12:37:25 +08:00
|
|
|
|
StartTime = spanStartTime + spanDuration,
|
2018-02-24 01:59:55 +08:00
|
|
|
|
X = X + Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
|
2017-12-22 20:42:54 +08:00
|
|
|
|
});
|
2017-10-10 15:34:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
2018-02-24 01:59:55 +08:00
|
|
|
|
public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
|
|
|
|
public double Duration => EndTime - StartTime;
|
|
|
|
|
|
|
|
|
|
public double Distance
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.Distance; }
|
|
|
|
|
set { Curve.Distance = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-23 12:37:25 +08:00
|
|
|
|
public SliderCurve Curve { get; } = new SliderCurve();
|
|
|
|
|
|
2017-10-10 15:34:01 +08:00
|
|
|
|
public List<Vector2> ControlPoints
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.ControlPoints; }
|
|
|
|
|
set { Curve.ControlPoints = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-25 14:35:28 +08:00
|
|
|
|
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
|
2017-10-10 15:34:01 +08:00
|
|
|
|
|
|
|
|
|
public CurveType CurveType
|
|
|
|
|
{
|
|
|
|
|
get { return Curve.CurveType; }
|
|
|
|
|
set { Curve.CurveType = value; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|