private IEnumerator StartingSong(string ChartLocation, Song.ChartType type) { Debug.Log("Loading"); Song song = null; SongLoader.Instance.Load(ChartLocation, type, delegate(Song _song) { song = _song; }); fade.color = new Color(0, 0, 0, 0); fade.gameObject.SetActive(true); while (fade.color.a < 1) { fade.color += new Color(0, 0, 0, Time.deltaTime); yield return(null); } while (song == null) { yield return(null); } Debug.Log("Loading audio"); bool prepared = false; SongLoader.Instance.PrepareAudio(song, delegate() { prepared = true; }); while (!prepared) { yield return(null); } Session.PlayerInfo[] players = new Session.PlayerInfo[] { //new Session.PlayerInfo(Song.Difficulty.Easy), //new Session.PlayerInfo(Song.Difficulty.Medium), //new Session.PlayerInfo(Song.Difficulty.Hard), new Session.PlayerInfo(Song.Difficulty.Expert) }; session.Initialize(song, players); selectScreen.SetActive(false); Debug.Log("Ready to play"); while (fade.color.a > 0) { fade.color -= new Color(0, 0, 0, Time.deltaTime); yield return(null); } fade.gameObject.SetActive(false); System.GC.Collect(); session.StartPlaying(); }
public void LoadSong(string ChartLocation, Song.ChartType type) { StartCoroutine(StartingSong(ChartLocation, type)); }
private SongInfo CreateSongInfo(string s, Song.ChartType type) { SongInfo temp = new SongInfo(); string path = Path.GetDirectoryName(s); string[] songINIFile = Directory.GetFiles(path, "*.ini", SearchOption.AllDirectories); if (songINIFile.Length > 0 && File.Exists(path + "//song.ini")) { foreach (string line in File.ReadAllLines(path + "//song.ini")) { if (line.Contains("artist ") || line.Contains("artist=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); temp.Artist = spaceRemove.Substring(7); } if (line.Contains("name ") || line.Contains("name=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); temp.SongName = spaceRemove.Substring(5); } if (line.Contains("charter ") || line.Contains("charter=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); temp.Charter = spaceRemove.Substring(8); } if (line.Contains("album ") || line.Contains("album=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); temp.Album = spaceRemove.Substring(6); } if (line.Contains("delay ") || line.Contains("delay=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); temp.offset = Math.Abs((long)Convert.ToUInt64(spaceRemove.Substring(6))); } if (line.Contains("preview_start_time ") || line.Contains("preview_start_time=")) { string spaceRemove = line.Replace("= ", "=").Replace(" =", "="); string value = spaceRemove.Substring(19); uint _time = 0; uint.TryParse(value, out _time); long time = Math.Abs(_time); temp.PreviewStartTime = time; } } temp.type = type; temp.fileLoction = s; return(temp); } else { ChartReader chartReader = new ChartReader(); Song _currentChart = new Song(); _currentChart = chartReader.ReadChartFile(s); temp.Artist = _currentChart.data.info.chartArtist; temp.SongName = _currentChart.data.info.chartName; temp.Charter = _currentChart.data.info.chartCharter; temp.PreviewStartTime = (long)_currentChart.data.info.previewStart; temp.type = type; temp.offset = (long)_currentChart.data.info.offset; temp.Album = "Album Unknown"; temp.fileLoction = s; } return(temp); }