public static BeatMapData ConvertBSDataToEditorData(BeatSaberJSONClass fromBeatSaber) { BeatMapData bmd = new BeatMapData(); bmd.beatsPerMinute = fromBeatSaber.info.beatsPerMinute; bmd.mapArtist = fromBeatSaber.info.authorName; bmd.songArtist = fromBeatSaber.info.songSubName; bmd.songName = fromBeatSaber.info.songName; bmd.songOffset = fromBeatSaber.info.difficultyLevels[0].offset / 100; List <NoteDetails> notes = new List <NoteDetails>(); foreach (BSNote bsNote in fromBeatSaber.level._notes) { NoteDetails note = new NoteDetails(); if (bsNote._type == 0) { note.color = Note.NoteColor.LEFT; } else { note.color = Note.NoteColor.RIGHT; } note.slashDirection = BSNote.GetSlashDirection(bsNote._cutDirection); note.gridPosition = new Vector2(bsNote._lineIndex, bsNote._lineLayer); note.timeToSpawn = bsNote._time; notes.Add(note); } bmd.notes = notes.ToArray(); return(bmd); }
public static NoteDetails[] GenerateNotesForNewMap(BeatMap.NoteMode modeToGenerate, int totalBeats) { Debug.Log("Generating notes for new map, #Beats-" + totalBeats + " Mode-" + modeToGenerate); int numberOfNotesToGenerate = (12 * totalBeats); numberOfNotesToGenerate = (int)(numberOfNotesToGenerate * Note.GetFactor(modeToGenerate)); NoteDetails[] notes = new NoteDetails[numberOfNotesToGenerate]; for (int count = 0; count < numberOfNotesToGenerate; count++) { notes[count] = new NoteDetails(); int offSet = count % 12; int y = offSet / 4; int x = offSet % 4; Vector2 gridPosition = new Vector2(x, y); notes[count].gridPosition = gridPosition; notes[count].color = Note.NoteColor.NONE; notes[count].slashDirection = Note.SlashDirection.NONE; float spawnTime = (int)(count / 12f) / Note.GetFactor(modeToGenerate); float factor = Note.GetFactor(modeToGenerate); spawnTime = BeatMap.RoundToRelativeBeat(spawnTime, modeToGenerate); notes[count].timeToSpawn = spawnTime; } return(notes); }
private void InvertArray(List <NoteDetails> notes) { for (int count = 0; count < notes.Count; count++) { NoteDetails currentNote = notes[count]; currentNote.inverted = !currentNote.inverted; } }
public static void AddNoteChange(NoteDetails change) { int noteIndex = BeatMapData.GetNoteWithSamePosition(change, notes); if (noteIndex > -1) { changes.Add(notes[noteIndex]); } }
public void Initialize(NoteDetails noteDetails, Material[] availableMats, Vector3 spawnPosition) { if (materials == null) { materials = availableMats; } HitBox = new HitBox(hitBox, hurtBox); materials = availableMats; meshRenderer = GetComponent <MeshRenderer>(); this.noteDetails = noteDetails; transform.position = spawnPosition; Refresh(); }
public static int GetNoteWithSamePosition(NoteDetails note, NoteDetails[] listToSearch) { for (int count = 0; count < listToSearch.Length; count++) { if (note.gridPosition == listToSearch[count].gridPosition) { if (Mathf.Abs(note.timeToSpawn - listToSearch[count].timeToSpawn) < .1f) { return(count); } } } return(-1); }
public bool AddNoteDetail(NoteDetails details) { if (completedNotes.Contains(details)) { return(false); } else if (waitingNotes.Contains(details)) { return(false); } foreach (Note note in activeNotes) { if (note.noteDetails.timeToSpawn == details.timeToSpawn) { if (note.noteDetails.gridPosition == details.gridPosition) { return(false); } } } completedNotes.Add(details); return(true); }
private void Update() { if (!initialized) { // Initialization // if (audioIsLoading) { AudioIsInitialized(); } } // INITIALIZED // else { // Start Update // currentFrame++; if (running) { beatManager.Update(); // Song may be completed // if ((state == EditorState.Playback || state == EditorState.Recording) && !audioSource.isPlaying) { PauseSong(); } if (mainCamera.transform.position.z >= showGuardAtZ && !guard.activeSelf) { guard.SetActive(true); BeatMap.Log("Guard activated"); PauseSong(); } } // Check if player is back in a good position and resume song // else if (guard.activeSelf && mainCamera.transform.position.z < showGuardAtZ) { guard.SetActive(false); BeatMap.Log("Guard deactivated"); ResumeSong(); } // If we're not running, we are done // else { return; } // Check if the next beat has started // if (beatManager.NextBeatStarted(true, mostRecentBeat)) { mostRecentBeat = beatManager.GetCurrentRelativeBeat(); // Check if any active notes are complete // foreach (Note note in activeNotes) { if ((note.transform.position.z < destroyNoteAtZ && !beatManager.rewinding) || (note.transform.position.z > spawnPositions[0, 0].z) && beatManager.rewinding) { note.gameObject.SetActive(false); if (!beatManager.rewinding) { completedNotes.Add(note.noteDetails); } else { waitingNotes.Add(note.noteDetails); } } } // Wait list is determined by rewinding // List <NoteDetails> waitList; if (!beatManager.rewinding) { waitList = waitingNotes; } else { waitList = completedNotes; } // Temp list for removing notes from waiting list // List <NoteDetails> notesDoneWaiting = new List <NoteDetails>(); for (int count = 0; count < waitList.Count; count++) { NoteDetails noteDetails = waitList[count]; float playerRelativeTimeToSpawn = beatManager.currentBeat + beatsToReachPlayer; if ((playerRelativeTimeToSpawn >= noteDetails.timeToSpawn && !beatManager.rewinding) || (beatManager.currentBeat <= noteDetails.timeToSpawn && beatManager.rewinding)) { Note note = noteDetails.note; if (note == null) { note = Instantiate(notePrefab).GetComponent <Note>(); } note.Initialize(noteDetails, materials, GetSpawnPosition(noteDetails.gridPosition, beatManager.rewinding)); note.transform.SetParent(NoteContainer.transform); notesDoneWaiting.Add(noteDetails); activeNotes.Add(note); note.Refresh(); } } foreach (NoteDetails note in notesDoneWaiting) { if (!beatManager.rewinding) { waitingNotes.Remove(note); } else { completedNotes.Remove(note); } } } } }