2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-18 11:48:33 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-12-01 14:08:12 +08:00
|
|
|
|
using System;
|
2017-11-28 20:22:57 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-12-01 19:39:58 +08:00
|
|
|
|
using System.Linq;
|
2017-09-18 11:48:33 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-09-15 19:54:34 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
2017-12-01 14:08:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
using OpenTK;
|
2017-09-15 19:54:34 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Beatmaps
|
|
|
|
|
{
|
2018-01-10 14:37:55 +08:00
|
|
|
|
public class CatchBeatmapProcessor : BeatmapProcessor<CatchHitObject>
|
2017-09-15 19:54:34 +08:00
|
|
|
|
{
|
2017-11-28 17:37:41 +08:00
|
|
|
|
public override void PostProcess(Beatmap<CatchHitObject> beatmap)
|
2017-09-15 19:54:34 +08:00
|
|
|
|
{
|
|
|
|
|
if (beatmap.ComboColors.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-01-03 15:31:57 +08:00
|
|
|
|
int index = 0;
|
2017-09-15 19:54:34 +08:00
|
|
|
|
int colourIndex = 0;
|
|
|
|
|
|
2017-11-28 17:37:41 +08:00
|
|
|
|
CatchHitObject lastObj = null;
|
2017-09-15 19:54:34 +08:00
|
|
|
|
|
2017-12-01 19:39:58 +08:00
|
|
|
|
initialiseHyperDash(beatmap.HitObjects);
|
2017-11-28 20:22:57 +08:00
|
|
|
|
|
2017-09-15 19:54:34 +08:00
|
|
|
|
foreach (var obj in beatmap.HitObjects)
|
|
|
|
|
{
|
|
|
|
|
if (obj.NewCombo)
|
|
|
|
|
{
|
|
|
|
|
if (lastObj != null) lastObj.LastInCombo = true;
|
|
|
|
|
colourIndex = (colourIndex + 1) % beatmap.ComboColors.Count;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-03 15:31:57 +08:00
|
|
|
|
obj.IndexInBeatmap = index++;
|
2017-09-15 19:54:34 +08:00
|
|
|
|
obj.ComboColour = beatmap.ComboColors[colourIndex];
|
|
|
|
|
|
|
|
|
|
lastObj = obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-28 20:22:57 +08:00
|
|
|
|
|
2017-12-01 19:39:58 +08:00
|
|
|
|
private void initialiseHyperDash(List<CatchHitObject> objects)
|
2017-11-28 20:22:57 +08:00
|
|
|
|
{
|
2017-12-01 14:08:12 +08:00
|
|
|
|
// todo: add difficulty adjust.
|
2017-12-01 19:39:58 +08:00
|
|
|
|
double halfCatcherWidth = CatcherArea.CATCHER_SIZE * (objects.FirstOrDefault()?.Scale ?? 1) / CatchPlayfield.BASE_WIDTH / 2;
|
2017-11-28 20:22:57 +08:00
|
|
|
|
|
2017-12-01 14:08:12 +08:00
|
|
|
|
int lastDirection = 0;
|
2017-12-01 19:39:58 +08:00
|
|
|
|
double lastExcess = halfCatcherWidth;
|
2017-12-01 14:08:12 +08:00
|
|
|
|
|
|
|
|
|
int objCount = objects.Count;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < objCount - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
CatchHitObject currentObject = objects[i];
|
|
|
|
|
|
|
|
|
|
// not needed?
|
2017-12-01 19:39:58 +08:00
|
|
|
|
// if (currentObject is TinyDroplet) continue;
|
2017-12-01 14:08:12 +08:00
|
|
|
|
|
|
|
|
|
CatchHitObject nextObject = objects[i + 1];
|
2017-12-01 19:39:58 +08:00
|
|
|
|
|
|
|
|
|
// while (nextObject is TinyDroplet)
|
|
|
|
|
// {
|
|
|
|
|
// if (++i == objCount - 1) break;
|
|
|
|
|
// nextObject = objects[i + 1];
|
|
|
|
|
// }
|
2017-12-01 14:08:12 +08:00
|
|
|
|
|
|
|
|
|
int thisDirection = nextObject.X > currentObject.X ? 1 : -1;
|
|
|
|
|
double timeToNext = nextObject.StartTime - ((currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime) - 4;
|
2017-12-01 19:39:58 +08:00
|
|
|
|
double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth);
|
2017-12-01 14:08:12 +08:00
|
|
|
|
|
|
|
|
|
if (timeToNext * CatcherArea.Catcher.BASE_SPEED < distanceToNext)
|
|
|
|
|
{
|
2017-12-01 18:24:48 +08:00
|
|
|
|
currentObject.HyperDashTarget = nextObject;
|
2017-12-01 19:39:58 +08:00
|
|
|
|
lastExcess = halfCatcherWidth;
|
2017-12-01 14:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//currentObject.DistanceToHyperDash = timeToNext - distanceToNext;
|
2017-12-01 19:39:58 +08:00
|
|
|
|
lastExcess = MathHelper.Clamp(timeToNext - distanceToNext, 0, halfCatcherWidth);
|
2017-12-01 14:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastDirection = thisDirection;
|
|
|
|
|
}
|
2017-11-28 20:22:57 +08:00
|
|
|
|
}
|
2017-09-15 19:54:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|