-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #568 from smoogipooo/taiko_replays
Taiko replays
- Loading branch information
Showing
9 changed files
with
217 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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 | ||
{ | ||
public class CentreHit : Hit | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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 | ||
{ | ||
public class RimHit : Hit | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 System; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Modes.Objects.Types; | ||
using osu.Game.Modes.Taiko.Objects; | ||
using osu.Game.Modes.Replays; | ||
|
||
namespace osu.Game.Modes.Taiko.Replays | ||
{ | ||
public class TaikoAutoReplay : Replay | ||
{ | ||
private readonly Beatmap<TaikoHitObject> beatmap; | ||
|
||
public TaikoAutoReplay(Beatmap<TaikoHitObject> beatmap) | ||
{ | ||
this.beatmap = beatmap; | ||
|
||
createAutoReplay(); | ||
} | ||
|
||
private void createAutoReplay() | ||
{ | ||
bool hitButton = true; | ||
|
||
Frames.Add(new ReplayFrame(-100000, 320, 240, ReplayButtonState.None)); | ||
Frames.Add(new ReplayFrame(beatmap.HitObjects[0].StartTime - 1000, 320, 240, ReplayButtonState.None)); | ||
|
||
for (int i = 0; i < beatmap.HitObjects.Count; i++) | ||
{ | ||
TaikoHitObject h = beatmap.HitObjects[i]; | ||
|
||
ReplayButtonState button; | ||
|
||
IHasEndTime endTimeData = h as IHasEndTime; | ||
double endTime = endTimeData?.EndTime ?? h.StartTime; | ||
|
||
Swell swell = h as Swell; | ||
DrumRoll drumRoll = h as DrumRoll; | ||
Hit hit = h as Hit; | ||
|
||
if (swell != null) | ||
{ | ||
int d = 0; | ||
int count = 0; | ||
int req = swell.RequiredHits; | ||
double hitRate = swell.Duration / req; | ||
for (double j = h.StartTime; j < endTime; j += hitRate) | ||
{ | ||
switch (d) | ||
{ | ||
default: | ||
button = ReplayButtonState.Left1; | ||
break; | ||
case 1: | ||
button = ReplayButtonState.Right1; | ||
break; | ||
case 2: | ||
button = ReplayButtonState.Left2; | ||
break; | ||
case 3: | ||
button = ReplayButtonState.Right2; | ||
break; | ||
} | ||
|
||
Frames.Add(new ReplayFrame(j, 0, 0, button)); | ||
d = (d + 1) % 4; | ||
if (++count > req) | ||
break; | ||
} | ||
} | ||
else if (drumRoll != null) | ||
{ | ||
double delay = drumRoll.TickTimeDistance; | ||
|
||
double time = drumRoll.StartTime; | ||
|
||
for (int j = 0; j < drumRoll.TotalTicks; j++) | ||
{ | ||
Frames.Add(new ReplayFrame((int)time, 0, 0, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2)); | ||
time += delay; | ||
hitButton = !hitButton; | ||
} | ||
} | ||
else if (hit != null) | ||
{ | ||
if (hit is CentreHit) | ||
{ | ||
if (h.IsStrong) | ||
button = ReplayButtonState.Right1 | ReplayButtonState.Right2; | ||
else | ||
button = hitButton ? ReplayButtonState.Right1 : ReplayButtonState.Right2; | ||
} | ||
else | ||
{ | ||
if (h.IsStrong) | ||
button = ReplayButtonState.Left1 | ReplayButtonState.Left2; | ||
else | ||
button = hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2; | ||
} | ||
|
||
Frames.Add(new ReplayFrame(h.StartTime, 0, 0, button)); | ||
} | ||
else | ||
throw new Exception("Unknown hit object type."); | ||
|
||
Frames.Add(new ReplayFrame(endTime + 1, 0, 0, ReplayButtonState.None)); | ||
|
||
if (i < beatmap.HitObjects.Count - 1) | ||
{ | ||
double waitTime = beatmap.HitObjects[i + 1].StartTime - 1000; | ||
if (waitTime > endTime) | ||
Frames.Add(new ReplayFrame(waitTime, 0, 0, ReplayButtonState.None)); | ||
} | ||
|
||
hitButton = !hitButton; | ||
} | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
osu.Game.Modes.Taiko/Replays/TaikoFramedReplayInputHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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.Replays; | ||
using System.Collections.Generic; | ||
using osu.Framework.Input; | ||
using OpenTK.Input; | ||
|
||
namespace osu.Game.Modes.Taiko.Replays | ||
{ | ||
internal class TaikoFramedReplayInputHandler : FramedReplayInputHandler | ||
{ | ||
public TaikoFramedReplayInputHandler(Replay replay) | ||
: base(replay) | ||
{ | ||
} | ||
|
||
public override List<InputState> GetPendingStates() | ||
{ | ||
var keys = new List<Key>(); | ||
|
||
if (CurrentFrame?.MouseRight1 == true) | ||
keys.Add(Key.F); | ||
if (CurrentFrame?.MouseRight2 == true) | ||
keys.Add(Key.J); | ||
if (CurrentFrame?.MouseLeft1 == true) | ||
keys.Add(Key.D); | ||
if (CurrentFrame?.MouseLeft2 == true) | ||
keys.Add(Key.K); | ||
|
||
return new List<InputState> | ||
{ | ||
new InputState { Keyboard = new ReplayKeyboardState(keys) } | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters