static void Postfix(ref StandardLevelDetailViewPatches __instance)
        {
            //Only run calculation, if it isn't disabled
            if (!Settings.Config.EnableMenuHighscore)
            {
                return;
            }

            if (__instance._playerStatsContainer)
            {
                if (__instance._showPlayerStats && __instance._playerData != null)
                {
                    __instance._playerStatsContainer.SetActive(true);
                    PlayerLevelStatsData playerLevelStatsData = __instance._playerData.GetPlayerLevelStatsData(__instance._level.levelID, __instance._selectedDifficultyBeatmap.difficulty, __instance._selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);

                    if (playerLevelStatsData.validScore)
                    {
                        //calculate maximum possilble score
                        int currentDifficultyMaxScore = ScorePercentage.calculateMaxScore(__instance.selectedDifficultyBeatmap.beatmapData.notesCount);
                        //calculate actual score percentage
                        double currentDifficultyPercentageScore = ScorePercentage.calculatePercentage(currentDifficultyMaxScore, playerLevelStatsData.highScore);
                        //add percentage to highScoreText
                        string highScoreText = playerLevelStatsData.highScore.ToString() + " " + "(" + currentDifficultyPercentageScore.ToString() + "%)";
                        __instance._highScoreText.text = highScoreText;
                        return;
                    }
                }
                // __instance._playerStatsContainer.SetActive(false);
            }
        }
        static void Postfix(ref ResultsViewControllerPatches __instance)
        {
            if (UI.Settings.instance.isEndEnabled)
            {
                return;
            }

            int    maxScore;
            double resultPercentage;
            double resultAvgPercentage;
            int    resultScore;

            //Only calculate percentage, if map was successfully cleared
            if (__instance._levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared)
            {
                maxScore = ScorePercentage.calculateMaxScore(__instance._difficultyBeatmap.beatmapData.notesCount);
                //use modifiedScore with negative multipliers
                if (__instance._levelCompletionResults.gameplayModifiers.noFail || __instance._levelCompletionResults.gameplayModifiers.noObstacles || __instance._levelCompletionResults.gameplayModifiers.noArrows || __instance._levelCompletionResults.gameplayModifiers.noBombs)
                {
                    resultScore = __instance._levelCompletionResults.modifiedScore;
                }
                //use rawScore without and with positive modifiers to avoid going over 100% without recalculating maxScore
                else
                {
                    resultScore = __instance._levelCompletionResults.rawScore;
                }
                //$resultScore =
                resultPercentage    = ScorePercentage.calculatePercentage(maxScore, resultScore);
                resultAvgPercentage = ScorePercentage.calculatePercentage(115 * ScorePercentage.numNotes, ScorePercentage.totalScore);

                //disable wrapping and autosize. format string and overwite rankText
                __instance._rankText.autoSizeTextContainer = false;
                __instance._rankText.enableWordWrapping    = false;
                if (UI.Settings.instance.isAvgEnabled)
                {
                    __instance._rankText.text = "<size=70%>" + resultPercentage.ToString() + "<size=50%>" + "%\n" + "<size=70%>" + ((resultAvgPercentage * 115) / 100).ToString() + "<size=50%>" + "/" + 115.ToString();
                }
                else
                {
                    __instance._rankText.text = "<size=70%>" + resultPercentage.ToString() + "<size=50%>";
                }
                Logger.log.Debug("Total Score: " + ScorePercentage.totalScore.ToString());
                Logger.log.Debug((115 * ScorePercentage.numNotes).ToString());
                Logger.log.Debug(ScorePercentage.numNotes.ToString());
            }
        }
Beispiel #3
0
    // When note block hits player collider - where segments are placed
    private void OnTriggerEnter(Collider other)
    {
        MusicNote noteHit = other.GetComponentInParent <MusicNote>();

        noteCounter++;

        // Player was correct
        if (ringManager.SelectedRingElement != null && noteHit.ColorOfNote.ringElement == ringManager.SelectedRingElement.RingElement())
        {
            comboCounter++;
            notesHit++;
            if (comboCounter > MaxComboAchieved)
            {
                MaxComboAchieved = comboCounter;
            }

            animator.SetBool("Jump", true);
            StartCoroutine(setBoolParameterNextFrame("Jump", false));

            healthPoints += gameSettings.HealthRegainOnHit;
            if (healthPoints > 100)
            {
                healthPoints = 100;
            }

            audioSource.PlayOneShot(hitSound);
        }
        // Player missed
        else
        {
            comboCounter  = 0;
            healthPoints -= gameSettings.HealthLossOnFail;
            if (healthPoints < 0)
            {
                healthPoints = 0;
            }

            audioSource.PlayOneShot(missSound);
        }

        if (healthPoints <= 0)
        {
            FindObjectOfType <InLevelManager>().EndGameScreen(true);
        }
        else if (healthPoints < 20)
        {
            healthPointsBarUI.GetComponent <Image>().color = Color.red;
        }
        else if (healthPoints < 40)
        {
            healthPointsBarUI.GetComponent <Image>().color = Color.yellow;
        }
        else
        {
            healthPointsBarUI.GetComponent <Image>().color = Color.white;
        }

        // Calculate scores
        int baseScore = 100;

        TotalPlayerScore   += comboCounter * baseScore;
        totalPossibleScore += noteCounter * baseScore;
        ScorePercentage     = (float)notesHit * 100 / (float)noteCounter;

        // Show on UI
        scorePercentageUI.text       = ScorePercentage.ToString("F2") + "%";   // Two decimal points
        comboCounterUI.text          = comboCounter + "x";
        healthPointsBarUI.localScale = new Vector3(1, healthPoints / 100, 1);
    }