IEnumerator FixerToNextLevel(LevelSO level) { BackToCutscene(); yield return(wait1Second); spawner.SpawnLevel(level); enemiesSpawned = level.numberOfEnemies; onEnemiesCountChanged.Invoke(enemiesSpawned); fixer.Stand(); yield return(wait1Second); Vector3 fixingPosition = level.arcadeMachine.GetFixingPosition(); Vector3 fixerStartPosition = fixer.transform.position; float step = (fixer.speed / (fixerStartPosition - fixingPosition).magnitude) * Time.fixedDeltaTime; float t = 0; while (t <= 1.0f) { t += step; // Goes from 0 to 1, incrementing by step each time fixer.transform.position = Vector3.Lerp(fixerStartPosition, fixingPosition, t); // Move objectToMove closer to b yield return(new WaitForFixedUpdate()); // Leave the routine and return here in the next frame } fixer.transform.position = fixingPosition; fixer.Fixing(); yield return(wait1Second); ToPlayMode(); //yield return new WaitForSeconds(5f); //ToNextLevel(); }
private void Awake() { if (loadLevelSO != null) { levelSO = loadLevelSO; } }
public void SetSelectedSong(SongInfo info) { _selectedSong = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(info.levelId)); if (_selectedSong != null) { _selectedDifficulty = _selectedSong.difficultyBeatmaps.OrderByDescending(x => x.difficulty).First().difficulty; _selectedSongCell.songName = _selectedSong.songName + "\n<size=80%>" + _selectedSong.songSubName + "</size>"; _selectedSongCell.author = _selectedSong.songAuthorName; _selectedSongCell.coverImage = _selectedSong.coverImage; } else { _selectedSongCell.songName = info.songName; _selectedSongCell.author = "Loading info..."; SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) => { _selectedSongCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>"; _selectedSongCell.author = song.authorName; StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _selectedSongCell.coverImage = cover; })); }); } UpdateButtons(); }
public void SetSongInfo(SongInfo songInfo) { _currentSongInfo = songInfo; if (_currentSongCell != null) { LevelSO level = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(songInfo.levelId)); if (level == null) { _currentSongCell.songName = _currentSongInfo.songName; _currentSongCell.author = "Loading info..."; SongDownloader.Instance.RequestSongByLevelID(_currentSongInfo.levelId, (song) => { _currentSongCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>"; _currentSongCell.author = song.authorName; StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _currentSongCell.coverImage = cover; })); } ); } else { _currentSongCell.songName = $"{level.songName}\n<size=80%>{level.songSubName}</size>"; _currentSongCell.author = level.songAuthorName; _currentSongCell.coverImage = level.coverImage; } } }
public void ShowResultsScreen() { if (!_radioNavController.viewControllers.Contains(_resultsScreenViewController)) { PushViewControllerToNavigationController(_radioNavController, _resultsScreenViewController, null, true); if (lastDifficulty == null || lastResults == null) { _resultsScreenViewController.SetSongInfo(channelInfo.currentSong, channelInfo.preferredDifficulty); } else { _resultsScreenViewController.SetSongInfo(lastDifficulty, lastResults); } LevelSO level = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(channelInfo.currentSong.levelId)); if (level != null) { SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)level, (levelLoaded) => { PreviewPlayer.CrossfadeTo(levelLoaded.audioClip, levelLoaded.previewStartTime, Math.Max(totalTime - currentTime, levelLoaded.previewDuration)); }); } } }
LevelSO[] SortLevelsByCreationTime(LevelSO[] levels) { DirectoryInfo customSongsFolder = new DirectoryInfo(Environment.CurrentDirectory.Replace('\\', '/') + "/CustomSongs/"); List <string> sortedFolders = customSongsFolder.GetDirectories().OrderByDescending(x => x.CreationTime.Ticks).Select(x => x.FullName.Replace('\\', '/')).ToList(); List <string> sortedLevelIDs = new List <string>(); foreach (string path in sortedFolders) { CustomLevel song = SongLoader.CustomLevels.FirstOrDefault(x => x.customSongInfo.path.StartsWith(path)); if (song != null) { sortedLevelIDs.Add(song.levelID); } } List <LevelSO> notSorted = new List <LevelSO>(levels); List <LevelSO> sortedLevels = new List <LevelSO>(); foreach (string levelId in sortedLevelIDs) { LevelSO data = notSorted.FirstOrDefault(x => x.levelID == levelId); if (data != null) { sortedLevels.Add(data); } } sortedLevels.AddRange(notSorted.Except(sortedLevels)); return(sortedLevels.ToArray()); }
private void PlayNow_Pressed() { SongInfo info = channelInfo.currentSong; LevelSO level = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(info.levelId)); if (level == null) { SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) => { SongDownloader.Instance.DownloadSong(song, "RadioSongs", () => { SongLoader.Instance.RefreshSongs(false); SongLoader.SongsLoadedEvent += PlayNow_SongsLoaded; }, (progress) => { _inGameViewController.SetProgressBarState((progress < 100f), progress); }); }); } else { SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)level, (levelLoaded) => { StartLevel(levelLoaded, channelInfo.preferredDifficulty, currentTime); }); } }
public void SetSong(SongInfo info) { if (_songTableCell == null) { return; } _selectedSong = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(info.levelId)); if (_selectedSong != null) { _songTableCell.songName = _selectedSong.songName + "\n<size=80%>" + _selectedSong.songSubName + "</size>"; _songTableCell.author = _selectedSong.songAuthorName; _songTableCell.coverImage = _selectedSong.coverImage; } else { _songTableCell.songName = info.songName; _songTableCell.author = "Loading info..."; SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) => { _songTableCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>"; _songTableCell.author = song.authorName; StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _songTableCell.coverImage = cover; })); }); } }
public void ShowLeaderboard(List <PlayerInfo> playerInfos, SongInfo song) { if (_leaderboardViewController == null) { _leaderboardViewController = BeatSaberUI.CreateViewController <LeaderboardViewController>(); } if (_roomNavigationController.viewControllers.IndexOf(_leaderboardViewController) < 0) { PushViewControllerToNavigationController(_roomNavigationController, _leaderboardViewController, null, true); } LevelSO level = _levelCollection.levels.FirstOrDefault(x => x.levelID.StartsWith(song.levelId)); if (level != null) { if (level is CustomLevel) { SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)level, SongLoaded); } else { PreviewPlayer.CrossfadeTo(level.audioClip, level.previewStartTime, (level.audioClip.length - level.previewStartTime), 1f); } } _leaderboardViewController.SetLeaderboard(playerInfos); _leaderboardViewController.SetSong(song); }
private void Match3_OnLevelSet(object sender, System.EventArgs e) { LevelSO levelSO = match3.GetLevelSO(); switch (levelSO.goalType) { default: case LevelSO.GoalType.Glass: transform.Find("glassImage").gameObject.SetActive(true); glassText.gameObject.SetActive(true); targetScoreText.gameObject.SetActive(false); break; case LevelSO.GoalType.Score: transform.Find("glassImage").gameObject.SetActive(false); glassText.gameObject.SetActive(false); targetScoreText.gameObject.SetActive(true); targetScoreText.text = levelSO.targetScore.ToString(); break; } UpdateText(); }
private void SongLoaded(LevelSO song) { if (_difficultySelectionViewController != null) { _difficultySelectionViewController.SetPlayButtonInteractable(true); } PreviewPlayer.CrossfadeTo(song.audioClip, song.previewStartTime, (song.audioClip.length - song.previewStartTime), 1f); }
private void SongSelected(LevelSO song) { lastSelectedSong = song.levelID; Client.Instance.SetSelectedSong(new SongInfo() { songName = song.songName + " " + song.songSubName, levelId = song.levelID.Substring(0, Math.Min(32, song.levelID.Length)) }); }
public List <FlowerData> GenerateRandomFlowers(LevelSO level) { CorrentHeight = Random.value; levelData = level; AddCorrectChoices(); AddWrongChoices(); return(returnedList); }
public void Init(LevelSO level) { this.levelSriptable = level; this.LevelNumber.text = level.levelID.ToString(); this.LevelImage.sprite = level.LevelPhoto; Star.enabled = (level.isCompleted) ? true : false; button.onClick.AddListener(() => { GameManager.i.LoadCurrentLevel(this.levelSriptable); }); }
public void Init(LevelSO levelData) { waves = levelData.waves; _isInit = true; spawnTiles = FindObjectsOfType <RoadTile>().Where(x => x.isStart).ToArray(); PlayerStats.Instance.WavesTotal = waves.Length; waveButton.onClick.AddListener(StartWave); }
private void Awake() { levelSO = match3.GetLevelSO(); Columns = levelSO.width; Rows = levelSO.height; NumCellTypes = levelSO.gemList.Count; NumSpecialTypes = levelSO.goalType == LevelSO.GoalType.Glass ? 1 : 0; agent = GetComponent <Agent>(); }
public static void RefreshData(LevelSO song = null) { try { if (queuedSong == null) { if (song == null) { song = SongListUtils.GetInstalledSong(); } Logger.Debug($"Refresh Waiting Menu data - Song is {(song != null ? "not" : "")} loaded"); if (song != null) { level.text = $"Queued: { song.songName} by { song.songAuthorName }"; if (song is CustomLevel) { SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)song, (customLevel) => { Logger.Debug($"Loaded audio Clip for {song.songName}"); ReadyUp(customLevel); }); } else { ReadyUp(song); } } else if (!downloading) { level.text = $"Downloading: { SteamAPI.GetSongName()}"; Logger.Debug($"We do not have the song in our library, lets start downloading it."); downloading = true; Instance.StartCoroutine(Utils.SongDownloader.Instance.DownloadSong(SteamAPI.GetSongId(), LevelDownloadProgress, LevelDownloaded)); } } if (Instance && Instance.isActiveAndEnabled) { Dictionary <string, float> status = Controllers.PlayerController.Instance.GetConnectedPlayerDownloadStatus(); middleViewController.Data.Clear(); foreach (KeyValuePair <string, float> user in status.OrderBy(u => u.Value)) { CustomCellInfo cell = new CustomCellInfo(user.Key, user.Value == -1f ? "FAILED TO DOWNLOAD": user.Value == 1f ? "Ready" : $"Downloading song ${(int) Math.Round(user.Value * 100, 0)}%", user.Value == 1f ? Sprites.checkmarkIcon : Sprites.crossIcon); middleViewController.Data.Add(cell); } middleViewController._customListTableView.ReloadData(); middleViewController._customListTableView.ScrollToRow(0, false); } } catch (Exception e) { Logger.Error(e); } }
public bool RemoveLevel(LevelSO level) { var removed = _levelList.Remove(level); if (removed) { UpdateArray(); } return(removed); }
public static void LevelDownloaded(string hash) { try { downloading = false; LevelSO song = SongListUtils.GetInstalledSong(hash.ToUpper()); RefreshData(song); } catch (Exception e) { Logger.Error(e); } }
private static void ReadyUp(LevelSO song) { if (queuedSong != null || (queuedSong == null && song == null)) { return; } if (queuedSong == null && song != null) { queuedSong = song; SteamAPI.SetReady(); PreviewPlayer.CrossfadeTo(song.audioClip, song.previewStartTime, song.previewDuration); } }
public void CreateNewLevelSO() { #if UNITY_EDITOR levelSO = Utils.Instance.CreateAsset <LevelSO>("Assets/SO Data/Levels/Level.asset"); var newArray = new LevelSO[GameDataSO.levelSOs.Length + 1]; GameDataSO.levelSOs.CopyTo(newArray, 0); newArray[GameDataSO.levelSOs.Length] = levelSO; GameDataSO.levelSOs = newArray; #endif //UNITY_EDITOR }
public override void Paint(LevelSO levelSO, bool useSameColor = false) { currentLevelSO = levelSO; if (currentLevelSO == null) { return; } GenerateMesh(currentLevelSO.carpetSOs, useSameColor); var x = currentLevelSO.Position.x * canvas.transform.localScale.x; var z = currentLevelSO.Position.y * canvas.transform.localScale.z; canvas.transform.localPosition = new Vector3(x, 0.01f, z); }
public void ShowInGameScreen() { if (!_radioNavController.viewControllers.Contains(_inGameViewController)) { PushViewControllerToNavigationController(_radioNavController, _inGameViewController, null, true); _inGameViewController.SetSongInfo(channelInfo.currentSong); LevelSO level = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(channelInfo.currentSong.levelId)); if (level != null) { SongLoader.Instance.LoadAudioClipForLevel((CustomLevel)level, (levelLoaded) => { PreviewPlayer.CrossfadeTo(levelLoaded.audioClip, levelLoaded.previewStartTime, Math.Max(totalTime - currentTime, levelLoaded.previewDuration)); }); } } }
public void SetLevelSO(LevelSO levelSO) { this.levelSO = levelSO; gridWidth = levelSO.width; gridHeight = levelSO.height; grid = new Grid <GemGridPosition>(gridWidth, gridHeight, 1f, Vector3.zero, (Grid <GemGridPosition> g, int x, int y) => new GemGridPosition(g, x, y)); // Initialize Grid for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { // Get Saved LevelGridPosition LevelSO.LevelGridPosition levelGridPosition = null; foreach (LevelSO.LevelGridPosition tmpLevelGridPosition in levelSO.levelGridPositionList) { if (tmpLevelGridPosition.x == x && tmpLevelGridPosition.y == y) { levelGridPosition = tmpLevelGridPosition; break; } } if (levelGridPosition == null) { // Couldn't find LevelGridPosition with this x, y! Debug.LogError("Error! Null!"); } GemSO gem = levelGridPosition.gemSO; GemGrid gemGrid = new GemGrid(gem, x, y); grid.GetGridObject(x, y).SetGemGrid(gemGrid); grid.GetGridObject(x, y).SetHasGlass(levelGridPosition.hasGlass); } } score = 0; moveCount = levelSO.moveAmount; OnLevelSet?.Invoke(this, new OnLevelSetEventArgs { levelSO = levelSO, grid = grid }); }
public void StartLevel(LevelSO song, BeatmapDifficulty difficulty) { if (Connected && NetworkClient != null) { #if DEBUG Misc.Logger.Info("Starting level..."); #endif NetOutgoingMessage outMsg = NetworkClient.CreateMessage(); outMsg.Write((byte)CommandType.StartLevel); outMsg.Write((byte)difficulty); new SongInfo() { songName = song.songName + " " + song.songSubName, levelId = song.levelID.Substring(0, Math.Min(32, song.levelID.Length)), songDuration = song.audioClip.length }.AddToMessage(outMsg); NetworkClient.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered, 0); } }
private void Awake() { levelSO = match3.GetLevelSO(); Columns = levelSO.width; Rows = levelSO.height; NumCellTypes = levelSO.gemList.Count; NumSpecialTypes = levelSO.goalType == LevelSO.GoalType.Score ? 0 : 1; agent = GetComponent <Agent>(); match3Visual.OnStateWaitingForUser += Match3Visual_OnStateWaitingForUser; match3.OnGemGridPositionDestroyed += Match3_OnGemGridPositionDestroyed; match3.OnGlassDestroyed += Match3_OnGlassDestroyed; match3.OnMoveUsed += Match3_OnMoveUsed; match3.OnOutOfMoves += Match3_OnOutOfMoves; match3.OnWin += Match3_OnWin; }
public BeatmapDifficulty GetClosestDifficulty(LevelSO level, BeatmapDifficulty difficulty) { int num = -1; foreach (IDifficultyBeatmap difficultyBeatmap in level.difficultyBeatmaps) { if (difficulty < difficultyBeatmap.difficulty) { break; } num++; } if (num == -1) { num = 0; } return(level.difficultyBeatmaps[num].difficulty); }