private void RandomSong() { level = null; IStandardLevel song = null; var levels = SongsForDifficulty(); var vaildSongCount = levels.Count; if (vaildSongCount != 0) { do { int rand = UnityEngine.Random.Range(0, vaildSongCount); song = levels[rand]; }while (pastSongs.Contains(song)); } level = song; if (level != null) { randomButton.interactable = true; } else { randomButton.interactable = false; } }
public void RemoveSong(IStandardLevel level) { if (level == null) { return; } RemoveSong(level as CustomLevel); }
public static bool HasDifficultyInRange(this IStandardLevel level, LevelDifficulty min, LevelDifficulty max) { bool hasDiff = false; for (int i = (int)min; i <= (int)max; i++) { if (level.GetDifficultyLevel((LevelDifficulty)i) != null) { hasDiff = true; } } return(hasDiff); }
IEnumerator SelectAndLoadSong(IStandardLevel level) { AddToQueue(level); var diff = minDiff; IStandardLevelDifficultyBeatmap difficultyLevel = null; do { diff = (LevelDifficulty)UnityEngine.Random.Range((int)minDiff, (int)maxDiff + 1); difficultyLevel = level.GetDifficultyLevel(diff); } while (difficultyLevel == null); if (autoPlay) { // Fade screen away to not spoil song var gameSceneManager = Resources.FindObjectsOfTypeAll <GameScenesManager>().FirstOrDefault(); gameSceneManager.HandleExecutorTransitionDidStart(0.7f); //var fade = Resources.FindObjectsOfTypeAll<FadeOutOnGameEvent>().FirstOrDefault(); //fade.HandleGameEvent(0.7f); // Turn preview down player.volume = 0; yield return(new WaitForSeconds(1.0f)); } int row = listTableView.RowNumberForLevelID(level.levelID); tableView.SelectRow(row, true); tableView.ScrollToRow(row, false); difficultyViewController.SetDifficultyLevels(level.difficultyBeatmaps, difficultyLevel); var gameplayMode = detailViewController.gameplayMode; var gameplayOptions = detailViewController.gameplayOptions; detailViewController.SetContent(difficultyLevel, gameplayMode); if (autoPlay) { detailViewController.PlayButtonPressed(); if (gameplayMode.IsSolo() && !gameplayOptions.validForScoreUse) { var prompt = flowController.GetPrivateField <SimpleDialogPromptViewController>("_simpleDialogPromptViewController"); yield return(new WaitForSeconds(0.1f)); flowController.HandleSimpleDialogPromptViewControllerDidFinish(prompt, true); } } }
private void AddToQueue(IStandardLevel played) { pastSongs.Enqueue(played); int numSongs = SongsForDifficulty().Count; if (allowAfter > numSongs) { allowAfter = numSongs - 2; if (allowAfter < 0) { allowAfter = 0; } } while (pastSongs.Count > allowAfter) { pastSongs.Dequeue(); } }
public CustomDifficultyBeatmap(IStandardLevel parentLevel, LevelDifficulty difficulty, int difficultyRank, float noteJumpMovementSpeed, BeatmapDataSO beatmapData) : base(parentLevel, difficulty, difficultyRank, noteJumpMovementSpeed, beatmapData) { }
public IEnumerator Start() { // The goal now is to find the clip this scene will be playing. // For this, we find the single root gameObject (which is the gameObject // to which we are attached), // then we get its GameSongController to find the audio clip, // and its FlyingTextSpawner to display the lyrics. textSpawner = FindObjectOfType <FlyingTextSpawner>(); songController = FindObjectOfType <GameSongController>(); if (textSpawner == null || songController == null) { yield break; } MainGameSceneSetup sceneSetup = FindObjectOfType <MainGameSceneSetup>(); if (sceneSetup == null) { yield break; } MainGameSceneSetupData sceneSetupData = SetupDataField.GetValue(sceneSetup) as MainGameSceneSetupData; if (sceneSetupData == null) { yield break; } List <Subtitle> subtitles = new List <Subtitle>(); if (LyricsFetcher.GetLocalLyrics(sceneSetupData.difficultyLevel.level.levelID, subtitles)) { // Lyrics found locally, continue with them. SpawnText("Lyrics found locally", 3f); } else { // Clip found, now select the first song that has the same clip (using reference comparison). IStandardLevel level = sceneSetupData.difficultyLevel.level; // We found the matching song, we can get started. Debug.Log($"Corresponding song data found: {level.songName} by {level.songAuthorName}."); // When this coroutine ends, it will call the given callback with a list // of all the subtitles we found, and allow us to react. // If no subs are found, the callback is not called. yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level.songName, level.songAuthorName, subtitles))); if (subtitles.Count == 0) { yield break; } SpawnText("Lyrics found online", 3f); } StartCoroutine(DisplayLyrics(subtitles)); }
private void StandardLevelListViewControllerOnDidSelectLevelEvent(StandardLevelListViewController arg1, IStandardLevel level) { var customLevel = level as CustomLevel; if (customLevel == null) { return; } if (customLevel.audioClip != TemporaryAudioClip || customLevel.AudioClipLoading) { return; } var levels = arg1.GetPrivateField <IStandardLevel[]>("_levels").ToList(); Action callback = delegate { arg1.SetPrivateField("_selectedLevel", null); arg1.HandleLevelSelectionDidChange(levels.IndexOf(customLevel), true); }; customLevel.FixBPMAndGetNoteJumpMovementSpeed(); StartCoroutine(LoadAudio( "file:///" + customLevel.customSongInfo.path + "/" + customLevel.customSongInfo.GetAudioPath(), customLevel, callback)); }