// Start is called before the first frame update void Start() { Note135 = GameObject.Find("NoteCube 135"); Note24 = GameObject.Find("NoteCube 24"); objectList = new List <GameObject>();; bms = gameObject.AddComponent <Bms>(); BmsLoad(); }
private void OnLoaded(object sender, RoutedEventArgs e) { try { string text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\JAudio Player"; string path = text + "\\Z2Sound.dat"; string soundPath = string.Empty; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } if (File.Exists(path)) { StreamReader streamReader = new StreamReader(new FileStream(path, FileMode.Open)); soundPath = streamReader.ReadLine(); streamReader.Dispose(); } else { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.Description = "Select the path that contains 'Z2Sound.baa' and the subdirectory 'Waves'."; folderBrowserDialog.ShowNewFolderButton = false; if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamWriter streamWriter = new StreamWriter(new FileStream(path, FileMode.Create)); streamWriter.WriteLine(folderBrowserDialog.SelectedPath); streamWriter.Dispose(); soundPath = folderBrowserDialog.SelectedPath; } else { System.Windows.Application.Current.Shutdown(); } } playback = new Playback(soundPath); if (Environment.GetCommandLineArgs().Length > 1) { base.Title = Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[1]) + " - JAudio Player"; Bms sequence = new Bms(File.OpenRead(Environment.GetCommandLineArgs()[1])); playback.Sequence = sequence; Playback_Start(null, null); } } catch (SharpDXException) { System.Windows.MessageBox.Show("Could not initialize the audio interface.", "Load sequence", MessageBoxButton.OK, MessageBoxImage.Hand); } catch (Exception ex2) { System.Windows.MessageBox.Show(ex2.Message, "Load sequence", MessageBoxButton.OK, MessageBoxImage.Hand); } }
private void Awake() { TextAsset ta = Resources.Load("test") as TextAsset; lineData = ta.text.Split('\n'); //lineData = File.ReadAllLines("Assets/Resources/Lovely_Summer.txt"); bmsLoader = GameObject.Find("BmsLoader").GetComponent <BmsParser>(); beatCreator = GameObject.Find("BeatCreator").GetComponent <BeatCreator>(); bms = bmsLoader.getBms(); comboText.fontSize = 40; scoreText.fontSize = 40; }
void setVariables() { if (gameManager == null) { gameManager = FindObjectOfType <GameManager>(); } if (node_top == null) { node_top = GameObject.Find("node_top"); } if (Note135 == null) { Note135 = node_top; } if (Note24 == null) { Note24 = node_top; } if (objectList == null) { objectList = new List <GameObject>(); } if (bms == null) { bms = gameObject.AddComponent <Bms>(); } if (theAudio == null) { theAudio = AudioManager.instance; } }
private void Awake() { bms = gameObject.GetComponent <Bms>(); beatCreator = GameObject.Find("BeatCreator").GetComponent <BeatCreator>(); }
private void BmsLoad() { bms = gameObject.AddComponent <Bms>(); string[] lineData = System.IO.File.ReadAllLines("Assets/BmsFiles/BS_5a.bms"); //File.ReadAllLines(Application.dataPath + "/BmsFiles/" + bmsFileName); foreach (string line in lineData) { if (line.StartsWith("#")) { string[] data = line.Split(' '); // 데이터 섹션이 아니면서 헤더 데이터가 없는 경우에는 건너 뜀. if (data[0].IndexOf(":") == -1 && data.Length == 1) { continue; } // 헤더 섹션 if (data[0].Equals("#TITLE")) { bms.setTitle(data[1]); } else if (data[0].Equals("#ARTIST")) { bms.setArtist(data[1]); } else if (data[0].Equals("#BPM")) { bms.setBpm(double.Parse(data[1])); } else if (data[0].Equals("#PLAYER")) { } else if (data[0].Equals("#GENRE")) { } else if (data[0].Equals("#PLAYLEVEL")) { } else if (data[0].Equals("#RANK")) { } else if (data[0].Equals("#TOTAL")) { } else if (data[0].Equals("#VOLWAV")) { } else if (data[0].Equals("#MIDIFILE")) { } else if (data[0].Equals("#WAV")) { } else if (data[0].Equals("#BMP")) { } else if (data[0].Equals("#STAGEFILE")) { } else if (data[0].Equals("#VIDEOFILE")) { } else if (data[0].Equals("#BGA")) { } else if (data[0].Equals("#STOP")) { } else if (data[0].Equals("#LNTYPE")) { bms.setLnType(int.Parse(data[1])); } else if (data[0].Equals("#LNOBJ")) { } else { // 위의 경우에 모두 해당하지 않을 경우, 데이터 섹션 int bar = 0; Int32.TryParse(data[0].Substring(1, 3), out bar); int channel = 0; Int32.TryParse(data[0].Substring(4, 2), out channel); string noteStr = data[0].Substring(7); List <int> noteData = getNoteDataOfStr(noteStr); Note note = gameObject.AddComponent <Note>(); note.setBar(bar); note.setChannel(channel); note.setNoteData(noteData); // note.debug(); bms.addNote(note); } } } if (bms.getNoteList().Count != 0) { isFinishLoad = true; } }
public void BmsLoad(string musicName) { setVariables(); bmsFileName = musicName + ".bms"; //string[] lineData = File.ReadAllLines(pathForFiles("axion.bms")); W = 40; bms = gameObject.AddComponent <Bms>(); TextAsset dddata = (TextAsset)Resources.Load("BMS/" + musicName, typeof(TextAsset)); StringReader sr = new StringReader(dddata.text); string line = sr.ReadLine(); while (line != null) { //Debug.Log(line); if (line.StartsWith("#")) { string[] data = line.Split(' '); // exception if (data[0].IndexOf(":") == -1 && data.Length == 1) { continue; } // header field if (data[0].Equals("#TITLE")) { bms.setTitle(data[1]); } else if (data[0].Equals("#ARTIST")) { bms.setArtist(data[1]); } else if (data[0].Equals("#BPM")) { bms.setBpm(double.Parse(data[1])); noteSpeed = W / (4.0f / (float)bms.getBpm() * 60); } else if (data[0].Equals("#PLAYER")) { } else if (data[0].Equals("#GENRE")) { } else if (data[0].Equals("#PLAYLEVEL")) { } else if (data[0].Equals("#RANK")) { } else if (data[0].Equals("#TOTAL")) { } else if (data[0].Equals("#VOLWAV")) { } else if (data[0].Equals("#MIDIFILE")) { } else if (data[0].Equals("#WAV01")) { }// else if (data[0].Equals("#WAV02")) { }// else if (data[0].Equals("#BMP01")) { }// else if (data[0].Equals("#STAGEFILE")) { } else if (data[0].Equals("#VIDEOFILE")) { } else if (data[0].Equals("#BGA")) { } else if (data[0].Equals("#STOP")) { } else if (data[0].Equals("#LNTYPE")) { bms.setLnType(int.Parse(data[1])); } else if (data[0].Equals("#LNOBJ")) { } else if (data[0].Contains("#WAV")) { } else { // data field int bar = 0; // node key Int32.TryParse(data[0].Substring(1, 3), out bar); int channel = 0; // node channel Int32.TryParse(data[0].Substring(4, 2), out channel); string noteStr = data[0].Substring(7); List <int> noteData = getNoteDataOfStr(noteStr); Note note = gameObject.AddComponent <Note>(); note.setBar(bar); note.setChannel(channel); note.setNoteData(noteData); //note.debug(); bms.addNote(note); isFinishLoad = true; } } line = line = sr.ReadLine(); } //string[] lineData = File.ReadAllLines(pathForFiles(bmsFileName)); //foreach (string line in lineData) //{ // //Debug.Log(line); // if (line.StartsWith("#")) // { // string[] data = line.Split(' '); // // exception // if (data[0].IndexOf(":") == -1 && data.Length == 1) // { // continue; // } // // header field // if (data[0].Equals("#TITLE")) // { // bms.setTitle(data[1]); // } // else if (data[0].Equals("#ARTIST")) // { // bms.setArtist(data[1]); // } // else if (data[0].Equals("#BPM")) // { // bms.setBpm(double.Parse(data[1])); // noteSpeed = W / (4.0f / (float)bms.getBpm() * 60); // } // else if (data[0].Equals("#PLAYER")) // { // } // else if (data[0].Equals("#GENRE")) // { // } // else if (data[0].Equals("#PLAYLEVEL")) // { // } // else if (data[0].Equals("#RANK")) // { // } // else if (data[0].Equals("#TOTAL")) // { // } // else if (data[0].Equals("#VOLWAV")) // { // } // else if (data[0].Equals("#MIDIFILE")) // { // } // else if (data[0].Equals("#WAV01")) // { // }// // else if (data[0].Equals("#WAV02")) // { // }// // else if (data[0].Equals("#BMP01")) // { // }// // else if (data[0].Equals("#STAGEFILE")) // { // } // else if (data[0].Equals("#VIDEOFILE")) // { // } // else if (data[0].Equals("#BGA")) // { // } // else if (data[0].Equals("#STOP")) // { // } // else if (data[0].Equals("#LNTYPE")) // { // bms.setLnType(int.Parse(data[1])); // } // else if (data[0].Equals("#LNOBJ")) // { // } // else if (data[0].Contains("#WAV")) // { // } // else // { // // data field // int bar = 0; // node key // Int32.TryParse(data[0].Substring(1, 3), out bar); // int channel = 0; // node channel // Int32.TryParse(data[0].Substring(4, 2), out channel); // string noteStr = data[0].Substring(7); // List<int> noteData = getNoteDataOfStr(noteStr); // Note note = gameObject.AddComponent<Note>(); // note.setBar(bar); // note.setChannel(channel); // note.setNoteData(noteData); // //note.debug(); // bms.addNote(note); // isFinishLoad = true; // } // } //} if (isFinishLoad) { float musicStartTimeBias = 0; float time_delay = 3.0f; if (gameManager == null) { gameManager = FindObjectOfType <GameManager>(); } float bias = gameManager.getMusicBias(musicName); float biasByTimeDelay = time_delay * noteSpeed; foreach (Note note in bms.getNoteList()) { int noteNum = note.noteData.Count; int cnt = 0; foreach (int i in note.noteData) { if (i == 1) { switch (note.channel) { case 11: GameObject r1 = Instantiate(Note135); r1.transform.localPosition = new Vector3(-10, -15, biasByTimeDelay + bias + (note.bar * W) + (W / noteNum * cnt)); objectList.Add(r1); break; case 12: GameObject r2 = Instantiate(Note24); r2.transform.localPosition = new Vector3(-5, -15, biasByTimeDelay + bias + (note.bar * W) + (W / noteNum * cnt)); objectList.Add(r2); break; case 13: GameObject r3 = Instantiate(Note135); r3.transform.localPosition = new Vector3(0, -15, biasByTimeDelay + bias + (note.bar * W) + (W / noteNum * cnt)); objectList.Add(r3); break; case 14: GameObject r4 = Instantiate(Note24); r4.transform.localPosition = new Vector3(5, -15, biasByTimeDelay + bias + (note.bar * W) + (W / noteNum * cnt)); objectList.Add(r4); break; case 15: GameObject r5 = Instantiate(Note135); r5.transform.localPosition = new Vector3(10, -15, biasByTimeDelay + bias + (note.bar * W) + (W / noteNum * cnt)); objectList.Add(r5); break; } } else if (i == 2) { float musicStartBias = (note.bar * W) + (W / noteNum * cnt); musicStartTimeBias = musicStartBias / noteSpeed; } cnt++; } } theAudio.playBGMWithDelay(musicName, musicStartTimeBias + time_delay); } }
public void BmsLoad(string[] lineData) { Debug.Log("----BmsLoader:BmsLoad()----"); bms = gameObject.AddComponent <Bms>(); BarData barData; foreach (string line in lineData) { if (line.StartsWith("#")) { string[] data = line.Split(' '); if (data[0].IndexOf(":") == -1 && data.Length == 1) { continue; } if (data[0].Equals("#TITLE")) { bms.setTitle(data[1]); } else if (data[0].Equals("#ARTIST")) { bms.setArtist(data[1]); } else if (data[0].Equals("#BPM")) { bms.setBpm(double.Parse(data[1])); } else if (data[0].Equals("#PLAYER")) { } else if (data[0].Equals("#GENRE")) { } else if (data[0].Equals("#PLAYLEVEL")) { } else if (data[0].Equals("#RANK")) { } else if (data[0].Equals("#TOTAL")) { } else if (data[0].Equals("#VOLWAV")) { } else if (data[0].Equals("#MIDIFILE")) { } else if (data[0].Substring(0, 4).Equals("#WAV")) { } else if (data[0].Equals("#BMP")) { } else if (data[0].Equals("#STAGEFILE")) { } else if (data[0].Equals("#VIDEOFILE")) { } else if (data[0].Equals("#BGA")) { } else if (data[0].Equals("#STOP")) { } else if (data[0].Equals("#LNTYPE")) { bms.setLnType(int.Parse(data[1])); } else if (data[0].Equals("#LNOBJ")) { } else if (data[0].IndexOf(":") != -1) { int bar = 0; int channel = 0; Int32.TryParse(data[0].Trim().Substring(1, 3), out bar); Int32.TryParse(data[0].Trim().Substring(4, 2), out channel); string noteStr = data[0].Trim().Substring(7); List <Dictionary <int, float> > noteData = getNoteDataOfStr(noteStr, bar, bms.getBpm()); // create note data barData = gameObject.AddComponent <BarData>(); barData.setBar(bar); barData.setChannel(channel); barData.setNoteDataList(noteData); bms.addBarData(barData); } } } if (bms.getBarDataList().Count != 0) { isFinishLoad = true; } }
private void BmsLoad() { //bmsFileName = "MINO - anacne.bms"; W = 40; bms = gameObject.AddComponent <Bms>(); string[] lineData = File.ReadAllLines(pathForFiles(bmsFileName)); foreach (string line in lineData) { //Debug.Log(line); if (line.StartsWith("#")) { string[] data = line.Split(' '); // exception if (data[0].IndexOf(":") == -1 && data.Length == 1) { continue; } // header field if (data[0].Equals("#TITLE")) { bms.setTitle(data[1]); } else if (data[0].Equals("#ARTIST")) { bms.setArtist(data[1]); } else if (data[0].Equals("#BPM")) { bms.setBpm(double.Parse(data[1])); } else if (data[0].Equals("#PLAYER")) { } else if (data[0].Equals("#GENRE")) { } else if (data[0].Equals("#PLAYLEVEL")) { } else if (data[0].Equals("#RANK")) { } else if (data[0].Equals("#TOTAL")) { } else if (data[0].Equals("#VOLWAV")) { } else if (data[0].Equals("#MIDIFILE")) { } else if (data[0].Equals("#WAV02")) { }// else if (data[0].Equals("#BMP01")) { }// else if (data[0].Equals("#STAGEFILE")) { } else if (data[0].Equals("#VIDEOFILE")) { } else if (data[0].Equals("#BGA")) { } else if (data[0].Equals("#STOP")) { } else if (data[0].Equals("#LNTYPE")) { bms.setLnType(int.Parse(data[1])); } else if (data[0].Equals("#LNOBJ")) { } else { // data field int bar = 0; // node key Int32.TryParse(data[0].Substring(1, 3), out bar); int channel = 0; // node channel Int32.TryParse(data[0].Substring(4, 2), out channel); string noteStr = data[0].Substring(7); List <int> noteData = getNoteDataOfStr(noteStr); Note note = gameObject.AddComponent <Note>(); note.setBar(bar); note.setChannel(channel); note.setNoteData(noteData); //note.debug(); bms.addNote(note); isFinishLoad = true; } } } if (isFinishLoad) { foreach (Note note in bms.getNoteList()) { switch (note.channel) { case 11: int cnt = 0; switch (note.noteData.Count) { case 1: GameObject r_1 = Instantiate(Note135); r_1.transform.position = new Vector3(-10, -15, 30 + note.bar * W); objectList.Add(r_1); break; case 2: foreach (int i in note.noteData) { if (i == 1) { GameObject r_2 = Instantiate(Note135); r_2.transform.position = new Vector3(-10, -15, 30 + (note.bar * W) + (W / 8 * cnt)); objectList.Add(r_2); } cnt += 4; } break; case 4: foreach (int i in note.noteData) { if (i == 1) { GameObject r_4 = Instantiate(Note135); r_4.transform.position = new Vector3(-10, -15, 30 + (note.bar * W) + (W / 8 * cnt)); objectList.Add(r_4); } cnt += 2; } break; case 8: foreach (int i in note.noteData) { if (i == 1) { GameObject r_8 = Instantiate(Note135); r_8.transform.position = new Vector3(-10, -15, 30 + (note.bar * W) + (W / 8 * cnt)); objectList.Add(r_8); } cnt += 1; } break; } break; case 12: int cnt2 = 0; switch (note.noteData.Count) { case 1: GameObject g_1 = Instantiate(Note24); g_1.transform.position = new Vector3(-5, -15, 30 + note.bar * W); objectList.Add(g_1); break; case 2: foreach (int i in note.noteData) { if (i == 1) { GameObject g_2 = Instantiate(Note24); g_2.transform.position = new Vector3(-5, -15, 30 + (note.bar * W) + (W / 8 * cnt2)); objectList.Add(g_2); } cnt2 += 4; } break; case 4: foreach (int i in note.noteData) { if (i == 1) { GameObject g_4 = Instantiate(Note24); g_4.transform.position = new Vector3(-5, -15, 30 + (note.bar * W) + (W / 8 * cnt2)); objectList.Add(g_4); } cnt2 += 2; } break; case 8: foreach (int i in note.noteData) { if (i == 1) { GameObject g_8 = Instantiate(Note24); g_8.transform.position = new Vector3(-5, -15, 30 + (note.bar * W) + (W / 8 * cnt2)); objectList.Add(g_8); } cnt2 += 1; } break; } break; case 13: int cnt3 = 0; switch (note.noteData.Count) { case 1: GameObject g_1 = Instantiate(Note135); g_1.transform.position = new Vector3(0, -15, 30 + note.bar * W); objectList.Add(g_1); break; case 2: foreach (int i in note.noteData) { if (i == 1) { GameObject g_2 = Instantiate(Note135); g_2.transform.position = new Vector3(0, -15, 30 + (note.bar * W) + (W / 8 * cnt3)); objectList.Add(g_2); } cnt3 += 4; } break; case 4: foreach (int i in note.noteData) { if (i == 1) { GameObject g_4 = Instantiate(Note135); g_4.transform.position = new Vector3(0, -15, 30 + (note.bar * W) + (W / 8 * cnt3)); objectList.Add(g_4); } cnt3 += 2; } break; case 8: foreach (int i in note.noteData) { if (i == 1) { GameObject g_8 = Instantiate(Note135); g_8.transform.position = new Vector3(0, -15, 30 + (note.bar * W) + (W / 8 * cnt3)); objectList.Add(g_8); } cnt3 += 1; } break; } break; case 14: int cnt4 = 0; switch (note.noteData.Count) { case 1: GameObject g_1 = Instantiate(Note24); g_1.transform.position = new Vector3(5, -15, 30 + note.bar * W); objectList.Add(g_1); break; case 2: foreach (int i in note.noteData) { if (i == 1) { GameObject g_2 = Instantiate(Note24); g_2.transform.position = new Vector3(5, -15, 30 + (note.bar * W) + (W / 8 * cnt4)); objectList.Add(g_2); } cnt4 += 4; } break; case 4: foreach (int i in note.noteData) { if (i == 1) { GameObject g_4 = Instantiate(Note24); g_4.transform.position = new Vector3(5, -15, 30 + (note.bar * W) + (W / 8 * cnt4)); objectList.Add(g_4); } cnt4 += 2; } break; case 8: foreach (int i in note.noteData) { if (i == 1) { GameObject g_8 = Instantiate(Note24); g_8.transform.position = new Vector3(5, -15, 30 + (note.bar * W) + (W / 8 * cnt4)); objectList.Add(g_8); } cnt4 += 1; } break; } break; case 15: int cnt5 = 0; switch (note.noteData.Count) { case 1: GameObject g_1 = Instantiate(Note135); g_1.transform.position = new Vector3(10, -15, 30 + note.bar * W); objectList.Add(g_1); break; case 2: foreach (int i in note.noteData) { if (i == 1) { GameObject g_2 = Instantiate(Note135); g_2.transform.position = new Vector3(10, -15, 30 + (note.bar * W) + (W / 8 * cnt5)); objectList.Add(g_2); } cnt5 += 4; } break; case 4: foreach (int i in note.noteData) { if (i == 1) { GameObject g_4 = Instantiate(Note135); g_4.transform.position = new Vector3(10, -15, 30 + (note.bar * W) + (W / 8 * cnt5)); objectList.Add(g_4); } cnt5 += 2; } break; case 8: foreach (int i in note.noteData) { if (i == 1) { GameObject g_8 = Instantiate(Note135); g_8.transform.position = new Vector3(10, -15, 30 + (note.bar * W) + (W / 8 * cnt5)); objectList.Add(g_8); } cnt5 += 1; } break; } break; } } } }
//IEnumerator Start () { void Start() { Debug.Log("----GameManager:Start()----"); keyDictionary = new Dictionary <KeyCode, Action> { { KeyCode.LeftArrow, KeyL }, { KeyCode.RightArrow, KeyR } }; cube1 = GameObject.Find("Cube_1"); cube2 = GameObject.Find("Cube_2"); cube3 = GameObject.Find("Cube_3"); cube4 = GameObject.Find("Cube_4"); cube5 = GameObject.Find("Cube_5"); cc1 = (Cube_sc)cube1.GetComponent(typeof(Cube_sc)); cc2 = (Cube_sc)cube2.GetComponent(typeof(Cube_sc)); cc3 = (Cube_sc)cube3.GetComponent(typeof(Cube_sc)); cc4 = (Cube_sc)cube4.GetComponent(typeof(Cube_sc)); cc5 = (Cube_sc)cube5.GetComponent(typeof(Cube_sc)); cur = 3; Key3(); // bms file string[] lineData = File.ReadAllLines("Assets/Resources/BmsFiles/Lovely_Summer.bms"); // bms file parsing BmsLoader_sc bmsLoader = GameObject.Find("BmsLoader").GetComponent <BmsLoader_sc>(); bmsLoader.BmsLoad(lineData); Bms bms = bmsLoader.getBms(); // get y position of start line GameObject plane_Top = GameObject.Find("Plane_Top"); float startPositionY = plane_Top.transform.position.y; // get y position of judgment line GameObject lineJudgment = GameObject.Find("LineJudgment"); float judgmentPositionY = lineJudgment.transform.position.y; // get center line GameObject lineCenter = GameObject.Find("LineCenter"); // set y position of destroying note float destroyDelayPositionY = 35f; // distance between top line to judgment line // set width rate of note float noteWidthRate = 1.8f; List <NoteObj_sc> noteObj_Line_1 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_2 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_3 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_4 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_5 = new List <NoteObj_sc>(); List <NoteObj_sc> bar_Line = new List <NoteObj_sc>(); bool isLongNoteStart_1 = true; bool isLongNoteStart_2 = true; bool isLongNoteStart_3 = true; bool isLongNoteStart_4 = true; bool isLongNoteStart_5 = true; float preNoteTime_Ln1 = 0f; float preNoteTime_Ln2 = 0f; float preNoteTime_Ln3 = 0f; float preNoteTime_Ln4 = 0f; float preNoteTime_Ln5 = 0f; float destroyDelayTime = bms.getTotalPlayTime() + 1; float secondPerBar = 60.0f / (float)bms.getBpm() * 4.0f; // seconds per bar int barCount = 0; // create bars for (int i = 0; i < bms.totalBarCount; i++) { float barTime = barCount * secondPerBar; note = (GameObject)Instantiate(barPrefab, new Vector3(0, startPositionY, 0), Quaternion.identity); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.speed = defaultSpeed; note_sc.destroyPositionY = startPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = barTime; note_sc.channel = 0; bar_Line.Add(note_sc); barCount++; } // create notes foreach (BarData barData in bms.getBarDataList()) { int channel = barData.getChannel(); float linePositionX = lineCenter.transform.position.x; if (channel == 11 || channel == 51) { linePositionX = lineCenter.transform.position.x - 2; } else if (channel == 12 || channel == 52) { linePositionX = lineCenter.transform.position.x - 1; } else if (channel == 13 || channel == 53) { linePositionX = lineCenter.transform.position.x; } else if (channel == 14 || channel == 54) { linePositionX = lineCenter.transform.position.x + 1; } else if (channel == 15 || channel == 55) { linePositionX = lineCenter.transform.position.x + 2; } bool isLongChannel = false; if (channel == 51 || channel == 52 || channel == 53 || channel == 54 || channel == 55) { isLongChannel = true; } foreach (Dictionary <int, float> noteData in barData.getNoteDataList()) { foreach (int key in noteData.Keys) { // for normal notes if (isLongChannel == false && key != 0 && channel != 16) { float noteTime = noteData[key]; note = (GameObject)Instantiate(notePrefab, new Vector3(linePositionX * noteWidthRate, startPositionY, 0), Quaternion.identity); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.speed = defaultSpeed; note_sc.destroyPositionY = startPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = noteTime; note_sc.channel = channel; if (channel == 11) { noteObj_Line_1.Add(note_sc); } else if (channel == 12) { noteObj_Line_2.Add(note_sc); } else if (channel == 13) { noteObj_Line_3.Add(note_sc); } else if (channel == 14) { noteObj_Line_4.Add(note_sc); } else if (channel == 15) { noteObj_Line_5.Add(note_sc); } } // for long notes if (isLongChannel == true && key != 0) { float secondPerBeat = 60.0f / (float)bms.getBpm() * 4.0f / beatPerBar; // seconds per beat float longHeightRate = 0f; bool isLongNoteStart = false; if (channel == 51) { isLongNoteStart = isLongNoteStart_1; } else if (channel == 52) { isLongNoteStart = isLongNoteStart_2; } else if (channel == 53) { isLongNoteStart = isLongNoteStart_3; } else if (channel == 54) { isLongNoteStart = isLongNoteStart_4; } else if (channel == 55) { isLongNoteStart = isLongNoteStart_5; } if (isLongNoteStart == true) { if (channel == 51) { preNoteTime_Ln1 = noteData[key]; isLongNoteStart_1 = false; } else if (channel == 52) { preNoteTime_Ln2 = noteData[key]; isLongNoteStart_2 = false; } else if (channel == 53) { preNoteTime_Ln3 = noteData[key]; isLongNoteStart_3 = false; } else if (channel == 54) { preNoteTime_Ln4 = noteData[key]; isLongNoteStart_4 = false; } else if (channel == 55) { preNoteTime_Ln5 = noteData[key]; isLongNoteStart_5 = false; } } else if (isLongNoteStart == false) { float noteTime = noteData[key]; float preNoteTime_Ln = 0f; if (channel == 51) { preNoteTime_Ln = preNoteTime_Ln1; } else if (channel == 52) { preNoteTime_Ln = preNoteTime_Ln2; } else if (channel == 53) { preNoteTime_Ln = preNoteTime_Ln3; } else if (channel == 54) { preNoteTime_Ln = preNoteTime_Ln4; } else if (channel == 55) { preNoteTime_Ln = preNoteTime_Ln5; } longHeightRate = (noteTime - preNoteTime_Ln) / secondPerBeat; note = (GameObject)Instantiate(notePrefab, new Vector3(linePositionX * noteWidthRate, startPositionY, 0), Quaternion.identity); float originalScaleX = note.transform.localScale.x; float originalScaleY = note.transform.localScale.y; float originalScaleZ = note.transform.localScale.z; note.transform.localScale = new Vector3(originalScaleX, originalScaleY + originalScaleY * Mathf.Round(longHeightRate), originalScaleZ); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.destroyPositionY = startPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = preNoteTime_Ln; note_sc.channel = channel; if (channel == 51) { noteObj_Line_1.Add(note_sc); preNoteTime_Ln1 = 0; isLongNoteStart_1 = true; } else if (channel == 52) { noteObj_Line_2.Add(note_sc); preNoteTime_Ln2 = 0; isLongNoteStart_2 = true; } else if (channel == 53) { noteObj_Line_3.Add(note_sc); preNoteTime_Ln3 = 0; isLongNoteStart_3 = true; } else if (channel == 54) { noteObj_Line_4.Add(note_sc); preNoteTime_Ln4 = 0; isLongNoteStart_4 = true; } else if (channel == 55) { noteObj_Line_5.Add(note_sc); preNoteTime_Ln5 = 0; isLongNoteStart_5 = true; } } } } } } noteObj_Line_1.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_2.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_3.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_4.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_5.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); bar_Line.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); Debug.Log("noteObj_Line_1 = " + noteObj_Line_1.Count); Debug.Log("noteObj_Line_2 = " + noteObj_Line_2.Count); Debug.Log("noteObj_Line_3 = " + noteObj_Line_3.Count); Debug.Log("noteObj_Line_4 = " + noteObj_Line_4.Count); Debug.Log("noteObj_Line_5 = " + noteObj_Line_5.Count); Debug.Log("bar_Line = " + bar_Line.Count); // setup for the creation of beats BeatCreator_sc beatCreator = GameObject.Find("BeatCreator").GetComponent <BeatCreator_sc>(); beatCreator.noteObj_Line_1 = noteObj_Line_1; beatCreator.noteObj_Line_2 = noteObj_Line_2; beatCreator.noteObj_Line_3 = noteObj_Line_3; beatCreator.noteObj_Line_4 = noteObj_Line_4; beatCreator.noteObj_Line_5 = noteObj_Line_5; beatCreator.bar_Line = bar_Line; beatCreator.bpm = (float)bms.getBpm(); beatCreator.beatPerBar = beatPerBar; beatCreator.timeRateBySpeed = timeRateBySpeed; //AudioClip bgm = Resources.Load("Sound/" + bmsName) as AudioClip; //beatCreator.bgmSound = bgm; beatCreator.isTic = isTic; //yield return new WaitForEndOfFrame(); // wait for a frame is ready beatCreator.isStart = true; // start beat creation }
// Use this for initialization IEnumerator Start() { // 화면 비율. //Screen.SetResolution(Screen.width * 16 / 9, Screen.width, true); // bms 파일 로드. //string[] lineData = File.ReadAllLines(Application.dataPath + "/BmsFiles/" + "test.bms"); //string[] lineData2 = File.ReadAllLines("Assets/Resources/BmsFiles/" + "test.bms"); // BMS 파일 찾기. TextAsset ta = Resources.Load("BmsFiles/" + bmsName) as TextAsset; string strData = "" + ta.text; string[] lineData = strData.Split('\n'); // BMS 노트데이터 파싱. BmsLoader_sc bmsLoader = GameObject.Find("BmsLoader").GetComponent <BmsLoader_sc>(); bmsLoader.BmsLoad(lineData); Bms bms = bmsLoader.getBms(); // 시작선. GameObject plane_Top = GameObject.Find("Plane_Top"); float startPositionY = plane_Top.transform.position.y; // 판정선. GameObject lineJudgment = GameObject.Find("LineJudgment"); float judgmentPositionY = lineJudgment.transform.position.y; // 시작선 ~ 판정선 거리. //print(Vector3.Distance(plane_Top.transform.position, lineJudgment.transform.position)); //float distance = 17.81831f; // 노트 라인. GameObject lineCenter = GameObject.Find("LineCenter"); // 노트 소멸 위치. float destroyDelayPositionY = 30.0f; // 노트 간격 비율. float noteWidthRate = 1.8f; // 노트 프리팹 생성 및 리스트 저장. List <NoteObj_sc> noteObj_Line_1 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_2 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_3 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_4 = new List <NoteObj_sc>(); List <NoteObj_sc> noteObj_Line_5 = new List <NoteObj_sc>(); List <NoteObj_sc> bar_Line = new List <NoteObj_sc>(); bool isLongNoteStart_1 = true; bool isLongNoteStart_2 = true; bool isLongNoteStart_3 = true; bool isLongNoteStart_4 = true; bool isLongNoteStart_5 = true; float preNoteTime_Ln1 = 0f; float preNoteTime_Ln2 = 0f; float preNoteTime_Ln3 = 0f; float preNoteTime_Ln4 = 0f; float preNoteTime_Ln5 = 0f; // 노트 소멸 딜레이 타임. float destroyDelayTime = bms.getTotalPlayTime() + 1; // Bar 생성. float secondPerBar = 60.0f / (float)bms.getBpm() * 4.0f; // Bar 당 시간(초). int barCount = 0; for (int i = 0; i < bms.totalBarCount; i++) { // barLine 생성 float barTime = barCount * secondPerBar; // Bar 시작시간 note = (GameObject)Instantiate(barPrefab, new Vector3(0, startPositionY, 0), Quaternion.identity); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.speed = defaultSpeed; note_sc.destroyPositionY = judgmentPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = barTime; bar_Line.Add(note_sc); barCount++; } // 노트 생성. foreach (BarData barData in bms.getBarDataList()) { float linePositionX = lineCenter.transform.position.x; bool isLongChannel = false; int channel = barData.getChannel(); if (channel == 11 || channel == 51) { linePositionX = lineCenter.transform.position.x - 2; } else if (channel == 12 || channel == 52) { linePositionX = lineCenter.transform.position.x - 1; } else if (channel == 13 || channel == 53) { linePositionX = lineCenter.transform.position.x; } else if (channel == 14 || channel == 54) { linePositionX = lineCenter.transform.position.x + 1; } else if (channel == 15 || channel == 55) { linePositionX = lineCenter.transform.position.x + 2; } if (channel == 51 || channel == 52 || channel == 53 || channel == 54 || channel == 55) { isLongChannel = true; } foreach (Dictionary <int, float> noteData in barData.getNoteDataList()) { foreach (int key in noteData.Keys) { // 단노트. if (isLongChannel == false && key != 0 && channel != 16) { float noteTime = noteData[key]; note = (GameObject)Instantiate(notePrefab, new Vector3(linePositionX * noteWidthRate, startPositionY, 0), Quaternion.identity); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.speed = defaultSpeed; note_sc.destroyPositionY = judgmentPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = noteTime; note_sc.channel = channel; if (channel == 11) { note_sc.particleName = "particle/Effect1"; noteObj_Line_1.Add(note_sc); } else if (channel == 12) { noteObj_Line_2.Add(note_sc); } else if (channel == 13) { noteObj_Line_3.Add(note_sc); } else if (channel == 14) { noteObj_Line_4.Add(note_sc); } else if (channel == 15) { noteObj_Line_5.Add(note_sc); } } // 롱노트. if (isLongChannel == true && key != 0) { float secondPerBeat = 60.0f / (float)bms.getBpm() * 4.0f / beatPerBar; // Beat당 시간(초) float longHeightRate = 0f; // 롱노트 높이 배율. bool isLongNoteStart = false; if (channel == 51) { isLongNoteStart = isLongNoteStart_1; } else if (channel == 52) { isLongNoteStart = isLongNoteStart_2; } else if (channel == 53) { isLongNoteStart = isLongNoteStart_3; } else if (channel == 54) { isLongNoteStart = isLongNoteStart_4; } else if (channel == 55) { isLongNoteStart = isLongNoteStart_5; } if (isLongNoteStart == true) { if (channel == 51) { preNoteTime_Ln1 = noteData[key]; isLongNoteStart_1 = false; } else if (channel == 52) { preNoteTime_Ln2 = noteData[key]; isLongNoteStart_2 = false; } else if (channel == 53) { preNoteTime_Ln3 = noteData[key]; isLongNoteStart_3 = false; } else if (channel == 54) { preNoteTime_Ln4 = noteData[key]; isLongNoteStart_4 = false; } else if (channel == 55) { preNoteTime_Ln5 = noteData[key]; isLongNoteStart_5 = false; } } else if (isLongNoteStart == false) { float noteTime = noteData[key]; float preNoteTime_Ln = 0f; if (channel == 51) { preNoteTime_Ln = preNoteTime_Ln1; } else if (channel == 52) { preNoteTime_Ln = preNoteTime_Ln2; } else if (channel == 53) { preNoteTime_Ln = preNoteTime_Ln3; } else if (channel == 54) { preNoteTime_Ln = preNoteTime_Ln4; } else if (channel == 55) { preNoteTime_Ln = preNoteTime_Ln5; } longHeightRate = (noteTime - preNoteTime_Ln) / secondPerBeat; //print("preNoteTime_Ln = " + preNoteTime_Ln); //print("noteTime = " + noteTime); //print("longHeightRate = " + Mathf.Round(longHeightRate)); note = (GameObject)Instantiate(notePrefab, new Vector3(linePositionX * noteWidthRate, startPositionY, 0), Quaternion.identity); float originalScaleX = note.transform.localScale.x; float originalScaleY = note.transform.localScale.y; float originalScaleZ = note.transform.localScale.z; note.transform.localScale = new Vector3(originalScaleX, originalScaleY * Mathf.Round(longHeightRate) + originalScaleY, originalScaleZ); note_sc = note.GetComponent <NoteObj_sc>(); note_sc.destroyPositionY = judgmentPositionY - destroyDelayPositionY; note_sc.destroyDelayTime = destroyDelayTime; note_sc.noteTime = preNoteTime_Ln; if (channel == 51) { noteObj_Line_1.Add(note_sc); preNoteTime_Ln1 = 0; isLongNoteStart_1 = true; } else if (channel == 52) { noteObj_Line_2.Add(note_sc); preNoteTime_Ln2 = 0; isLongNoteStart_2 = true; } else if (channel == 53) { noteObj_Line_3.Add(note_sc); preNoteTime_Ln3 = 0; isLongNoteStart_3 = true; } else if (channel == 54) { noteObj_Line_4.Add(note_sc); preNoteTime_Ln4 = 0; isLongNoteStart_4 = true; } else if (channel == 55) { noteObj_Line_5.Add(note_sc); preNoteTime_Ln5 = 0; isLongNoteStart_5 = true; } } } } } } noteObj_Line_1.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_2.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_3.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_4.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); noteObj_Line_5.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); bar_Line.Sort(delegate(NoteObj_sc a, NoteObj_sc b) { return(a.noteTime.CompareTo(b.noteTime)); }); // 비트 크리에이터. BeatCreator_sc beatCreator = GameObject.Find("BeatCreator").GetComponent <BeatCreator_sc>(); beatCreator.noteObj_Line_1 = noteObj_Line_1; beatCreator.noteObj_Line_2 = noteObj_Line_2; beatCreator.noteObj_Line_3 = noteObj_Line_3; beatCreator.noteObj_Line_4 = noteObj_Line_4; beatCreator.noteObj_Line_5 = noteObj_Line_5; beatCreator.bar_Line = bar_Line; beatCreator.bpm = (float)bms.getBpm(); beatCreator.beatPerBar = beatPerBar; beatCreator.timeRateBySpeed = timeRateBySpeed; AudioClip bgm = Resources.Load("Sound/" + bmsName) as AudioClip; beatCreator.bgmSound = bgm; beatCreator.isTic = isTic; // 모든 렌더링작업이 끝날 때까지 대기 yield return(new WaitForEndOfFrame()); beatCreator.isStart = true; // 시작 }