// 코루틴 사용 IEnumerator AwaitMakeNote2(List <Note2> notes2) { if (notes2.Count == 0) { yield break; } for (int i = 0; i < notes2.Count; i++) { // Debug.Log("AwaitMakeNote2"); Note2 note2 = notes2[i]; int noteType = note2.noteType; float noteTiming = note2.order; while (true) { float currentTiming = GameManager.instance.audioSource.time; // Debug.Log(currentTiming); if (noteTiming > currentTiming - 0.05f && noteTiming < currentTiming + 0.05f) { // Debug.Log(noteTiming); MakeNote2(note2); break; } yield return(new WaitForSeconds(0.05f)); } } //int noteType = note.noteType; //float order = note.order; //// 1초 기다린 후에 아래 내용을 실행해라 //yield return new WaitForSeconds(startPoint + order * beatInterval); //MakeNote2(note); }
private void _ctxAddNote_Click(object sender, EventArgs e) { Note2 note = new Note2(); note.Name = "<н¨>"; Program.CurrentDoc.AddNote(note); RefreshTree(""); SelectTreeNodeByNote(note); FormAction.Instance.OnStateChanged(); }
private void SelectTreeNodeByNote(Note2 note) { foreach (TreeNode node in _tree.Nodes) { if (node.Tag == note) { _tree.SelectedNode = node; return; } } }
void MakeNote2(Note2 note) { GameObject obj = noteObjectPooler.getObject(note.noteType); // 설정된 시작 라인으로 노트를 이동시킨다. x = obj.transform.position.x; z = obj.transform.position.z; startY = YLocation(PlayerInformation.selectLevel); // Y축만 바꿔서 올려준다. obj.transform.position = new Vector3(x, startY, z); obj.GetComponent <NormalNoteBehavior>().Initialize(); obj.SetActive(true); // 보여줌 }
private void IterateDoc1Group(SecurityCenterDocument2 doc2, NoteGroup clearGroup) { foreach (Note note in clearGroup.GetNotes()) { Note2 note2 = new Note2(); note2.Name = note.Name; note2.Notes = note.Text; note2.Tags = clearGroup.Name == "<default>" ? "" : clearGroup.Name; doc2.AddNote(note2); } foreach (NoteGroup subGroup in clearGroup.GetGroups()) { IterateDoc1Group(doc2, subGroup); } }
private void _ctxDelete_Click(object sender, EventArgs e) { if (_tree.SelectedNode != null) { Note2 note = _tree.SelectedNode.Tag as Note2; if (note != null) { Program.CurrentDoc.RemoveNote(note); FormAction.Instance.OnStateChanged(); RefreshTree(""); _txtName.Text = ""; _txtNotes.Text = ""; _txtTags.Text = ""; } } }
public void Save(SecurityCenterDocument2 doc2, string file, string password) { SecurityCenterDocument2 encryptedDoc2 = new SecurityCenterDocument2(); encryptedDoc2.LastUpdatedDate = DateTime.Now; encryptedDoc2.Schema = doc2.Schema; encryptedDoc2.Security.Hash = Hash(password); foreach (Note2 note2 in doc2.Notes) { Note2 encryptedNote = new Note2(); encryptedNote.Name = Encrypt(password, note2.Name); encryptedNote.Notes = Encrypt(password, note2.Notes); encryptedNote.Tags = Encrypt(password, note2.Tags); encryptedDoc2.AddNote(encryptedNote); } using (FileStream fs = new FileStream(file, FileMode.Create)) { XmlSerializer ser = new XmlSerializer(typeof (SecurityCenterDocument2)); ser.Serialize(fs, encryptedDoc2); } }
private void _tree_AfterSelect(object sender, TreeViewEventArgs e) { _txtName.TextChanged -= OnTextChanged; _txtNotes.TextChanged -= OnTextChanged; _txtTags.TextChanged -= OnTextChanged; Note2 note = e.Node.Tag as Note2; if (note == null) { return; } _bindingNote.DataSource = note; _txtName.TextChanged += OnTextChanged; _txtNotes.TextChanged += OnTextChanged; _txtTags.TextChanged += OnTextChanged; }
public SecurityCenterDocument2 Load(string file, string password) { SecurityCenterDocument2 encryptedDoc2; using (FileStream fs = new FileStream(file, FileMode.Open)) { XmlSerializer ser = new XmlSerializer(typeof(SecurityCenterDocument2)); encryptedDoc2 = ser.Deserialize(fs) as SecurityCenterDocument2; } if (encryptedDoc2 == null) { return null; } if (Hash(password) != encryptedDoc2.Security.Hash) { throw new WrongPasswordException(); } SecurityCenterDocument2 doc2 = new SecurityCenterDocument2(); doc2.LastUpdatedDate = encryptedDoc2.LastUpdatedDate; doc2.Schema = encryptedDoc2.Schema; foreach (Note2 encryptedNote in encryptedDoc2.Notes) { Note2 note = new Note2(); note.Name = Decrypt(password, encryptedNote.Name); note.Notes = Decrypt(password, encryptedNote.Notes); note.Tags = Decrypt(password, encryptedNote.Tags); doc2.AddNote(note); } return doc2; }
// Start is called before the first frame update void Start() { startY = YLocation(PlayerInformation.selectLevel); noteObjectPooler = gameObject.GetComponent <ObjectPooler>(); // 초기화 // 텍스트에서 비트정보를 읽는다 TextAsset textAsset = Resources.Load <TextAsset>("Beats/" + PlayerInformation.selectedMusic); StreamReader reader; // textAsset을 얻지 못하면 사용자가 추가하거나 다운 받은것이므로 내부폴더에서 가져온다. if (textAsset == null) { Debug.Log("textAsset is Null"); string txtFilePath = Application.persistentDataPath + Path.DirectorySeparatorChar + "beats" + Path.DirectorySeparatorChar + PlayerInformation.selectedMusic + ".txt"; reader = new StreamReader(txtFilePath); } else { // StringReader reader = new StringReader(textAsset.text); // Resources에 있는 txt파일을 streamReader로 읽기 위해서는 MemoryStream을 이용한다. MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(textAsset.text)); reader = new StreamReader(ms); } // 첫번째 적힌 곡 이름을 읽는다 musicTitle = reader.ReadLine(); Debug.Log(musicTitle); // 두번째 아티스트를 읽는다 musicArtist = reader.ReadLine(); Debug.Log(musicArtist); // 세번째 줄에 적힌 비트 정보를 읽는다 string beatInformation = reader.ReadLine(); bpm = Convert.ToInt32(beatInformation.Split(' ')[0]); divider = Convert.ToInt32(beatInformation.Split(' ')[1]); startPoint = (float)Convert.ToDouble(beatInformation.Split(' ')[2]); // 1초마다 떨어지는 비트 개수 // 만약 txt 파일의 divider 값이 크면 1초에 생성되는 노트수가 // 적어진다. beatCount = (float)bpm / divider; // 비트가 떨어지는 간격을 계산한다.(노트사이의 간격 시간임) beatInterval = 1 / beatCount; // 각 비트들이 떨어지는 위치 및 시간정보(4번째 줄부터) string line; //while ((line = reader.ReadLine()) != null) //{ // // 노트를 생성 // // 먼저 떨어지는 노트의 인덱스를 구하고 // // 언제 떨어지는 구해서 매개변수로 전달 // Note note = new Note( // Convert.ToInt32(line.Split(' ')[0]) + 1, // Convert.ToInt32(line.Split(' ')[1]) // ); // notes.Add(note); //} while ((line = reader.ReadLine()) != null) { // 노트를 생성 // 먼저 떨어지는 노트의 인덱스를 구하고 // 언제 떨어지는 구해서 매개변수로 전달 Note2 note = new Note2( Convert.ToInt32(line.Split(' ')[0]) + 1, Convert.ToSingle(line.Split(' ')[1]) ); notes2.Add(note); } // 모든 노트를 정해진 시간에 출발하도록 // 코루틴으로 //for (int i = 0; i <notes.Count; i++) //{ // StartCoroutine(AwaitMakeNote(notes[i])); //} // 모든 노트를 정해진 시간에 출발하도록 // 코루틴으로 //for (int i = 0; i < notes2.Count; i++) //{ // StartCoroutine(AwaitMakeNote(notes[i])); //} StartCoroutine(StartMakeNote(notes2)); // 마지막 노트를 기준으로 게임 종료 함수를 부른다. StartCoroutine(AwaitGameResult2(notes2[notes2.Count - 1].order)); }