public bool CheckHit(Note note) { if (note.Motion == Motion.NotSet) { return(false); } if (note.Motion == Motion.Up && double.IsNaN(JumpBeat)) { return(false); // We can't check an UP against no jump } else if (note.Motion == Motion.Down && double.IsNaN(DownBeat)) { return(false); // We can't check a DOWN against no down } float diffMS = -999.0f; var beatCheck = note.Motion == Motion.Up ? JumpBeat : DownBeat; //diffMS = (float)(((note.BeatLocation - beatCheck) * 60 / Globals.CurrentBpm)); diffMS = (float)(Globals.GetSecAtBeat(note.BeatLocation) - Globals.GetSecAtBeat(beatCheck)); if (diffMS > MotionTiming.EarlyPerfect) // Too soon to hit { return(false); } // All other are valid note.HitResult.WasHit = true; note.HitResult.Difference = diffMS; return(true); }
public static bool CheckHit(Note note) { var noteMin = Globals.CalcTransX(note, Side.Left); var noteMax = Globals.CalcTransX(note, Side.Right); float diffMS = float.MaxValue; if (note.Type != NoteType.Shuffle) { var validPoints = Points.Where(x => x.Value.Valid && x.Value.MinX <noteMax && x.Value.MaxX> noteMin).ToList(); if (validPoints.Count == 0) { return(false); // No need to modify hit result-- defaults to false } validPoints.Sort((x, y) => Math.Abs(x.Value.Beat - note.BeatLocation).CompareTo(Math.Abs(y.Value.Beat - note.BeatLocation))); // Use the closest point and get the time difference //float diffMS = (float)(((note.BeatLocation - validPoints.First().Beat) * 60 / Globals.CurrentBpm)); diffMS = (float)(Globals.GetSecAtBeat(note.BeatLocation) - Globals.GetSecAtBeat(validPoints.First().Value.Beat)); if (diffMS > NoteTiming.Bad) // Too soon to hit, just leave { return(false); } // All other times are valid note.HitResult.WasHit = true; note.HitResult.Difference = diffMS; } else { var validPoints = Points.Where(x => x.Value.Valid && (float)(Globals.GetSecAtBeat(note.BeatLocation) - Globals.GetSecAtBeat(x.Value.UpdateBeat)) < NoteTiming.Shuffle && x.Value.VelX >= NoteTiming.ShuffleVelocityThreshold).ToList(); if (validPoints.Count == 0) { return(false); // No need to modify hit result-- defaults to false } // If any points exist, then we're fine note.HitResult.WasHit = true; note.HitResult.Difference = diffMS; } return(true); }