Objects.Song createTestSong() { Objects.Song returnSong = new Objects.Song(); returnSong.BPM = 120f; Random randomNoteGenerator = new Random(); // Create random notes for (float i = 1f; i < 600f; i += randomNoteGenerator.Next(1, 3)) { Objects.Note newNote = new Objects.Note(m_Game); newNote.Location = new Point(randomNoteGenerator.Next(-1, 2), randomNoteGenerator.Next(-1, 2)); returnSong.AddNote(i, newNote); SpawnGameObject(newNote); m_Notes.Add(newNote); } return(returnSong); }
public void ParseFile(string filename) { Objects.Song song = new Objects.Song(); string path = Path.Combine(Directory.GetCurrentDirectory(), "Content", filename); string line; StreamReader sr = new StreamReader(path); bool gameElements = false; while ((line = sr.ReadLine()) != null) { if (gameElements) { Objects.Note note = new Objects.Note(m_Game); note.Beat = float.Parse(line.Remove(line.IndexOf(","))); line = line.Substring(line.IndexOf(",") + 2); string type = line.Remove(line.IndexOf(",")); if (type.Equals("Bad")) { note.SetBad(true); note.NotePowerup = Objects.Note.Powerup.None; } else { note.SetBad(false); if (type.Equals("Good")) { note.NotePowerup = Objects.Note.Powerup.None; } else { note.SetPowerup(type); } } if (type.Equals("Good") || type.Equals("Bad")) { line = line.Substring(line.IndexOf(",") + 2); note.Value = int.Parse(line.Remove(line.IndexOf(","))); } else { note.Value = 0; } line = line.Substring(line.IndexOf(",") + 2); note.IntToLocation(int.Parse(line)); song.AddNote(note.Beat, note); SpawnGameObject(note); m_Notes.Add(note); } if (line.StartsWith("#")) { if (line.Contains("GameElements")) { gameElements = true; } continue; } else if (line.StartsWith("Name:")) { song.Name = line.Remove(0, 6); } else if (line.StartsWith("Artist:")) { song.Artist = line.Remove(0, 8); } else if (line.StartsWith("Mode:")) { string mode = line.Remove(0, 6); if (mode.Equals("Dance")) { song.DanceMode = true; } else { song.DanceMode = false; } } else if (line.StartsWith("Difficulty:")) { song.Difficulty = int.Parse(line.Remove(0, 12)); } else if (line.StartsWith("BPM:")) { song.BPM = float.Parse(line.Remove(0, 5)); } else if (line.StartsWith("SongLength:")) { song.Length = float.Parse(line.Remove(0, 12)); } else if (line.StartsWith("LeadIn:")) { song.LeadIn = float.Parse(line.Remove(0, 8)); } else if (line.StartsWith("BeatsPerMeasure:")) { song.BeatsPerMeasure = int.Parse(line.Remove(0, 17)); } else if (line.StartsWith("AppearanceTime:")) { song.AppearanceTime = float.Parse(line.Remove(0, 16)); } } m_Songs.Clear(); m_Songs.Add(song); sr.Close(); }