private void AddNotes(ref SongParser.Notes notes, SongParser.NoteType noteType) { int _lane = 1; if (player.transform.position.y > 0.0f && player.transform.position.y <= 0.5f) { _lane = 0; } else if (player.transform.position.y < 0.0f && player.transform.position.y >= -0.5f) { _lane = 2; } switch (_lane) { case 0: notes.top = noteType; break; case 1: notes.middle = noteType; break; case 2: notes.bottom = noteType; break; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { SongParser.Metadata _tempSongData = new SongParser.Metadata(); _tempSongData.title = "JOURNEI"; _tempSongData.subtitle = ""; _tempSongData.artist = "Hans"; _tempSongData.bannerPath = ""; _tempSongData.backgroundPath = ""; _tempSongData.musicPath = "JOURNEI.mp3"; _tempSongData.offset = 0.0f; _tempSongData.sampleStart = 97.33f; _tempSongData.sampleLength = 10.58f; _tempSongData.bpm = 125; SongParser.NoteData _tempNoteData = new SongParser.NoteData(); List <SongParser.Notes> _tempBar = new List <SongParser.Notes>(); SongParser.Notes _tempNotes = new SongParser.Notes(); _tempNotes.bottom = 0; _tempNotes.middle = SongParser.NoteType.Air; _tempNotes.top = 0; _tempBar.Add(_tempNotes); _tempNoteData.bars = new List <List <SongParser.Notes> >(); _tempNoteData.bars.Add(_tempBar); _tempSongData.noteData = _tempNoteData; SongWriter _songWriter = new SongWriter(); _songWriter.Write(_tempSongData, Application.persistentDataPath); Debug.Log("Song should be written now."); } }
/// <summary> /// Records a single note line. /// </summary> /// <param name="bar">The bar that the note line belongs to.</param> private IEnumerator RecordNotes(List <SongParser.Notes> bar) { // Debug.Log("New notes."); isRecordingNotes = true; SongParser.Notes _notes = new SongParser.Notes(); _notes.top = 0; _notes.middle = 0; _notes.bottom = 0; float _timer = 0.0f; while (_timer <= (barTime / 4) - Time.deltaTime) { if (Input.GetKeyDown(KeyCode.W)) { AddNotes(ref _notes, SongParser.NoteType.Fire); } else if (Input.GetKeyDown(KeyCode.A)) { AddNotes(ref _notes, SongParser.NoteType.Air); } else if (Input.GetKeyDown(KeyCode.D)) { AddNotes(ref _notes, SongParser.NoteType.Water); } else if (Input.GetKeyDown(KeyCode.S)) { AddNotes(ref _notes, SongParser.NoteType.Earth); } _timer += Time.deltaTime; yield return(null); } //for (int i = 0; i < 4; i++) //{ // if (Input.GetKeyDown(KeyCode.W)) // { // AddNotes(ref _notes, SongParser.NoteType.Fire); // } // else if (Input.GetKeyDown(KeyCode.A)) // { // AddNotes(ref _notes, SongParser.NoteType.Air); // } // else if (Input.GetKeyDown(KeyCode.D)) // { // AddNotes(ref _notes, SongParser.NoteType.Water); // } // else if (Input.GetKeyDown(KeyCode.S)) // { // AddNotes(ref _notes, SongParser.NoteType.Earth); // } // yield return new WaitForSeconds((barTime / 4) - Time.deltaTime); //} bar.Add(_notes); isRecordingNotes = false; yield break; }