Esempio n. 1
0
        public void Initialize(BeatMapData data, NoteMode noteMode, EditorState requestedState)
        {
            if (BeatMap.state != EditorState.Started)
            {
                Debug.Log("Trying to initialize when not in started state - " + state);
                return;
            }
            Debug.LogWarning("Audio loaded, Initializing with note mode " + currentNoteMode);

            waitingNotes       = new List <NoteDetails>();
            activeNotes        = new List <Note>();
            completedNotes     = new List <NoteDetails>();
            beatManager        = new Utilities.BeatManager(data.beatsPerMinute, song);
            audioSource.clip   = song;
            beatsToReachPlayer = timeToReachPlayer * beatManager.beatsPerSecond; // Convert from seconds to beats
            Debug.Log("Time to reach player Seconds-Beats -- " + timeToReachPlayer + "-" + beatsToReachPlayer);
            Debug.Log("BPM - " + data.beatsPerMinute + " BPS - " + beatManager.beatsPerSecond);
            Debug.Log("Total beats - " + beatManager.GetTotalBeats);
            lastBeatBarPlacedAtBeat = beatManager.GetCurrentWholeBeat;
            beatMapData             = data;
            waitingNotes            = new List <NoteDetails>();
            activeNotes             = new List <Note>();
            completedNotes          = new List <NoteDetails>();
            if (data.notes == null)
            {
                beatMapData.notes = new NoteDetails[0];
            }
            Log("Loading notes, size - " + data.notes.Length);
            for (int count = 0; count < data.notes.Length; count++)
            {
                data.notes[count].inverted    = false;
                data.notes[count].timeToSpawn = RoundToRelativeBeat(data.notes[count].timeToSpawn, noteMode);
                waitingNotes.Add(data.notes[count]);
            }
            // When in creative mode, we keep the inverted objects in memory //
            if (requestedState == EditorState.Recording || requestedState == EditorState.Editing)
            {
                Debug.Log("Creating inverted array, waitingnotes size - " + waitingNotes.Count + " - " +
                          "total beats - " + beatManager.GetTotalBeats);
                NoteDetails[] invertedArray = BeatMapData.InvertNoteArray(waitingNotes.ToArray(), beatManager.GetTotalBeats, currentNoteMode);
                for (int count = 0; count < invertedArray.Length; count++)
                {
                    invertedArray[count].inverted = true;
                    waitingNotes.Add(invertedArray[count]);
                }
                Log("Inverted array size - " + invertedArray.Length);
            }
            if (requestedState == EditorState.Editing || requestedState == EditorState.PlaybackPaused)
            {
                // If we have an inverted map on top of the regular map, disable note displah for performance //
                miniMap.showNotes = true;
            }
            else if (requestedState == EditorState.Playback || requestedState == EditorState.Recording)
            {
                miniMap.showNotes = false;
            }
            SetRunning(false);
            SetCurrentState(requestedState);
            miniMap.Initialize(beatManager.GetTotalBeats, beatsToReachPlayer);
            initialized = true;
        }