//Each hitobject marked as a "DC" means that it requires a directional change to catch public int[] GetDirectionalChangeTimes() { double circlesize = Double.Parse(map.GetTag("Difficulty", "CircleSize"), CultureInfo.InvariantCulture); CatcherInfo catcher = new CatcherInfo(circlesize); List <int> DCtimes = new List <int>(); Direction prevnotedir = catcher.CurDirection; for (int i = 1; i < hitpositions.Length; i++) { if (hitpositions[i] == hitpositions[i - 1]) { continue; } Direction notedirection; if (hitpositions[i] - hitpositions[i - 1] > 0) { notedirection = Direction.Right; } else { notedirection = Direction.Left; } bool isprevhyper; if (i > 1 && hittimes[i - 1] != hittimes[i - 2]) { isprevhyper = catcher.PercentHyper(Math.Abs(hitpositions[i - 1] - hitpositions[i - 2]), hittimes[i - 1] - hittimes[i - 2]) > 1; } else { isprevhyper = false; } int distance = Math.Abs(hitpositions[i] - hitpositions[i - 1]); double checkedsize = catcher.CatcherSize; if (isprevhyper) { checkedsize /= 2; } if (notedirection != catcher.CurDirection && (distance > checkedsize || notedirection == prevnotedir)) { catcher.CurDirection = notedirection; DCtimes.Add(hittimes[i]); } prevnotedir = catcher.CurDirection; } return(DCtimes.ToArray()); }
private double CalculateNonmovementDifficulty(int index, CatcherInfo catcher, double difficulty) { //Check if the last three notes can be caught without moving //Prevents unnecessary checking if (index > 2 && Math.Max(Math.Max(positions[index], positions[index - 1]), positions[index - 2]) - Math.Min(Math.Min(positions[index], positions[index - 1]), positions[index - 2]) < catcher.CatcherSize) { //the distance the catcher moves, scaled as a percentage of how close the jump is to requiring movement double totalpercentdistance = 0; //index locating what note is the last note not needing movement to catch int nonmovementindex; //Makes sure that the notes aren't all in a straight line int leftmost = Math.Max(positions[index], positions[index - 1]); int rightmost = Math.Min(positions[index], positions[index - 1]); //used to make sure we only get at most 10 notes int nonmovecount = 0; int DCcount = 0; List <int> nonmoveDCtimes = new List <int>(); Direction curdir; if (positions[index] - positions[index - 1] > 0) { curdir = Direction.Right; } else if (positions[index] - positions[index - 1] < 0) { curdir = Direction.Left; } else { curdir = Direction.Stop; } Direction prevdir = curdir; //while it's still a nonmovement jump for (nonmovementindex = index; nonmovementindex > 0 && nonmovecount < 10; nonmovementindex--) { if (positions[nonmovementindex] > leftmost) { leftmost = positions[nonmovementindex]; } else if (positions[nonmovementindex] < rightmost) { rightmost = positions[nonmovementindex]; } if (positions[nonmovementindex] - positions[nonmovementindex - 1] > 0) { curdir = Direction.Right; } else if (positions[nonmovementindex] - positions[nonmovementindex - 1] < 0) { curdir = Direction.Left; } if (leftmost - rightmost > catcher.CatcherSize) { break; } if (positions[nonmovementindex] - positions[nonmovementindex - 1] > catcher.CatcherSize) { break; } if (curdir != prevdir) { DCcount++; nonmoveDCtimes.Add(times[nonmovecount]); } prevdir = curdir; totalpercentdistance += Math.Abs(positions[nonmovementindex] - positions[nonmovementindex - 1]) / (double)catcher.CatcherSize; nonmovecount++; } //Get the sum of the time between DC's in the nonmovement section double nonmoveDCsum = 0; for (int i = 1; i < nonmoveDCtimes.Count; i++) { nonmoveDCsum += nonmoveDCtimes[i] - nonmoveDCtimes[i - 1]; } double pendingdiff; if (nonmoveDCsum == 0) { pendingdiff = 0; } else { pendingdiff = 110 * Math.Pow(DCcount / nonmoveDCsum, 0.72) * (Math.Pow(totalpercentdistance, 5) / (Math.Pow(10, 5) / 10)); } difficulty = Math.Max(pendingdiff, difficulty); } return(difficulty); }