2018-04-13 17:19:50 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-04-18 15:46:02 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-04-18 15:46:02 +08:00
|
|
|
|
using System;
|
2018-04-19 21:04:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Mods
|
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public class CatchModHardRock : ModHardRock, IApplicableToHitObject
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public override double ScoreMultiplier => 1.12;
|
|
|
|
|
public override bool Ranked => true;
|
2018-04-18 15:46:02 +08:00
|
|
|
|
|
|
|
|
|
private float lastStartX;
|
|
|
|
|
private int lastStartTime;
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public void ApplyToHitObject(HitObject hitObject)
|
2018-04-18 15:46:02 +08:00
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
var catchObject = (CatchHitObject)hitObject;
|
|
|
|
|
|
|
|
|
|
float position = catchObject.X;
|
2018-04-18 15:46:02 +08:00
|
|
|
|
int startTime = (int)hitObject.StartTime;
|
|
|
|
|
|
|
|
|
|
if (lastStartX == 0)
|
|
|
|
|
{
|
|
|
|
|
lastStartX = position;
|
|
|
|
|
lastStartTime = startTime;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float diff = lastStartX - position;
|
|
|
|
|
int timeDiff = startTime - lastStartTime;
|
|
|
|
|
|
|
|
|
|
if (timeDiff > 1000)
|
|
|
|
|
{
|
|
|
|
|
lastStartX = position;
|
|
|
|
|
lastStartTime = startTime;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (diff == 0)
|
|
|
|
|
{
|
|
|
|
|
bool right = RNG.NextBool();
|
|
|
|
|
|
|
|
|
|
float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4d)) / CatchPlayfield.BASE_WIDTH;
|
|
|
|
|
|
|
|
|
|
if (right)
|
|
|
|
|
{
|
|
|
|
|
if (position + rand <= 1)
|
|
|
|
|
position += rand;
|
|
|
|
|
else
|
|
|
|
|
position -= rand;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (position - rand >= 0)
|
|
|
|
|
position -= rand;
|
|
|
|
|
else
|
|
|
|
|
position += rand;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
catchObject.X = position;
|
2018-04-18 15:46:02 +08:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Math.Abs(diff) < timeDiff / 3d)
|
|
|
|
|
{
|
|
|
|
|
if (diff > 0)
|
|
|
|
|
{
|
|
|
|
|
if (position - diff > 0)
|
|
|
|
|
position -= diff;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (position - diff < 1)
|
|
|
|
|
position -= diff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
catchObject.X = position;
|
2018-04-18 15:46:02 +08:00
|
|
|
|
|
|
|
|
|
lastStartX = position;
|
|
|
|
|
lastStartTime = startTime;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|