/// <summary> /// 롱 노트 /// </summary> /// <param name="fileName"></param> /// <returns></returns> string readStringFromFile_long(string fileName, int sTime) { TextAsset textAsset = Resources.Load(fileName) as TextAsset; string str = textAsset.text; char sp = ','; string[] spString = str.Split(sp); LONGNOTE note = new LONGNOTE(0, Vector2.zero, 0, 0, 0); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 6 == 0) { if (sTime == 0) { note.sTime = (int)numFloat; } else if (((int)numFloat) == sTime) { i += 5; return(str); } } else if (i % 6 == 1) { note.sPos.x = numFloat; } else if (i % 6 == 2) { note.sPos.y = numFloat; } else if (i % 6 == 3) { note.eTime = (int)numFloat; } else if (i % 6 == 4) { note.moveType = (int)numFloat; } else if (i % 6 == 5) { note.childs = (int)numFloat; _longNoteList.Add(note); } } return(str); }
/// <summary> /// 롱 노트 /// </summary> /// <param name="fileName"></param> /// <returns></returns> string readStringFromFile_long(string fileName) { string path = pathForDocuments(fileName); if (File.Exists(path)) { // 파일 일기 FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(file); string str = null; str = sr.ReadToEnd(); // 단어 분리 char sp = ','; string[] spString = str.Split(sp); LONGNOTE note = new LONGNOTE(0, Vector2.zero, 0, 0, 0); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 6 == 0) { note.sTime = (int)numFloat; } else if (i % 6 == 1) { note.sPos.x = numFloat; } else if (i % 6 == 2) { note.sPos.y = numFloat; } else if (i % 6 == 3) { note.eTime = (int)numFloat; } else if (i % 6 == 4) { note.moveType = (int)numFloat; } else if (i % 6 == 5) { note.childs = (int)numFloat; _longNoteList.Add(note); } } sr.Close(); file.Close(); return(str); } else { return(null); } }
public void initData(LONGNOTE baseData) { myData = baseData; //_myChilds.Add(myData.ePos); switch (myData.moveType) { case 0: moveX = 0; moveY = 0.02f; break; case 1: moveX = 0.0066f; moveY = 0.0166f; break; case 2: moveX = 0.0166f; moveY = 0.0066f; break; case 3: moveX = 0.02f; moveY = 0; break; case 4: moveX = 0.0166f; moveY = -0.0066f; break; case 5: moveX = 0.0066f; moveY = -0.0166f; break; case 6: moveX = 0; moveY = -0.02f; break; case 7: moveX = -0.0066f; moveY = -0.0166f; break; case 8: moveX = -0.0166f; moveY = -0.0066f; break; case 9: moveX = -0.02f; moveY = 0; break; case 10: moveX = -0.0166f; moveY = 0.0066f; break; case 11: moveX = -0.0066f; moveY = 0.0166f; break; } ePos.x = moveX * myData.eTime * 30 * 0.75f; // 1 * 5 * 30 == 150 ePos.y = moveY * myData.eTime * 30 * 0.75f; GameObject a = Instantiate(dot, ePos, Quaternion.identity) as GameObject; a.transform.parent = transform; a.transform.localPosition = ePos; myBar = Instantiate(bar, a.transform.position, Quaternion.identity) as GameObject; myBar.transform.parent = a.transform; myBar.transform.localScale = new Vector3(0.3f * myData.eTime * 0.75f, 1, 0); //myBar.transform.localScale -= new Vector3(0.064f, 0, 0); myBar.transform.Rotate(new Vector3(0, 0, (Mathf.Atan2(ePos.y, ePos.x) * Mathf.Rad2Deg + 180) % 360)); }
public void longNoteClick(int sTime) { // NOTE CLICK Debug.Log("Note Erase"); swLongNote.Close(); // 지금 까지 한것을 저장 // 그리고 다시 읽기 TextAsset textAsset = Resources.Load("Data/Level" + Singleton.getInstance.level + "/LongNote/song" + Singleton.getInstance.songNum) as TextAsset; string str = textAsset.text; char sp = ','; string[] spString = str.Split(sp); LONGNOTE note = new LONGNOTE(0, Vector2.zero, 0, 0, 0); // 다시 쓰기 path = pathForDocuments("Assets/Resources/Data/Level" + Singleton.getInstance.level + "/LongNote" + "/song" + Singleton.getInstance.songNum + ".txt"); file = new FileStream(path, FileMode.Create, FileAccess.Write); swLongNote = new StreamWriter(file); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 6 == 0) { if (((int)numFloat) == sTime) { note.sTime = -1; i += 5; break; } else { note.sTime = (int)numFloat; } } else if (i % 6 == 1) { note.sPos.x = numFloat; } else if (i % 6 == 2) { note.sPos.y = numFloat; } else if (i % 6 == 3) { note.eTime = (int)numFloat; } else if (i % 6 == 4) { note.moveType = (int)numFloat; } else if (i % 6 == 5) { note.childs = (int)numFloat; swLongNote.WriteLine(note.sTime + ", " + note.sPos.x + ", " + note.sPos.y + ", " + note.eTime + ", " + note.moveType + ", " + note.childs + ", "); } } }
public void initData(LONGNOTE baseData) { myData = baseData; //_myChilds.Add(myData.ePos); int angle = 0; switch (myData.moveType) { case 0: moveX = 0; moveY = 0.02f; break; case 1: moveX = 0.0066f; moveY = 0.0166f; break; case 2: moveX = 0.0166f; moveY = 0.0066f; break; case 3: moveX = 0.02f; moveY = 0; break; case 4: moveX = 0.0166f; moveY = -0.0066f; break; case 5: moveX = 0.0066f; moveY = -0.0166f; break; case 6: moveX = 0; moveY = -0.02f; break; case 7: moveX = -0.0066f; moveY = -0.0166f; break; case 8: moveX = -0.0166f; moveY = -0.0066f; break; case 9: moveX = -0.02f; moveY = 0; break; case 10: moveX = -0.0166f; moveY = 0.0066f; break; case 11: moveX = -0.0066f; moveY = 0.0166f; break; } Vector2 ePos; ePos.x = moveX * myData.eTime * 30 * 0.75f; // 1 * 5 * 30 == 150 ePos.y = moveY * myData.eTime * 30 * 0.75f; GameObject a = Instantiate(dot, ePos, Quaternion.identity) as GameObject; a.transform.parent = transform; a.transform.localPosition = ePos; myBar = Instantiate(bar, a.transform.position, Quaternion.identity) as GameObject; myBar.transform.parent = a.transform; myBar.transform.localScale = new Vector3(0.3f * myData.eTime * 0.75f, 1, 0); myBar.transform.Rotate(new Vector3(0, 0, (Mathf.Atan2(ePos.y, ePos.x) * Mathf.Rad2Deg + 180) % 360)); }