private void PrinteResult() { int num = EiderToolPage.Instance.SongObject.BossInfos.BossLineObject.Count; float sumTime = 0; for (int i = 0; i < num; i++) { BossLineInfo temp = EiderToolPage.Instance.SongObject.BossInfos.BossLineObject[i]; sumTime += temp.KeepTimeLength * 0.001f / temp.SoundText.Split('$').Length; } LogManager.Log("平均时间为:", sumTime / num); }
public void AddNew() { m_ContentType = ContentBossType.AddNew; m_EditerLine = new BossLineInfo(); m_EditerLine.KeepTimeLength = 0; m_EditerLine.SoundText = ""; m_EditerLine.ClickText = ""; m_EditerLine.MusicFileName = ""; m_EditerLine.Type = SentenceInfo.SentenceType.ClickNode; m_EditerLine.IsEnd = false; DisPlayInfo(); }
public void Eider(int k) { m_ContentType = ContentBossType.Editer; m_BossLineNum = k; BossLineInfo temp = EiderToolPage.Instance.SongObject.BossInfos.BossLineObject[m_BossLineNum]; m_EditerLine = new BossLineInfo(); m_EditerLine.KeepTimeLength = temp.KeepTimeLength; m_EditerLine.SoundText = temp.SoundText; m_EditerLine.ClickText = temp.ClickText; m_EditerLine.MusicFileName = temp.MusicFileName; m_EditerLine.Type = temp.Type; m_EditerLine.IsEnd = temp.IsEnd; DisPlayInfo(); }
public void WriteSongtoTxt(SongTxtObject songInfo) { m_filePath = Application.dataPath + filePath; m_fileName = m_filePath + "/" + songInfo.SongInfos.SongName + ".txt"; LogManager.Log(m_fileName); if (!Directory.Exists(m_filePath)) { Directory.CreateDirectory(m_filePath); } FileStream fs; StreamWriter sw; if (File.Exists(m_fileName)) { fs = new FileStream(m_fileName, FileMode.Create, FileAccess.Write); } else { fs = new FileStream(m_fileName, FileMode.Create, FileAccess.Write); } sw = new StreamWriter(fs); sw.WriteLine("[General]"); sw.WriteLine("AudioFileName:" + songInfo.SongInfos.AudioFileName + ".mp3"); sw.WriteLine("BPM:" + songInfo.SongInfos.BPM); sw.WriteLine("[HitObjects]"); if (songInfo.HitInfos.Count > 0 && songInfo.BossInfos.IsBoss == false) { for (int i = 0; i < songInfo.HitInfos.Count; i++) { float x = (songInfo.HitInfos[i].Position[0] + 700) * 512f / 1400f; float y = (525 - songInfo.HitInfos[i].Position[1]) * 512f / 1400f; if (songInfo.HitInfos[i].Type == SentenceInfo.SentenceType.SoundNode) { sw.WriteLine((int)x + "," + (int)y + "," + (songInfo.HitInfos[i].StartHitTime + songInfo.HitInfos[i].EndHitTime) / 2 + ",1,0,0:0:0:0:"); } else { sw.WriteLine((int)x + "," + (int)y + "," + songInfo.HitInfos[i].HitTime + ",1,0,0:0:0:0:"); } } sw.WriteLine("[SentenceInfo]"); int startTime = songInfo.HitInfos[0].StartHitTime; int endTime = songInfo.HitInfos[0].EndHitTime; string soundText = ""; string clickText = songInfo.HitInfos[0].ClickText; if (songInfo.HitInfos[0].Type == SentenceInfo.SentenceType.SoundNode) { soundText = "#" + songInfo.HitInfos[0].SoundText; } else { soundText = songInfo.HitInfos[0].SoundText; } for (int i = 1; i < songInfo.HitInfos.Count; i++) { if (songInfo.HitInfos[i].StartHitTime == startTime) { if (!string.IsNullOrEmpty(songInfo.HitInfos[i].SoundText) && !string.IsNullOrEmpty(songInfo.HitInfos[i].ClickText)) { soundText = soundText + "$" + songInfo.HitInfos[i].SoundText; clickText = clickText + "$" + songInfo.HitInfos[i].ClickText; } } else { if (string.IsNullOrEmpty(soundText) == false && string.IsNullOrEmpty(clickText) == false) { sw.WriteLine(startTime + "," + endTime + "," + soundText + "," + clickText); } startTime = songInfo.HitInfos[i].StartHitTime; endTime = songInfo.HitInfos[i].EndHitTime; clickText = songInfo.HitInfos[i].ClickText; if (songInfo.HitInfos[i].Type == SentenceInfo.SentenceType.SoundNode) { soundText = "#" + songInfo.HitInfos[i].SoundText; } else { soundText = songInfo.HitInfos[i].SoundText; } } } if (string.IsNullOrEmpty(soundText) == false && string.IsNullOrEmpty(clickText) == false) { sw.WriteLine(startTime + "," + endTime + "," + soundText + "," + clickText); } } else { sw.WriteLine("[SentenceInfo]"); } BossInfo tempBoss = songInfo.BossInfos; if (tempBoss.BossLineObject.Count > 0) { if (tempBoss.IsBoss) { sw.WriteLine("@@" + tempBoss.StartTime + "," + tempBoss.DelayTime); for (int i = 0; i < tempBoss.BossLineObject.Count; i++) { BossLineInfo tempLine = tempBoss.BossLineObject[i]; string isEnd = ""; if (tempLine.IsEnd == true) { isEnd = "BB"; } if (tempLine.Type == SentenceInfo.SentenceType.SoundNode) { sw.WriteLine(tempLine.KeepTimeLength + ",#" + tempLine.SoundText + "," + tempLine.ClickText + "," + tempLine.MusicFileName + "," + isEnd); } else { sw.WriteLine(tempLine.KeepTimeLength + "," + tempLine.SoundText + "," + tempLine.ClickText + "," + tempLine.MusicFileName + "," + isEnd); } } } else { sw.WriteLine("@@VoiceStart," + tempBoss.DelayTime); for (int i = 0; i < tempBoss.BossLineObject.Count; i++) { BossLineInfo tempLine = tempBoss.BossLineObject[i]; if (tempLine.Type == SentenceInfo.SentenceType.SoundNode) { sw.WriteLine(tempLine.KeepTimeLength + ",#" + tempLine.SoundText + "," + tempLine.ClickText + "," + tempLine.MusicFileName); } else { sw.WriteLine(tempLine.KeepTimeLength + "," + tempLine.SoundText + "," + tempLine.ClickText + "," + tempLine.MusicFileName); } } } } sw.Close(); fs.Close(); }
public static SongTxtObject GetSongInfo(string fileName) { SongTxtObject songInfo = new SongTxtObject(); string path = "/Resources/Songs/" + fileName + ".txt"; if (DebugConfigController.Instance.RunTimeEditor) { path = Application.dataPath + path; } else { path = "Assets" + path; } songInfo.SongInfos.SongName = fileName; if (!File.Exists(path)) { return(null); } string[] contents = File.ReadAllLines(path); m_CollectType = CollectType.General; int hitno = 0; for (int i = 0; i < contents.Length; i++) { string parseContent = contents[i].Trim(); if (string.IsNullOrEmpty(parseContent)) { continue; } if (parseContent.Contains("[HitObjects]")) { m_CollectType = CollectType.HitObject; continue; } if (parseContent.Contains("[SentenceInfo]")) { m_CollectType = CollectType.SentenceInfo; continue; } if (parseContent.Contains("@@")) { m_CollectType = CollectType.Boss; string[] timeTemp = parseContent.Split(','); if (timeTemp.Length < 2) { LogManager.LogError("data parse error: the data file is --", path); } if (parseContent.Contains("@@VoiceStart")) { songInfo.BossInfos.IsBoss = false; songInfo.BossInfos.StartTime = -1; songInfo.BossInfos.DelayTime = int.Parse(timeTemp[1]); } else { songInfo.BossInfos.IsBoss = true; songInfo.BossInfos.StartTime = int.Parse(timeTemp[0].Replace("@@", "")); songInfo.BossInfos.DelayTime = int.Parse(timeTemp[1]); } continue; } switch (m_CollectType) { case CollectType.General: if (parseContent.Contains("AudioFileName:")) { songInfo.SongInfos.AudioFileName = parseContent.Replace("AudioFileName:", ""); } else if (parseContent.Contains("BPM:")) { songInfo.SongInfos.BPM = int.Parse(parseContent.Replace("BPM:", "")); } break; case CollectType.HitObject: string[] param = parseContent.Split(','); if (param.Length < 3) { LogManager.LogError("data parse error: the data file is --", path); } else { Vector2 pos = new Vector2(int.Parse(param[0]), int.Parse(param[1])); Vector2 pos2 = new Vector2(pos.x * (1400f / 512f) - 700f, 525 - pos.y * (1400f / 512f)); int startTime = int.Parse(param[2]); HitInfo ho = new HitInfo(); ho.HitTime = startTime; ho.Position = pos2; if (songInfo.HitInfos.Count > 0) { songInfo.HitInfos[songInfo.HitInfos.Count - 1].EndHitTime = ho.HitTime - 100; } ho.StartHitTime = ho.HitTime; ho.Type = SentenceInfo.SentenceType.ClickNode; ho.EndHitTime = ho.HitTime + 2000; ho.SoundText = "SE"; ho.ClickText = "SE"; songInfo.HitInfos.Add(ho); } break; case CollectType.SentenceInfo: string[] temp = parseContent.Split(','); //加了配音字段,先注掉 if (temp.Length != 4 && false) { LogManager.LogError("data parse error: the data file is --", path); LogManager.LogError("parseContent: ", parseContent); } else { SentenceInfo sentence = new SentenceInfo(); sentence.StartTime = int.Parse(temp[0]); sentence.EndTime = int.Parse(temp[1]); if (temp[2].Contains("#")) { temp[2] = temp[2].Replace("#", ""); sentence.Type = SentenceInfo.SentenceType.SoundNode; } else { sentence.Type = SentenceInfo.SentenceType.ClickNode; } string[] SoundText = temp[2].Split('$'); string[] ClickText = temp[3].Split('$'); for (int textNum = 0; hitno < songInfo.HitInfos.Count; hitno++, textNum++) { if (songInfo.HitInfos[hitno].HitTime >= sentence.StartTime && songInfo.HitInfos[hitno].HitTime <= sentence.EndTime) { songInfo.HitInfos[hitno].StartHitTime = sentence.StartTime; songInfo.HitInfos[hitno].EndHitTime = sentence.EndTime; songInfo.HitInfos[hitno].Type = sentence.Type; if (sentence.Type == SentenceInfo.SentenceType.SoundNode) { songInfo.HitInfos[hitno].HitTime = sentence.StartTime; } if (textNum < SoundText.Length && textNum < ClickText.Length) { songInfo.HitInfos[hitno].SoundText = SoundText[textNum]; songInfo.HitInfos[hitno].ClickText = ClickText[textNum]; } } else { break; } } } break; case CollectType.Boss: string[] bossTemp = parseContent.Split(','); if ((songInfo.BossInfos.IsBoss && bossTemp.Length != 5) || (!songInfo.BossInfos.IsBoss && bossTemp.Length != 4 && bossTemp.Length != 3)) { LogManager.LogError("data parse error: the data file is --", path); } BossLineInfo lineTemp = new BossLineInfo(); lineTemp.KeepTimeLength = int.Parse(bossTemp[0]); if (bossTemp[1].Contains("#")) { lineTemp.Type = SentenceInfo.SentenceType.SoundNode; } else { lineTemp.Type = SentenceInfo.SentenceType.ClickNode; } lineTemp.SoundText = bossTemp[1].Replace("#", ""); lineTemp.ClickText = bossTemp[2].Replace("#", ""); if (bossTemp.Length > 3) { lineTemp.MusicFileName = bossTemp[3]; } if (songInfo.BossInfos.IsBoss && bossTemp[4] == "BB") { lineTemp.IsEnd = true; } else { lineTemp.IsEnd = false; } songInfo.BossInfos.BossLineObject.Add(lineTemp); break; } } return(songInfo); }