MouseDance MouseDance
MouseDance MouseDance
MouseDance User Docs powered by DocFx, DiscordFx

Search Results for

    Customizing Scoring

    By default, MouseDance is doing only a simple score * combo counter * difficulty formula for scoring. If you want to change it, the proper way to do this is to implement IBeatmapScoreCalculator:

    Warning

    MouseDance has no HP Drain functionality yet, so it can't take that into account in the scoring formula for now (check the Roadmap and Release Notes for updates to this). It also has no Game modifiers yet, so that is also not included in the score formula. As it is, it can't exactly do the same scoring formulae in Osu!.

    public class BasicUsage : UnityEngine.MonoBehaviour, MouseDance.Runtime.Callbacks.IBeatmapScoreCalculator
    {
      public MouseDance.Runtime.BeatmapRunner _beatmapRunner;
      public UnityEngine.TextAsset _osuFile;
      public UnityEngine.AudioClip _song;
      
      void Start()
      {
        _beatmapRunner.SetScoreCalculator(this);
        _beatmapRunner.LoadAndStart(_osuFile, _song);
      }
      
      public int CalculateScore(MouseDance.Runtime.IHitObject hitCircle, int gotHitCircleValue, OsuParsers.Beatmaps.Beatmap beatmap)
      {
        int difficultyModifier = Mathf.RoundToInt((beatmap.DifficultySection.CircleSize + beatmap.DifficultySection.OverallDifficulty) / 38 * 5); // This is just following the wiki as close as I can, I honestly don't know where the 38 * 5 came from
        return gotHitCircleValue * (1 + ((hitCircle.ComboCounter-1) * difficultyModifier));
      }
    
      public int CalculateScore(MouseDance.Runtime.IHitObject slider, int gotSliderHeadScore, int collectedSliderParts, int totalSliderParts, bool pressWasEverReleased, OsuParsers.Beatmaps.Beatmap beatmap)
      {
        // Out of the percent of collected vs total, this will return either 0, 50, 100, or 300:
        // 66% to 100%: 300
        // 33% to 66% : 100
        // >0 to 33%  : 50
        // 0%         : 0
        int sliderCompletionScore = BeatmapUtil.GetSliderBaseScore(collectedSliderParts, totalSliderParts);
    
        int sliderValue = 0;
        
        // Allow a 300 score only if the player got 300 when hitting the Slider's head, and never releasing their hold on the mouse button
        if (!pressWasEverReleased && sliderCompletionScore == 300 && gotSliderHeadScore == 300)
        {
          sliderValue = 300;
        }
        // Allow a 100 score only if the player also got at least 100 when hitting the Slider's head
        else if (sliderCompletionScore >= 100 && gotSliderHeadScore >= 100)
        {
          sliderValue = 100;
        }
        else if (sliderCompletionScore == 50)
        {
          sliderValue = 50;
        }
    
        int difficultyModifier = Mathf.RoundToInt((beatmap.DifficultySection.CircleSize + beatmap.DifficultySection.OverallDifficulty) / 38 * 5); // This is just following the wiki as close as I can, I honestly don't know where the 38 * 5 came from
        return sliderValue * (1 + ((slider.ComboCounter-1) * difficultyModifier));
      }
    }
    

    Note that BeatmapRunner.SetScoreCalculator is called before starting the beatmap.

    Warning

    If your CalculateScore methods don't seem to be getting called, check if you've properly called SetScoreCalculator. For every BeatmapRunner, there can be at most only one active IBeatmapScoreCalculator in use.

    BeatmapRunner in the Inspector will show you which callbacks have been registered. The one labeled IBeatmapScoreCalculator should be green once the game is running.

    The name of the registered callback's concrete type will be displayed (namespace and class name). If it is a MonoBehaviour type, it'll show the actual file instead. You can click on that to ping it in the Project tab.

    Beatmap Runner Diagnostics

    This GUI is only for debugging. It is not designed or intended to register callbacks from the GUI.