Initial implementation of hyperdash calculation

This commit is contained in:
Dean Herbert
2017-12-01 15:08:12 +09:00
parent 76a1c7db3b
commit 881745d756
5 changed files with 87 additions and 27 deletions

View File

@ -1,9 +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 System;
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects.Types;
using OpenTK;
namespace osu.Game.Rulesets.Catch.Beatmaps
{
@ -40,7 +44,46 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
private void convertHyperDash(List<CatchHitObject> objects)
{
// todo: add difficulty adjust.
const double catcher_width = CatcherArea.CATCHER_SIZE / CatchPlayfield.BASE_WIDTH;
const double catcher_width_half = catcher_width / 2;
int lastDirection = 0;
double lastExcess = catcher_width_half;
int objCount = objects.Count;
for (int i = 0; i < objCount - 1; i++)
{
CatchHitObject currentObject = objects[i];
// not needed?
if (currentObject is TinyDroplet) continue;
CatchHitObject nextObject = objects[i + 1];
while (nextObject is TinyDroplet)
{
if (++i == objCount - 1) break;
nextObject = objects[i + 1];
}
int thisDirection = nextObject.X > currentObject.X ? 1 : -1;
double timeToNext = nextObject.StartTime - ((currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime) - 4;
double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : catcher_width_half);
if (timeToNext * CatcherArea.Catcher.BASE_SPEED < distanceToNext)
{
currentObject.HyperDash = true;
lastExcess = catcher_width_half;
}
else
{
//currentObject.DistanceToHyperDash = timeToNext - distanceToNext;
lastExcess = MathHelper.Clamp(timeToNext - distanceToNext, 0, catcher_width_half);
}
lastDirection = thisDirection;
}
}
}
}