Esempio n. 1
0
 private void TimerElapsedEvent(object se, ElapsedEventArgs ev)
 {
     LiveData.TimeElapsed = (int)Math.Round(audioTimeSyncController.songTime);
     if (Math.Truncate(DateTime.Now.Subtract(LiveData.LastSend).TotalMilliseconds) > 950 / MapData.PracticeModeModifiers["songSpeedMul"])
     {
         LiveData.Send();
     }
 }
Esempio n. 2
0
 private void NoteWasMissedEvent(NoteController noteController)
 {
     if (noteController.noteData.colorType != ColorType.None)
     {
         LiveData.Combo     = 0;
         LiveData.FullCombo = false;
         LiveData.Misses++;
         LiveData.Send();
     }
 }
Esempio n. 3
0
 private void EnergyDidChangeEvent(float health)
 {
     health *= 100;
     if (MapData.Modifiers["noFailOn0Energy"] && health <= 0)
     {
         MapData.LevelFailed          = true;
         MapData.ModifiersMultiplier += -50 / 100f;
         MapData.Send();
     }
     if (health < LiveData.PlayerHealth)
     {
         LiveData.Combo = 0;
     }
     LiveData.PlayerHealth = health;
     LiveData.Send();
 }
Esempio n. 4
0
 private void SetRankAndAccuracy()
 {
     LiveData.Accuracy = relativeScoreAndImmediateRankCounter.relativeScore * 100;
     LiveData.Rank     = relativeScoreAndImmediateRankCounter.immediateRank.ToString();
     LiveData.Send();
 }
Esempio n. 5
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();
        }