Esempio n. 1
0
        public override void CounterInit()
        {
            ColorUtility.TryParseHtmlString("#FFA500", out orange);

            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET);
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            SetPersonalBest((float)highScore / maxPossibleScore);
        }
        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);
            }
        }
Esempio n. 3
0
        private static void UploadScore(IDifficultyBeatmap levelDifficulty, LevelCompletionResults results, out bool newHighScore)
        {
            var freePlayCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            var dataModel           = freePlayCoordinator.GetPrivateField <PlayerDataModel>("_playerDataModel");

            PlayerData           currentLocalPlayer   = dataModel.playerData;
            PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelDifficulty.level.levelID, levelDifficulty.difficulty, levelDifficulty.parentDifficultyBeatmapSet.beatmapCharacteristic);

            int prevHighScore = playerLevelStatsData.highScore;

            LevelCompletionResults levelCompletionResults = results;

            playerLevelStatsData.UpdateScoreData(levelCompletionResults.modifiedScore, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);

            newHighScore = playerLevelStatsData.highScore > prevHighScore;

            var platFormLeaderBoardsModel = freePlayCoordinator.GetPrivateField <PlatformLeaderboardsModel>("_platformLeaderboardsModel");

            platFormLeaderBoardsModel.UploadScore(
                levelDifficulty,
                results.rawScore,
                results.modifiedScore,
                results.fullCombo,
                results.goodCutsCount,
                results.badCutsCount,
                results.missedCount,
                results.maxCombo,
                results.energy,
                results.gameplayModifiers);
        }
Esempio n. 4
0
 static void Postfix(StandardLevelDetailViewController __instance, ref LevelParamsPanel ____levelParamsPanel, ref TextMeshProUGUI ____highScoreText, ref IDifficultyBeatmap ____selectedDifficultyBeatmap, ref PlayerData ____playerData)
 {
     try
     {
         IBeatmapLevel level       = ____selectedDifficultyBeatmap.level;
         PlayerData    localPlayer = ____playerData;
         if (localPlayer != null)
         {
             PlayerLevelStatsData playerLevelStats = localPlayer.GetPlayerLevelStatsData(level.levelID, ____selectedDifficultyBeatmap.difficulty, ____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
             if (playerLevelStats != null)
             {
                 if (playerLevelStats.validScore)
                 {
                     int   highScore = int.Parse(____highScoreText.text);
                     int   maxScore  = ScoreController.MaxRawScoreForNumberOfNotes(____selectedDifficultyBeatmap.beatmapData.notesCount);
                     float percent   = (float)highScore / maxScore;
                     percent *= 100;
                     ____highScoreText.overflowMode       = TextOverflowModes.Overflow;
                     ____highScoreText.enableWordWrapping = false;
                     ____highScoreText.richText           = true;
                     ____highScoreText.text += "<size=75%> <#FFFFFF> (" + "<#FFD42A>" + percent.ToString("F2") + "%" + "<#FFFFFF>)";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Plugin.Log("Exception in DetailView Postfix: \n " + ex);
     }
 }
Esempio n. 5
0
        public void SetNextRankText()
        {
            if (!poll)
            {
                return;
            }

            // At launch, the UI exists, but no level is selected.
            LevelSO.DifficultyBeatmap difficultyBeatMap = ReflectionUtil.GetPrivateField <LevelSO.DifficultyBeatmap>(_songDetailViewController, "_difficultyBeatmap");
            if (difficultyBeatMap == null)
            {
                return;
            }

            // If the player hasn't finished a level, blank out the Next Rank text to fit in with the rest of the UI.
            if (_highScoreText.text == "-")
            {
                _nextRankText.text = _highScoreText.text;
                return;
            }

            BeatmapDifficulty difficulty = difficultyBeatMap.difficulty;
            int notesCount = difficultyBeatMap.beatmapData.notesCount;

            PlayerDataModelSO.LocalPlayer player = ReflectionUtil.GetPrivateField <PlayerDataModelSO.LocalPlayer>(_songDetailViewController, "_player");
            PlayerLevelStatsData          playerLevelStatsData = player.GetPlayerLevelStatsData(difficultyBeatMap.level.levelID, difficulty);

            _nextRankText.text = GetPointsToNextRank(notesCount, playerLevelStatsData.highScore);
        }
Esempio n. 6
0
        public override void CounterInit()
        {
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;

            maxPossibleScore = ScoreModel.ComputeMaxMultipliedScoreForBeatmap(beatmapData);

            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest(pbRatio);
            ScoreUpdated(0);
        }
        /// <summary>
        /// Update the gameplay play counts.
        /// </summary>
        /// <param name="gameplayMode"></param>
        private void UpdatePlayCounts()
        {
            // Build a map of levelId to sum of all playcounts and sort.
            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            foreach (KeyValuePair <string, List <BeatmapLevelSO> > entry in _levelPackToSongs)
            {
                foreach (var level in entry.Value)
                {
                    if (!_levelIdToPlayCount.ContainsKey(level.levelID))
                    {
                        // Skip folders
                        int playCountSum = 0;
                        foreach (IDifficultyBeatmapSet set in level.difficultyBeatmapSets)
                        {
                            foreach (IDifficultyBeatmap beatmap in set.difficultyBeatmaps)
                            {
                                PlayerLevelStatsData stats = playerData.currentLocalPlayer.GetPlayerLevelStatsData(level.levelID, beatmap.difficulty, set.beatmapCharacteristic);
                                playCountSum += stats.playCount;
                            }
                        }
                        _levelIdToPlayCount.Add(level.levelID, playCountSum);
                    }
                }
            }
        }
        static void Postfix(ref StandardLevelDetailViewPatches __instance)
        {
            if (__instance._showPlayerStats && __instance._playerData != null)
            {
                PlayerLevelStatsData playerLevelStatsData = __instance._playerData.GetPlayerLevelStatsData(__instance._level.levelID, __instance._selectedDifficultyBeatmap.difficulty, __instance._selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
                Plugin.scorePercentageCommon.currentScore = playerLevelStatsData.highScore;

                //Prepare Data for LevelStatsView
                if (playerLevelStatsData.validScore)
                {
                    Plugin.log.Debug("Condition 2 is true");
                    //calculate maximum possilble score
                    int currentDifficultyMaxScore = ScorePercentageCommon.calculateMaxScore(__instance.selectedDifficultyBeatmap.beatmapData.cuttableNotesType);
                    //calculate actual score percentage
                    double currentDifficultyPercentageScore = ScorePercentageCommon.calculatePercentage(currentDifficultyMaxScore, playerLevelStatsData.highScore);
                    Plugin.scorePercentageCommon.currentPercentage = currentDifficultyPercentageScore;

                    return;
                }
            }
            // Set currentScore and currentPercentage to 0, if no playerData exists
            // Does this even do anything!?
            Plugin.scorePercentageCommon.currentScore      = 0;
            Plugin.scorePercentageCommon.currentPercentage = 0;
        }
Esempio n. 9
0
        public void SongFinished(StandardLevelSceneSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers)
        {
            try
            {
                if (sender == null || levelCompletionResults == null || difficultyBeatmap == null || gameplayModifiers == null)
                {
                    return;
                }
                Logger.Debug("Finished song: " + levelCompletionResults.levelEndStateType + " - " + levelCompletionResults.songDuration + " - - " + levelCompletionResults.endSongTime);

                PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();
                _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
                _playerDataModel.Save();
                if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
                {
                    return;
                }

                PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
                bool                 cleared              = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
                string               levelID              = difficultyBeatmap.level.levelID;
                BeatmapDifficulty    difficulty           = difficultyBeatmap.difficulty;
                PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty);
                bool                 newHighScore         = playerLevelStatsData.highScore < levelCompletionResults.score;
                playerLevelStatsData.IncreaseNumberOfGameplays();
                if (cleared)
                {
                    playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                    Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
                }
            } catch (Exception e)
            {
                Data.Logger.Error(e);
            }
        }
        static void Postfix(ref StandardLevelDetailViewPatches __instance)
        {
            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);
                    Plugin.scorePercentageCommon.currentScore = playerLevelStatsData.highScore;
                    if (playerLevelStatsData.validScore)
                    {
                        //calculate maximum possilble score
                        int currentDifficultyMaxScore = ScorePercentageCommon.calculateMaxScore(__instance.selectedDifficultyBeatmap.beatmapData.notesCount);
                        //calculate actual score percentage
                        double currentDifficultyPercentageScore = ScorePercentageCommon.calculatePercentage(currentDifficultyMaxScore, playerLevelStatsData.highScore);
                        Plugin.scorePercentageCommon.currentPercentage = currentDifficultyPercentageScore;
                        //add percentage to highScoreText if it isn't disabled
                        if (PluginConfig.Instance.EnableMenuHighscore)
                        {
                            string highScoreText = playerLevelStatsData.highScore.ToString() + " " + "(" + currentDifficultyPercentageScore.ToString() + "%)";
                            __instance._highScoreText.text = highScoreText;
                        }
                        return;
                    }
                }
                // Set currentScore and currentPercentage to 0, if no playerData exists
                // Does this even do anything!?
                Plugin.scorePercentageCommon.currentScore      = 0;
                Plugin.scorePercentageCommon.currentPercentage = 0;

                // __instance._playerStatsContainer.SetActive(false);
            }
        }
        /// <summary>
        /// Update the gameplay play counts.
        /// </summary>
        /// <param name="gameplayMode"></param>
        private void UpdatePlayCounts()
        {
            // Build a map of levelId to sum of all playcounts and sort.
            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();
            IEnumerable <BeatmapDifficulty> difficultyIterator = Enum.GetValues(typeof(BeatmapDifficulty)).Cast <BeatmapDifficulty>();

            foreach (var level in _originalSongs)
            {
                if (!_levelIdToPlayCount.ContainsKey(level.levelID))
                {
                    // Skip folders
                    if (level.levelID.StartsWith("Folder_"))
                    {
                        _levelIdToPlayCount.Add(level.levelID, 0);
                    }
                    else
                    {
                        int playCountSum = 0;
                        foreach (BeatmapDifficulty difficulty in difficultyIterator)
                        {
                            PlayerLevelStatsData stats = playerData.currentLocalPlayer.GetPlayerLevelStatsData(level.levelID, difficulty);
                            playCountSum += stats.playCount;
                        }
                        _levelIdToPlayCount.Add(level.levelID, playCountSum);
                    }
                }
            }
        }
Esempio n. 12
0
        private void Init(CountersData data)
        {
            _scoreController = data.ScoreController;
            PlayerDataModelSO player = data.PlayerData;

            gameplayModsModel = data.ModifiersData;
            gameplayMods      = data.PlayerData.playerData.gameplayModifiers;
            IDifficultyBeatmap beatmap = data.GCSSD.difficultyBeatmap;

            stats = player.playerData.GetPlayerLevelStatsData(
                beatmap.level.levelID, beatmap.difficulty, beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            int maxRawScore = ScoreController.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            _maxPossibleScore = Mathf.RoundToInt(maxRawScore * gameplayModsModel.GetTotalMultiplier(gameplayMods));
            beginningPB       = stats.highScore / (float)_maxPossibleScore;
            highScore         = stats.highScore;

            Vector3 position = CountersController.DeterminePosition(gameObject, settings.Position, settings.Distance);

            TextHelper.CreateText(out _PbTrackerText, position);
            _PbTrackerText.fontSize  = settings.TextSize;
            _PbTrackerText.color     = Color.white;
            _PbTrackerText.alignment = TextAlignmentOptions.Center;

            _scoreController.scoreDidChangeEvent += UpdateScore;

            SetPersonalBest(beginningPB);

            if (settings.UnderScore)
            {
                StartCoroutine(WaitForScoreCounter());
            }
        }
Esempio n. 13
0
        public override void CounterInit()
        {
            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(noteCountProcessor.NoteCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest((float)highScore / maxPossibleScore);
            ScoreUpdated(0);
        }
Esempio n. 14
0
        public void SongFinished(StandardLevelScenesTransitionSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers, bool practice)
        {
            if (Client.Instance.InRadioMode)
            {
                PluginUI.instance.radioFlowCoordinator.lastDifficulty = difficultyBeatmap;
                PluginUI.instance.radioFlowCoordinator.lastResults    = levelCompletionResults;
            }

            if (Config.Instance.SpectatorMode || Client.disableScoreSubmission || ScoreSubmission.Disabled || ScoreSubmission.ProlongedDisabled)
            {
                List <string> reasons = new List <string>();

                if (Config.Instance.SpectatorMode)
                {
                    reasons.Add("Spectator mode");
                }
                if (Client.disableScoreSubmission)
                {
                    reasons.Add("Multiplayer score submission disabled by another mod");
                }
                if (ScoreSubmission.Disabled)
                {
                    reasons.Add("Score submission is disabled by " + ScoreSubmission.ModString);
                }
                if (ScoreSubmission.ProlongedDisabled)
                {
                    reasons.Add("Score submission is disabled for a prolonged time by " + ScoreSubmission.ProlongedModString);
                }

                Misc.Logger.Warning("\nScore submission is disabled! Reason:\n" + string.Join(",\n", reasons));
                return;
            }

            PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();

            _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
            _playerDataModel.Save();
            if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
            {
                return;
            }

            PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
            bool                    cleared               = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
            string                  levelID               = difficultyBeatmap.level.levelID;
            BeatmapDifficulty       difficulty            = difficultyBeatmap.difficulty;
            BeatmapCharacteristicSO beatmapCharacteristic = difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic;
            PlayerLevelStatsData    playerLevelStatsData  = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty, beatmapCharacteristic);
            bool                    newHighScore          = playerLevelStatsData.highScore < levelCompletionResults.score;

            playerLevelStatsData.IncreaseNumberOfGameplays();
            if (cleared)
            {
                Misc.Logger.Info("Submitting score...");
                playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
                Misc.Logger.Info("Score submitted!");
            }
        }
        static bool Prefix(MissionLevelScenesTransitionSetupDataSO missionLevelScenesTransitionSetupData, MissionCompletionResults missionCompletionResults, CampaignFlowCoordinator __instance, MissionSelectionNavigationController ____missionSelectionNavigationController)
        {
            if (!(____missionSelectionNavigationController.selectedMissionNode.missionData is CustomMissionDataSO))
            {
                return(true);
            }
            ChallengeExternalModifiers.onChallengeEnd?.Invoke();
            if (missionCompletionResults.levelCompletionResults.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
            {
                ____missionSelectionNavigationController.GetPrivateField <Action <MissionSelectionNavigationController> >("didPressPlayButtonEvent")(____missionSelectionNavigationController);
                return(false);
            }
            if (missionCompletionResults.levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared && missionCompletionResults.IsMissionComplete)
            {
                CustomMissionDataSO customMissionData = ____missionSelectionNavigationController.selectedMissionNode.missionData as CustomMissionDataSO;
                Campaign            campaign          = customMissionData.campaign;
                Challenge           challenge         = customMissionData.challenge;
                foreach (UnlockableItem item in challenge.unlockableItems)
                {
                    try
                    {
                        item.UnlockItem(campaign.path);
                    } catch (Exception ex)
                    {
                        Console.WriteLine("Failed to unlock item: " + item.fileName + " - Exception: " + ex.Message);
                    }
                }
                UnlockedItemsViewController unlockedItemsViewController = Resources.FindObjectsOfTypeAll <UnlockedItemsViewController>().First();
                unlockedItemsViewController.items = challenge.unlockableItems;
                unlockedItemsViewController.index = 0;
                if (unlockedItemsViewController.items.Count > 0)
                {
                    __instance.InvokeMethod("SetBottomScreenViewController", new object[] { unlockedItemsViewController, false });
                }
                if (challenge.unlockMap)
                {
                    UnlockedMaps.CompletedChallenge(challenge.name);
                }
                //Score submission
                if (customMissionData.gameplayModifiers.songSpeedMul == 1f && customMissionData.gameplayModifiers.fastNotes == false && customMissionData.gameplayModifiers.failOnSaberClash == false)
                {
                    SoloFreePlayFlowCoordinator freePlayCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();

                    PlayerDataModelSO dataModel = freePlayCoordinator.GetPrivateField <PlayerDataModelSO>("_playerDataModel");

                    PlayerData             currentLocalPlayer     = dataModel.playerData;
                    IDifficultyBeatmap     difficultyBeatmap      = Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded(customMissionData.customLevel.levelID).beatmapLevelData.GetDifficultyBeatmap(customMissionData.beatmapCharacteristic, customMissionData.beatmapDifficulty);
                    PlayerLevelStatsData   playerLevelStatsData   = currentLocalPlayer.GetPlayerLevelStatsData(difficultyBeatmap.level.levelID, difficultyBeatmap.difficulty, difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
                    LevelCompletionResults levelCompletionResults = missionCompletionResults.levelCompletionResults;
                    playerLevelStatsData.UpdateScoreData(levelCompletionResults.modifiedScore, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                    //todo Need change???
                    //freePlayCoordinator.GetPrivateField<PlatformLeaderboardsModel>("_platformLeaderboardsModel").AddScoreFromComletionResults(difficultyBeatmap, levelCompletionResults);
                }

                __instance.StartCoroutine(CustomCampaignLeaderboard.SubmitScore(challenge, missionCompletionResults));
            }
            return(true);
        }
Esempio n. 16
0
        public void GetMaxScores(LevelCompletionResults results, SongData data)
        {
            IDifficultyBeatmap   beatmap = data.GetGCSSD().difficultyBeatmap;
            PlayerLevelStatsData stats   = data.GetPlayerData().playerData.GetPlayerLevelStatsData(beatmap.level.levelID, beatmap.difficulty, beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);

            maxRawScore = ScoreModel.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.cuttableNotesType);

            modifiersMultiplier       = GetTotalMultiplier(data.GetPlayerData().playerData.gameplayModifiers, results.energy);
            maxScore                  = Mathf.RoundToInt(maxRawScore * modifiersMultiplier);
            personalBestModifiedRatio = stats.highScore / (float)maxScore;
            personalBestRawRatio      = stats.highScore / (float)maxRawScore;
            personalBest              = stats.highScore;
        }
Esempio n. 17
0
        public static void GetSongInfo()
        {
            if (_mainGameSceneSetupData == null)
            {
                _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault();
            }
            //Get notes count
            noteCount = _mainGameSceneSetupData.difficultyBeatmap.beatmapData.notesCount;
            PlayerDataModelSO    playerData      = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();
            PlayerLevelStatsData playerLevelData = playerData.currentLocalPlayer.GetPlayerLevelStatsData(_mainGameSceneSetupData.difficultyBeatmap.level.levelID, _mainGameSceneSetupData.difficultyBeatmap.difficulty);

            //Get Player Score
            if (playerScore == 0)
            {
                Log("Attempting to grab Local Score");
                playerScore = playerLevelData.validScore ? playerLevelData.highScore : 0;
            }


            CalculatePercentage();
        }
Esempio n. 18
0
        public void SongFinished(StandardLevelSceneSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers, bool practice)
        {
            if (Client.Instance.InRadioMode)
            {
                PluginUI.instance.radioFlowCoordinator.lastDifficulty = difficultyBeatmap;
                PluginUI.instance.radioFlowCoordinator.lastResults    = levelCompletionResults;
            }

            if (Config.Instance.SpectatorMode || Client.disableScoreSubmission || ScoreSubmission.Disabled || ScoreSubmission.ProlongedDisabled)
            {
                return;
            }

            PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();

            _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
            _playerDataModel.Save();
            if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
            {
                return;
            }

            PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
            bool                 cleared              = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
            string               levelID              = difficultyBeatmap.level.levelID;
            BeatmapDifficulty    difficulty           = difficultyBeatmap.difficulty;
            PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty);
            bool                 newHighScore         = playerLevelStatsData.highScore < levelCompletionResults.score;

            playerLevelStatsData.IncreaseNumberOfGameplays();
            if (cleared)
            {
                playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
            }
        }
Esempio n. 19
0
        private void BSEvents_gameSceneLoaded()
        {
            ResetData();

            LiveData.InLevel = true;
            scoreController  = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
            scoreController.scoreDidChangeEvent += ScoreController_scoreDidChangeEvent;

            AudioTimeSyncController audioController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
            PlayerData playerData = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData;
            GameplayCoreSceneSetupData currentMap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;

            IBeatmapLevel levelData = currentMap.difficultyBeatmap.level;

            StaticData.SongName    = levelData.songName;
            StaticData.SongSubName = levelData.songSubName;
            StaticData.SongAuthor  = levelData.songAuthorName;
            StaticData.Mapper      = levelData.levelAuthorName;
            StaticData.BPM         = Convert.ToInt32(Math.Round(levelData.beatsPerMinute));
            StaticData.Length      = Convert.ToInt32(Math.Round(audioController.songLength));
            PlayerLevelStatsData playerLevelStats = playerData.GetPlayerLevelStatsData(levelData.levelID, currentMap.difficultyBeatmap.difficulty,
                                                                                       currentMap.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);

            StaticData.PreviousRecord = playerLevelStats.highScore;

            if (previousMap == null || previousBeatmap == null || (levelData.levelID != previousMap.difficultyBeatmap.level.levelID))
            {
                Task.Run(async() =>
                {
                    if (previousBeatmap != null)
                    {
                        StaticData.PreviousBSR = previousBeatmap.Key;
                    }
                    Beatmap bm = await beatSaver.Hash(levelData.levelID.Replace("custom_level_", ""));
                    if (bm != null)
                    {
                        StaticData.BSRKey     = bm.Key;
                        StaticData.coverImage = BeatSaver.BaseURL + bm.CoverURL;
                        previousBeatmap       = bm;
                    }
                    else
                    {
                        StaticData.BSRKey = null; StaticData.coverImage = null; previousBeatmap = null;
                    }
                    StaticData.Send();
                });
            }
            else
            {
                StaticData.BSRKey = previousBeatmap.Key; StaticData.coverImage = BeatSaver.BaseURL + previousBeatmap.CoverURL;
            }

            StaticData.Difficulty = currentMap.difficultyBeatmap.difficultyRank;
            StaticData.NJS        = currentMap.difficultyBeatmap.noteJumpMovementSpeed;

            StaticData.Modifiers.Add("instaFail", currentMap.gameplayModifiers.instaFail);
            StaticData.Modifiers.Add("batteryEnergy", currentMap.gameplayModifiers.energyType == GameplayModifiers.EnergyType.Battery);
            StaticData.Modifiers.Add("disappearingArrows", currentMap.gameplayModifiers.disappearingArrows);
            StaticData.Modifiers.Add("ghostNotes", currentMap.gameplayModifiers.ghostNotes);
            StaticData.Modifiers.Add("fasterSong", currentMap.gameplayModifiers.songSpeedMul == 1.2f ? true : false);
            StaticData.Modifiers.Add("noFail", currentMap.gameplayModifiers.noFail);
            LiveData.PlayerHealth = StaticData.Modifiers["noFail"] ? 100 : 50;
            StaticData.Modifiers.Add("noObstacles", currentMap.gameplayModifiers.enabledObstacleType == GameplayModifiers.EnabledObstacleType.NoObstacles);
            StaticData.Modifiers.Add("noBombs", currentMap.gameplayModifiers.noBombs);
            StaticData.Modifiers.Add("slowerSong", currentMap.gameplayModifiers.songSpeedMul == 0.85f ? true : false);
            StaticData.Modifiers.Add("noArrows", currentMap.gameplayModifiers.noArrows);
            if (currentMap.practiceSettings != null) //In Practice mode
            {
                StaticData.PracticeMode = true;
                startSongTime           = new TimeSpan(0, 0, (int)Math.Round(currentMap.practiceSettings.startSongTime) - 1); //1s time desync
                StaticData.PracticeModeModifiers.Add("songSpeedMul", currentMap.practiceSettings.songSpeedMul);
            }

            previousMap = currentMap;

            TimeElapsed.Start();
            TimeElapsedLogger.Start();

            StaticData.Send();
            LiveData.Send();
        }
Esempio n. 20
0
        public void SetupMapDataAndMisc()
        {
            PlayerData    playerData    = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData;
            IBeatmapLevel levelData     = gameplayCoreSceneSetupData.difficultyBeatmap.level;
            bool          isCustomLevel = true;
            string        mapHash       = string.Empty;

            try { mapHash = levelData.levelID.Split('_')[2]; } catch { isCustomLevel = false; }
            isCustomLevel = isCustomLevel && mapHash.Length == 40 ? true : false;

            var difficultyData = SongCore.Collections.RetrieveDifficultyData(gameplayCoreSceneSetupData.difficultyBeatmap);

            MapData.Hash        = isCustomLevel ? mapHash : null;
            MapData.SongName    = levelData.songName;
            MapData.SongSubName = levelData.songSubName;
            MapData.SongAuthor  = levelData.songAuthorName;
            MapData.Mapper      = levelData.levelAuthorName;
            MapData.BPM         = Convert.ToInt32(Math.Round(levelData.beatsPerMinute));
            MapData.Length      = Convert.ToInt32(Math.Round(audioTimeSyncController.songLength));
            PlayerLevelStatsData playerLevelStats = playerData.GetPlayerLevelStatsData(levelData.levelID, gameplayCoreSceneSetupData.difficultyBeatmap.difficulty,
                                                                                       gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);

            MapData.PreviousRecord        = playerLevelStats.highScore;
            MapData.MapType               = gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName;
            MapData.Difficulty            = gameplayCoreSceneSetupData.difficultyBeatmap.difficulty.ToString("g");
            MapData.NJS                   = gameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed;
            MapData.CustomDifficultyLabel = difficultyData?._difficultyLabel ?? null;


            SongDataCoreCurrent sdc = new SongDataCoreCurrent {
                available = isCustomLevel ? SongDataCore.Plugin.Songs.IsDataAvailable() : false
            };

            if (sdc.available)
            {
                BeatStarSong map;
                SongDataCore.Plugin.Songs.Data.Songs.TryGetValue(mapHash, out map);
                sdc.map = map;
                if (sdc.map != null)
                {
                    Dictionary <string, BeatStarSongDifficultyStats> diffs = sdc.map.characteristics[(BeatStarCharacteristics)Enum.Parse(typeof(BeatStarCharacteristics),
                                                                                                                                         gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)];
                    sdc.stats    = diffs[MapData.Difficulty == "ExpertPlus" ? "Expert+" : MapData.Difficulty];
                    MapData.PP   = sdc.stats.pp;
                    MapData.Star = sdc.stats.star;
                }
                else
                {
                    sdc.available = false;
                }
            }

            if (sdc.available)
            {
                MapData.BSRKey = sdc.map.key;
                if (levelData is CustomPreviewBeatmapLevel customLevel)
                {
                    MapData.coverImage = GetBase64CoverImage(customLevel);
                }
                else
                {
                    getBeatsaverMap();
                }
            }
            else
            {
                getBeatsaverMap();
            }

            void getBeatsaverMap()
            {
                Task.Run(async() =>
                {
                    Beatmap bm = await beatSaver.Hash(mapHash);
                    if (bm != null)
                    {
                        MapData.BSRKey     = bm.Key;
                        MapData.coverImage = BeatSaver.BaseURL + bm.CoverURL;
                    }
                    else
                    {
                        MapData.BSRKey = null;
                    }
                    MapData.Send();
                });
            }

            if (MapData.Hash != previousStaticData.Hash)
            {
                MapData.PreviousBSR = previousStaticData.BSRKey;
            }

            MapData.Modifiers.Add("noFailOn0Energy", gameplayCoreSceneSetupData.gameplayModifiers.noFailOn0Energy);
            MapData.Modifiers.Add("oneLife", gameplayCoreSceneSetupData.gameplayModifiers.instaFail);
            MapData.Modifiers.Add("fourLives", gameplayCoreSceneSetupData.gameplayModifiers.energyType == GameplayModifiers.EnergyType.Battery);
            MapData.Modifiers.Add("noBombs", gameplayCoreSceneSetupData.gameplayModifiers.noBombs);
            MapData.Modifiers.Add("noWalls", gameplayCoreSceneSetupData.gameplayModifiers.enabledObstacleType == GameplayModifiers.EnabledObstacleType.NoObstacles);
            MapData.Modifiers.Add("noArrows", gameplayCoreSceneSetupData.gameplayModifiers.noArrows);
            MapData.Modifiers.Add("ghostNotes", gameplayCoreSceneSetupData.gameplayModifiers.ghostNotes);
            MapData.Modifiers.Add("disappearingArrows", gameplayCoreSceneSetupData.gameplayModifiers.disappearingArrows);
            MapData.Modifiers.Add("smallNotes", gameplayCoreSceneSetupData.gameplayModifiers.smallCubes);
            MapData.Modifiers.Add("proMode", gameplayCoreSceneSetupData.gameplayModifiers.proMode);
            MapData.Modifiers.Add("strictAngles", gameplayCoreSceneSetupData.gameplayModifiers.strictAngles);
            MapData.Modifiers.Add("zenMode", gameplayCoreSceneSetupData.gameplayModifiers.zenMode);
            MapData.Modifiers.Add("slowerSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 0.85f ? true : false);
            MapData.Modifiers.Add("fasterSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 1.2f ? true : false);
            MapData.Modifiers.Add("superFastSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 1.5f ? true : false);
            foreach (KeyValuePair <string, bool> keyValue in MapData.Modifiers)
            {
                if (MapData.Modifiers[keyValue.Key] && Enum.IsDefined(typeof(Modifiers), keyValue.Key))
                {
                    MapData.ModifiersMultiplier += (int)(Modifiers)Enum.Parse(typeof(Modifiers), keyValue.Key) / 100f;
                }
            }
            MapData.PracticeMode = gameplayCoreSceneSetupData.practiceSettings != null ? true : false;
            MapData.PracticeModeModifiers.Add("songSpeedMul", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.songSpeedMul : 1);
            MapData.PracticeModeModifiers.Add("startInAdvanceAndClearNotes", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.startInAdvanceAndClearNotes ? 1 : 0 : 0);
            MapData.PracticeModeModifiers.Add("startSongTime", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.startSongTime : 0);

            MapData.InLevel = true;
            timer.Start();

            MapData.Send();
            LiveData.Send();
        }