osu/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs

60 lines
1.9 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 09:19:50 +00:00
using System.Collections.Generic;
2018-04-13 09:19:50 +00:00
using osu.Game.Beatmaps;
2018-11-28 08:20:37 +00:00
using osu.Game.Replays.Legacy;
2018-04-13 09:19:50 +00:00
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
namespace osu.Game.Rulesets.Catch.Replays
{
public class CatchReplayFrame : ReplayFrame, IConvertibleReplayFrame
{
public List<CatchAction> Actions = new List<CatchAction>();
2018-04-13 09:19:50 +00:00
public float Position;
public bool Dashing;
public CatchReplayFrame()
{
}
public CatchReplayFrame(double time, float? position = null, bool dashing = false, CatchReplayFrame lastFrame = null)
2018-04-13 09:19:50 +00:00
: base(time)
{
Position = position ?? -1;
Dashing = dashing;
if (Dashing)
Actions.Add(CatchAction.Dash);
if (lastFrame != null)
{
if (Position > lastFrame.Position)
Actions.Add(CatchAction.MoveRight);
else if (Position < lastFrame.Position)
Actions.Add(CatchAction.MoveLeft);
}
2018-04-13 09:19:50 +00:00
}
public void ConvertFrom(LegacyReplayFrame currentFrame, IBeatmap beatmap, LegacyReplayFrame lastFrame = null)
2018-04-13 09:19:50 +00:00
{
Position = currentFrame.Position.X / CatchPlayfield.BASE_WIDTH;
Dashing = currentFrame.ButtonState == ReplayButtonState.Left1;
if (Dashing)
Actions.Add(CatchAction.Dash);
if (lastFrame != null)
{
if (currentFrame.Position.X > lastFrame.Position.X)
Actions.Add(CatchAction.MoveRight);
else if (currentFrame.Position.X < lastFrame.Position.X)
Actions.Add(CatchAction.MoveLeft);
}
2018-04-13 09:19:50 +00:00
}
}
}