1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00
osu-lazer/osu.Game.Modes.Taiko/Objects/DrumRoll.cs

99 lines
3.2 KiB
C#
Raw Normal View History

2017-03-17 12:56:14 +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
using osu.Game.Modes.Objects.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
using osu.Game.Audio;
2017-03-17 12:56:14 +08:00
namespace osu.Game.Modes.Taiko.Objects
{
2017-04-05 12:52:53 +08:00
public class DrumRoll : TaikoHitObject, IHasEndTime
2017-03-17 12:56:14 +08:00
{
/// <summary>
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
/// </summary>
private const float base_distance = 100;
2017-04-05 12:52:53 +08:00
public double EndTime => StartTime + Duration;
2017-03-17 12:56:14 +08:00
2017-04-05 12:52:53 +08:00
public double Duration { get; set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Numer of ticks per beat length.
2017-03-17 12:56:14 +08:00
/// </summary>
public int TickRate = 1;
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Good" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGoodHits { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Great" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGreatHits { get; protected set; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Total number of drum roll ticks.
/// </summary>
2017-03-22 00:33:22 +08:00
public int TotalTicks => Ticks.Count();
2017-03-17 12:56:14 +08:00
/// <summary>
/// Initializes the drum roll ticks if not initialized and returns them.
/// </summary>
2017-03-22 00:33:22 +08:00
public IEnumerable<DrumRollTick> Ticks => ticks ?? (ticks = createTicks());
2017-03-17 12:56:14 +08:00
private List<DrumRollTick> ticks;
/// <summary>
/// The length (in milliseconds) between ticks of this drumroll.
/// <para>Half of this value is the hit window of the ticks.</para>
/// </summary>
private double tickSpacing = 100;
2017-03-17 12:56:14 +08:00
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
base.ApplyDefaults(timing, difficulty);
tickSpacing = timing.BeatLengthAt(StartTime) / TickRate;
2017-03-17 12:56:14 +08:00
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
}
2017-03-22 00:33:22 +08:00
private List<DrumRollTick> createTicks()
2017-03-17 12:56:14 +08:00
{
2017-03-22 00:33:22 +08:00
var ret = new List<DrumRollTick>();
2017-03-17 12:56:14 +08:00
if (tickSpacing == 0)
2017-03-22 00:33:22 +08:00
return ret;
2017-03-17 12:56:14 +08:00
bool first = true;
2017-04-05 12:52:22 +08:00
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
2017-03-17 12:56:14 +08:00
{
2017-03-22 00:33:22 +08:00
ret.Add(new DrumRollTick
2017-03-17 12:56:14 +08:00
{
FirstTick = first,
ScrollTime = ScrollTime,
TickSpacing = tickSpacing,
2017-03-17 12:56:14 +08:00
StartTime = t,
2017-03-28 15:47:25 +08:00
IsStrong = IsStrong,
Samples = Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
Volume = s.Volume
}).ToList()
2017-03-17 12:56:14 +08:00
});
first = false;
}
2017-03-22 00:33:22 +08:00
return ret;
2017-03-17 12:56:14 +08:00
}
}
}