public void linkNoteClick(int sTime) { // NOTE CLICK Debug.Log("Note Erase"); swLinkNote.Close(); // 지금 까지 한것을 저장 // 그리고 다시 읽기 TextAsset textAsset = Resources.Load("Data/Level" + Singleton.getInstance.level + "/LinkNote/song" + Singleton.getInstance.songNum) as TextAsset; string str = textAsset.text; char sp = ','; string[] spString = str.Split(sp); LINKNOTE note = new LINKNOTE(0, Vector2.zero, 0, 0); // 다시 쓰기 path = pathForDocuments("Assets/Resources/Data/Level" + Singleton.getInstance.level + "/LinkNote" + "/song" + Singleton.getInstance.songNum + ".txt"); file = new FileStream(path, FileMode.Create, FileAccess.Write); swLinkNote = new StreamWriter(file); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 5 == 0) { if (((int)numFloat) == sTime) { note.sTime = -1; i += 4; break; } else { note.sTime = (int)numFloat; } } else if (i % 5 == 1) { note.sPos.x = numFloat; } else if (i % 5 == 2) { note.sPos.y = numFloat; } else if (i % 5 == 3) { note.eTime = (int)numFloat; } else if (i % 5 == 4) { note.angle = numFloat; swLinkNote.WriteLine(note.sTime + ", " + note.sPos.x + ", " + note.sPos.y + ", " + note.eTime + ", " + note.angle + ", "); } } }
public void initData(LINKNOTE baseData) { myData = baseData; link.transform.localScale = new Vector3(myData.eTime * 0.08f, 1, 0); link.transform.localScale -= new Vector3(0.064f, 0, 0); link.transform.Rotate(new Vector3(0, 0, myData.angle)); }
/// <summary> /// 연결 노트 /// </summary> /// <param name="fileName"></param> /// <returns></returns> string readStringFromFile_link(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); LINKNOTE note = new LINKNOTE(0, Vector2.zero, 0, 0); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 5 == 0) { note.sTime = (int)numFloat; } else if (i % 5 == 1) { note.sPos.x = numFloat; } else if (i % 5 == 2) { note.sPos.y = numFloat; } else if (i % 5 == 3) { note.eTime = (int)numFloat; } else if (i % 5 == 4) { note.angle = numFloat; _linkNoteList.Add(note); } } sr.Close(); file.Close(); return(str); } else { return(null); } }
/// <summary> /// 연결 노트 /// </summary> /// <param name="fileName"></param> /// <returns></returns> string readStringFromFile_link(string fileName, int sTime) { TextAsset textAsset = Resources.Load(fileName) as TextAsset; string str = textAsset.text; char sp = ','; string[] spString = str.Split(sp); LINKNOTE note = new LINKNOTE(0, Vector2.zero, 0, 0); for (int i = 0; i < spString.Length - 1; i++) { // string을 float형으로 변환 float numFloat = System.Convert.ToSingle(spString[i]); if (i % 5 == 0) { if (sTime == 0) { note.sTime = (int)numFloat; } else if (((int)numFloat) == sTime) { i += 4; return(str); } } else if (i % 5 == 1) { note.sPos.x = numFloat; } else if (i % 5 == 2) { note.sPos.y = numFloat; } else if (i % 5 == 3) { note.eTime = (int)numFloat; } else if (i % 5 == 4) { note.angle = numFloat; _linkNoteList.Add(note); } } return(str); }
public void initData(LINKNOTE baseData) { myData = baseData; link.transform.localScale = new Vector3(myData.eTime * 0.08f, 1, 0); link.transform.localScale -= new Vector3(0.064f, 0, 0); link.transform.Rotate(new Vector3(0, 0, myData.angle)); }