public override float GetNoteX(RuntimeNote note, double now, NoteMetrics noteMetrics, NoteAnimationMetrics animationMetrics) { var trackCount = animationMetrics.TrackCount; var trackXRatioStart = animationMetrics.NoteEndXRatios[0]; var trackXRatioEnd = animationMetrics.NoteEndXRatios[trackCount - 1]; var endXRatio = trackXRatioStart + (trackXRatioEnd - trackXRatioStart) * (note.EndX / (trackCount - 1)); var onStage = NoteAnimationHelper.GetOnStageStatusOf(note, now, animationMetrics); float xRatio; switch (onStage) { case OnStageStatus.Incoming: if (note.HasPrevHold()) { xRatio = GetIncomingNoteXRatio(note.PrevHold, note, now, noteMetrics, animationMetrics); } else if (note.HasPrevSlide()) { xRatio = GetIncomingNoteXRatio(note.PrevSlide, note, now, noteMetrics, animationMetrics); } else { xRatio = endXRatio; } break; case OnStageStatus.Passed when note.HasNextSlide(): var destXRatio = trackXRatioStart + (trackXRatioEnd - trackXRatioStart) * (note.NextSlide.EndX / (trackCount - 1)); var nextPerc = (float)(now - note.HitTime) / (float)(note.NextSlide.HitTime - note.HitTime); xRatio = MathHelper.Lerp(endXRatio, destXRatio, nextPerc); break; default: xRatio = endXRatio; break; } return(animationMetrics.Width * xRatio); }
public override float GetNoteX(RuntimeNote note, float now, NoteMetrics noteMetrics, NoteAnimationMetrics animationMetrics) { var trackCount = animationMetrics.TrackCount; var endLeftMarginRatio = animationMetrics.NoteEndXRatios[0]; var endRightMarginRatio = animationMetrics.NoteEndXRatios[trackCount - 1]; var endXRatio = endLeftMarginRatio + (endRightMarginRatio - endLeftMarginRatio) * (note.EndX / (trackCount - 1)); var onStage = NoteAnimationHelper.GetOnStageStatusOf(note, now, animationMetrics); float xRatio; switch (onStage) { case OnStageStatus.Incoming: if (note.HasPrevHold()) { xRatio = GetIncomingNoteXRatio(note.PrevHold, note, now, animationMetrics); } else if (note.HasPrevSlide()) { xRatio = GetIncomingNoteXRatio(note.PrevSlide, note, now, animationMetrics); } else { xRatio = endXRatio; } break; case OnStageStatus.Passed: if (note.HasNextSlide()) { var destXRatio = endLeftMarginRatio + (endRightMarginRatio - endLeftMarginRatio) * (note.NextSlide.EndX / (trackCount - 1)); var nextPerc = (now - note.HitTime) / (note.NextSlide.HitTime - note.HitTime); xRatio = MathHelperEx.Lerp(endXRatio, destXRatio, nextPerc); } else { xRatio = endXRatio; } break; default: var startLeftMarginRatio = animationMetrics.NoteStartXRatios[0]; var startRightMarginRatio = animationMetrics.NoteStartXRatios[trackCount - 1]; float whichStartToTake; if (note.IsSlide()) { whichStartToTake = note.EndX; } else { if (note.StartX < 0) { whichStartToTake = note.StartX * 0.5f; } else if (note.StartX > trackCount - 1) { whichStartToTake = (trackCount - 1) + (note.StartX - (trackCount - 1)) * 0.5f; } else { whichStartToTake = note.StartX; } } var startXRatio = startLeftMarginRatio + (startRightMarginRatio - startLeftMarginRatio) * (whichStartToTake / (trackCount - 1)); var timePoints = NoteAnimationHelper.CalculateNoteTimePoints(note, animationMetrics); var perc = (now - timePoints.Enter) / timePoints.Duration; xRatio = MathHelperEx.Lerp(startXRatio, endXRatio, perc); break; } return(animationMetrics.Width * xRatio); }