1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 22:22:55 +08:00

Merge branch 'taiko_replays' into taiko-drawable-generation

Conflicts:
	osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj
This commit is contained in:
smoogipooo 2017-03-29 11:17:55 +09:00
commit 6333cd5225
10 changed files with 233 additions and 3 deletions

View File

@ -44,7 +44,10 @@ namespace osu.Game.Modes.Taiko.Beatmaps
IHasRepeats repeatsData = original as IHasRepeats;
IHasEndTime endTimeData = original as IHasEndTime;
bool strong = ((original.Sample?.Type ?? SampleType.None) & SampleType.Finish) > 0;
// Old osu! used hit sounding to determine various hit type information
SampleType sample = original.Sample?.Type ?? SampleType.None;
bool strong = (sample & SampleType.Finish) > 0;
if (distanceData != null)
{
@ -71,11 +74,14 @@ namespace osu.Game.Modes.Taiko.Beatmaps
};
}
HitType type = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0 ? HitType.Centre : HitType.Rim;
return new Hit
{
StartTime = original.StartTime,
Sample = original.Sample,
IsStrong = strong
IsStrong = strong,
Type = type
};
}
}

View File

@ -0,0 +1,47 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.IO;
using osu.Framework.Input;
using osu.Game.Input.Handlers;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko
{
public class LegacyTaikoReplay : LegacyReplay
{
protected LegacyTaikoReplay()
{
}
public LegacyTaikoReplay(StreamReader reader)
: base(reader)
{
}
public override ReplayInputHandler CreateInputHandler() => new LegacyTaikoReplayInputHandler(Frames);
private class LegacyTaikoReplayInputHandler : LegacyReplayInputHandler
{
public LegacyTaikoReplayInputHandler(List<LegacyReplayFrame> replayContent)
: base(replayContent)
{
}
public override List<InputState> GetPendingStates() => new List<InputState>
{
new InputState
{
Keyboard = new ReplayKeyboardState(new List<Key>(new[]
{
CurrentFrame?.MouseRight1 == true ? Key.F : Key.Unknown,
CurrentFrame?.MouseRight2 == true ? Key.J : Key.Unknown,
CurrentFrame?.MouseLeft1 == true ? Key.D : Key.Unknown,
CurrentFrame?.MouseLeft2 == true ? Key.K : Key.Unknown
}))
}
};
}
}
}

View File

@ -1,7 +1,10 @@
// 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.Beatmaps;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Scoring;
using osu.Game.Modes.Taiko.Objects;
namespace osu.Game.Modes.Taiko.Mods
{
@ -61,4 +64,12 @@ namespace osu.Game.Modes.Taiko.Mods
{
}
public class TaikoModAutoplay : ModAutoplay<TaikoHitObject>
{
protected override Score CreateReplayScore(Beatmap<TaikoHitObject> beatmap) => new Score
{
Replay = new TaikoAutoReplay(beatmap)
};
}
}

View File

@ -8,6 +8,11 @@ namespace osu.Game.Modes.Taiko.Objects
{
public class Hit : TaikoHitObject
{
/// <summary>
/// Whether this hit is a centre-hit or a rim-hit.
/// </summary>
public HitType Type;
/// <summary>
/// The hit window that results in a "GREAT" hit.
/// </summary>

View File

@ -0,0 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Modes.Taiko.Objects
{
/// <summary>
/// Describes whether a hit is a centre-hit or a rim-hit.
/// </summary>
public enum HitType
{
Centre,
Rim
}
}

View File

@ -119,6 +119,15 @@ namespace osu.Game.Modes.Taiko.Scoring
{
}
public override Score CreateScore() => new TaikoScore
{
TotalScore = TotalScore,
Combo = Combo,
MaxCombo = HighestCombo,
Accuracy = Accuracy,
Health = Health,
};
protected override void ComputeTargets(Beatmap<TaikoHitObject> beatmap)
{
double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.DrainRate, 0.5, 0.75, 0.98));

View File

@ -0,0 +1,121 @@
// 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.Taiko.Objects;
using osu.Game.Modes.Objects.Types;
using osu.Game.Beatmaps;
namespace osu.Game.Modes.Taiko
{
public class TaikoAutoReplay : LegacyTaikoReplay
{
private readonly Beatmap<TaikoHitObject> beatmap;
public TaikoAutoReplay(Beatmap<TaikoHitObject> beatmap)
{
this.beatmap = beatmap;
createAutoReplay();
}
private void createAutoReplay()
{
bool hitButton = true;
Frames.Add(new LegacyReplayFrame(-100000, 320, 240, LegacyButtonState.None));
Frames.Add(new LegacyReplayFrame(beatmap.HitObjects[0].StartTime - 1000, 320, 240, LegacyButtonState.None));
for (int i = 0; i < beatmap.HitObjects.Count; i++)
{
TaikoHitObject h = beatmap.HitObjects[i];
LegacyButtonState button;
IHasEndTime endTimeData = h as IHasEndTime;
double endTime = endTimeData?.EndTime ?? h.StartTime;
Swell sp = h as Swell;
if (sp != null)
{
int d = 0;
int count = 0;
int req = sp.RequiredHits;
double hitRate = sp.Duration / req;
for (double j = h.StartTime; j < endTime; j += hitRate)
{
switch (d)
{
default:
button = LegacyButtonState.Left1;
break;
case 1:
button = LegacyButtonState.Right1;
break;
case 2:
button = LegacyButtonState.Left2;
break;
case 3:
button = LegacyButtonState.Right2;
break;
}
Frames.Add(new LegacyReplayFrame(j, 0, 0, button));
d = (d + 1) % 4;
if (++count > req)
break;
}
}
else if (h is DrumRoll)
{
DrumRoll d = h as DrumRoll;
double delay = d.TickTimeDistance;
double time = d.StartTime;
for (int j = 0; j < d.TotalTicks; j++)
{
Frames.Add(new LegacyReplayFrame((int)time, 0, 0, hitButton ? LegacyButtonState.Left1 : LegacyButtonState.Left2));
time += delay;
hitButton = !hitButton;
}
}
else
{
Hit hit = h as Hit;
if (hit.Type == HitType.Centre)
{
if (h.IsStrong)
button = LegacyButtonState.Right1 | LegacyButtonState.Right2;
else
button = hitButton ? LegacyButtonState.Right1 : LegacyButtonState.Right2;
}
else
{
if (h.IsStrong)
button = LegacyButtonState.Left1 | LegacyButtonState.Left2;
else
button = hitButton ? LegacyButtonState.Left1 : LegacyButtonState.Left2;
}
Frames.Add(new LegacyReplayFrame(h.StartTime, 0, 0, button));
}
Frames.Add(new LegacyReplayFrame(endTime + 1, 0, 0, LegacyButtonState.None));
if (i < beatmap.HitObjects.Count - 1)
{
double waitTime = beatmap.HitObjects[i + 1].StartTime - 1000;
if (waitTime > endTime)
Frames.Add(new LegacyReplayFrame(waitTime, 0, 0, LegacyButtonState.None));
}
hitButton = !hitButton;
}
//Player.currentScore.Replay = InputManager.ReplayScore.Replay;
//Player.currentScore.PlayerName = "mekkadosu!";
}
}
}

View File

@ -65,7 +65,7 @@ namespace osu.Game.Modes.Taiko
{
Mods = new Mod[]
{
new ModAutoplay(),
new TaikoModAutoplay(),
new ModCinema(),
},
},

View File

@ -0,0 +1,13 @@
// 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.Scoring;
using System.IO;
namespace osu.Game.Modes.Taiko
{
public class TaikoScore : Score
{
public override Replay CreateLegacyReplayFrom(StreamReader reader) => new LegacyTaikoReplay(reader);
}
}

View File

@ -52,6 +52,7 @@
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
<Compile Include="Judgements\TaikoJudgement.cs" />
<Compile Include="Judgements\TaikoHitResult.cs" />
<Compile Include="LegacyTaikoReplay.cs" />
<Compile Include="Objects\Drawable\DrawableRimHit.cs" />
<Compile Include="Objects\Drawable\DrawableStrongRimHit.cs" />
<Compile Include="Objects\Drawable\Pieces\CentreHitCirclePiece.cs" />
@ -72,11 +73,14 @@
<Compile Include="Objects\DrumRoll.cs" />
<Compile Include="Objects\DrumRollTick.cs" />
<Compile Include="Objects\Hit.cs" />
<Compile Include="Objects\HitType.cs" />
<Compile Include="Objects\Swell.cs" />
<Compile Include="TaikoAutoReplay.cs" />
<Compile Include="Objects\TaikoHitObject.cs" />
<Compile Include="TaikoDifficultyCalculator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scoring\TaikoScoreProcessor.cs" />
<Compile Include="TaikoScore.cs" />
<Compile Include="UI\HitTarget.cs" />
<Compile Include="UI\InputDrum.cs" />
<Compile Include="UI\DrawableTaikoJudgement.cs" />