public void Launch(NotesManager notesManager, SoundManager soundManager, EditManager editManager, NoteData noteData) { this.manager = notesManager; this.soundManager = soundManager; this.editManager = editManager; this.data = noteData; this.y = this.manager.from + (this.manager.to - this.manager.from) * (this.CalcTime() / this.manager.speed); this.angle = this.manager.from_angle; this.transform.position = new Vector3(this.manager.lane_width * (this.data.lane - 3), this.y, this.transform.position.z); this.transform.eulerAngles = new Vector3(this.angle, 0.0f, 0.0f); }
public void OnPressed(byte lane) { if (this.notesSelectManager.GetMode() != (byte)NotesSelectManager.MODE.SLIDE) { return; } NoteData pressNote = new NoteData(notesManager.GetIndex(), lane, (byte)NoteData.NOTE.SLIDE_PRESS, soundManager.GetTime(), notesManager.GetIndex() + 1, -1); releaseNote = new NoteData(notesManager.GetIndex() + 1, lane, (byte)NoteData.NOTE.SLIDE_RELEASE, soundManager.GetTime() + 0.1f, -1, notesManager.GetIndex()); notesManager.AddNote(pressNote); notesManager.AddNote(releaseNote); }
public void Launch(int index, NotesManager notesManager, SoundManager soundManager, NoteData note1, NoteData note2) { this.index = index; this.manager = notesManager; this.soundManager = soundManager; this.note1 = note1; this.note2 = note2; float x = this.manager.lane_width * ((float)(this.note1.lane + this.note2.lane) / 2f - 3f); float y = this.manager.from + (this.manager.to - this.manager.from) * (this.CalcTime() / this.manager.speed); float scaleX = (this.manager.lane_width / 10) * Mathf.Abs(this.note1.lane - this.note2.lane); this.transform.position = new Vector3(x, y, this.transform.position.z); this.transform.localScale = new Vector3(scaleX, this.transform.localScale.y, this.transform.localScale.z); }
public void UpdateNotes(NoteData noteData) { Transform childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == noteData.index) { Destroy(child.gameObject); this.Update(); break; } } }
public void OnTaoped(int lane) { switch (this.notesSelectManager.GetMode()) { case (byte)NotesSelectManager.MODE.SINGLE: NoteData note = new NoteData(notesManager.GetIndex(), (byte)lane, (byte)NoteData.NOTE.SINGLE, soundManager.GetTime(), -1, -1); notesManager.AddNote(note); break; case (byte)NotesSelectManager.MODE.SLIDE: break; case (byte)NotesSelectManager.MODE.FLICK: note = new NoteData(notesManager.GetIndex(), (byte)lane, (byte)NoteData.NOTE.FLICK, soundManager.GetTime(), -1, -1); notesManager.AddNote(note); break; } }
public void Quantize(NoteData noteData) { for (int i = 0; i < notes.Count; i++) { if (notes[i].index == noteData.index) { if (quantize.isOn) { float time = noteData.time; float SPQ = (60f / soundManager.BPM) / 4; // second per quater time = (float)Math.Round(time / SPQ, MidpointRounding.AwayFromZero) * SPQ; noteData.time = time; } break; } } }
public void OnTapped(Vector3 point) { byte lane; if (point.x <= this.notesManager.lane_width * -3) { lane = 0; } else if (point.x >= this.notesManager.lane_width * 3) { lane = 6; } else { lane = (byte)(Math.Round(point.x / this.notesManager.lane_width, MidpointRounding.AwayFromZero) + 3); } switch (this.GetMode()) { case (byte)NotesSelectManager.MODE.SINGLE: float time = soundManager.GetTime() + (notesManager.to - point.y) / ((notesManager.to - notesManager.from) / notesManager.speed); notesManager.AddNote(new NoteData(notesManager.GetIndex(), lane, (byte)NoteData.NOTE.SINGLE, time, -1, -1)); break; case (byte)NotesSelectManager.MODE.SLIDE: time = soundManager.GetTime() + (notesManager.to - point.y) / ((notesManager.to - notesManager.from) / notesManager.speed); NoteData pressNote = new NoteData(notesManager.GetIndex(), lane, (byte)NoteData.NOTE.SLIDE_PRESS, time, notesManager.GetIndex() + 1, -1); NoteData releaseNote = new NoteData(notesManager.GetIndex() + 1, lane, (byte)NoteData.NOTE.SLIDE_RELEASE, time + 0.5f, -1, notesManager.GetIndex()); notesManager.AddNote(pressNote); notesManager.AddNote(releaseNote); break; case (byte)NotesSelectManager.MODE.SLIDE_VIA: break; case (byte)NotesSelectManager.MODE.FLICK: time = soundManager.GetTime() + (notesManager.to - point.y) / ((notesManager.to - notesManager.from) / notesManager.speed); notesManager.AddNote(new NoteData(notesManager.GetIndex(), lane, (byte)NoteData.NOTE.FLICK, time, -1, -1)); break; } }
// Update is called once per frame void Update() { if (!this.fromNote.isEnable || CalcTime() - (this.toNote.time - this.fromNote.time) >= this.manager.speed + this.manager.afterTime) { Destroy(this.gameObject); return; } if (this.fromNote != this.prevFromNote || this.toNote != this.prevToNote) { Mesh mesh = GetComponent <MeshFilter>().mesh; Vector3[] vertices = mesh.vertices; float PPS = (this.manager.to - this.manager.from) / this.manager.speed; vertices[0] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width - this.manager.lane_width / 2, -(this.toNote.time - this.fromNote.time) * PPS, 0f); vertices[3] = new Vector3(-this.manager.lane_width / 2, 0f, 0f); vertices[1] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width + this.manager.lane_width / 2, -(this.toNote.time - this.fromNote.time) * PPS, 0f); vertices[2] = new Vector3(this.manager.lane_width / 2, 0f, 0f); mesh.vertices = vertices; mesh.RecalculateBounds(); BoxCollider collider = GetComponent <BoxCollider>(); collider.center = new Vector3(this.manager.lane_width * ((this.toNote.lane - this.fromNote.lane + (this.toNote.lane - this.fromNote.lane > 0 ? 1 : (this.toNote.lane - this.fromNote.lane < 0 ? -1 : 0))) / 2), (this.toNote.time - this.fromNote.time) / 2 * (Mathf.Abs(this.manager.to - this.manager.from) / this.manager.speed), 0f); collider.size = new Vector3((Mathf.Abs(this.toNote.lane - this.fromNote.lane) + 1) * this.manager.lane_width, Mathf.Abs(this.toNote.time - this.fromNote.time) * (Mathf.Abs(this.manager.to - this.manager.from) / this.manager.speed), collider.size.z); this.prevFromNote = this.fromNote.Clone(); this.prevToNote = this.toNote.Clone(); } this.y = this.manager.from + (this.manager.to - this.manager.from) * (this.CalcTime() / this.manager.speed); this.transform.position = new Vector3(this.manager.lane_width * (this.fromNote.lane - 3), this.y, 0.0f); }
public void Save() { if (!Directory.Exists(this.dataDir + "/" + this.musicFileManager.GetFileName())) { Directory.CreateDirectory(this.dataDir + "/" + this.musicFileManager.GetFileName()); } try { //Encoding utf8Enc = new UTF8Encoding(true); FileStream fs = new FileStream(this.dataDir + "/" + this.musicFileManager.GetFileName() + "/" + this.musicFileManager.GetFileName() + "-" + difficultyManager.GetValue() + ".csv", FileMode.Create, FileAccess.Write); StreamWriter writer = new StreamWriter(fs); List <NoteData> notes = this.notesManager.GetNotesList(); for (int i = 0; i < notes.Count; i++) { NoteData note = notes[i]; writer.WriteLine(note.index.ToString() + "," + note.lane.ToString() + "," + note.type.ToString() + "," + note.time.ToString() + "," + note.chainBehind + "," + note.chainForward); } writer.Close(); fs.Close(); } catch (System.Exception e) { toast.Launch("Save Error: " + e.ToString()); return; } toast.Launch("Saved (" + this.dataDir + "/" + this.musicFileManager.GetFileName() + "/" + this.musicFileManager.GetFileName() + "-" + difficultyManager.GetValue() + ".csv)"); }
public void Launch(int index, NotesManager notesManager, SoundManager soundManager, NoteData fromNote, NoteData toNote) { this.index = index; this.manager = notesManager; this.soundManager = soundManager; this.fromNote = fromNote; this.toNote = toNote; this.y = this.manager.from; this.prevFromNote = this.fromNote.Clone(); this.prevToNote = this.toNote.Clone(); Mesh mesh = GetComponent <MeshFilter>().mesh; Vector3[] vertices = mesh.vertices; float PPS = (this.manager.to - this.manager.from) / this.manager.speed; vertices[0] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width - this.manager.lane_width / 2, -(this.toNote.time - this.fromNote.time) * PPS, 0f); vertices[3] = new Vector3(-this.manager.lane_width / 2, 0f, 0f); vertices[1] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width + this.manager.lane_width / 2, -(this.toNote.time - this.fromNote.time) * PPS, 0f); vertices[2] = new Vector3(this.manager.lane_width / 2, 0f, 0f); mesh.vertices = vertices; mesh.RecalculateBounds(); BoxCollider collider = GetComponent <BoxCollider>(); collider.center = new Vector3(this.manager.lane_width * ((this.toNote.lane - this.fromNote.lane - 1) / 2), (this.toNote.time - this.fromNote.time) / 2 * (Mathf.Abs(this.manager.to - this.manager.from) / this.manager.speed), 0f); collider.size = new Vector3((Mathf.Abs(this.toNote.lane - this.fromNote.lane) + 1) * this.manager.lane_width, Mathf.Abs(this.toNote.time - this.fromNote.time) * (Mathf.Abs(this.manager.to - this.manager.from) / this.manager.speed), collider.size.z); this.transform.position = new Vector3(this.manager.lane_width * (this.fromNote.lane - 3), this.y, 0.0f); }
private void DeleteRelatedNote(NoteData noteData) { for (int i = 0; i < notes.Count; i++) { if (this.notes[i].index == noteData.index) { NoteData deletedNote = this.notes[i]; this.notes[i].isEnable = false; this.notes.Remove(this.notes[i]); switch (noteData.type) { case (byte)NoteData.NOTE.SLIDE_PRESS: for (int j = 0; j < notes.Count; j++) { if (deletedNote.chainBehind == this.notes[j].index) { this.DeleteRelatedNote(this.notes[j]); break; } } Transform childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == deletedNote.index) { Destroy(child.gameObject); } } break; case (byte)NoteData.NOTE.SLIDE_VIA: for (int j = 0; j < notes.Count; j++) { if (deletedNote.chainBehind == this.notes[j].index || deletedNote.chainForward == this.notes[j].index) { this.DeleteRelatedNote(this.notes[j]); break; } } childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == deletedNote.index) { Destroy(child.gameObject); } } break; case (byte)NoteData.NOTE.SLIDE_RELEASE: for (int j = 0; j < notes.Count; j++) { if (deletedNote.chainForward == this.notes[j].index) { this.DeleteRelatedNote(this.notes[j]); break; } } childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == deletedNote.index) { Destroy(child.gameObject); } } break; case (byte)NoteData.NOTE.FLICK: if (noteData.chainForward != -1) { for (int j = 0; j < notes.Count; j++) { if (deletedNote.chainForward == this.notes[j].index) { this.DeleteRelatedNote(this.notes[j]); break; } } } childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == deletedNote.index) { Destroy(child.gameObject); } } break; default: childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); if (childData.index == deletedNote.index) { Destroy(child.gameObject); } } break; } break; } } }
// Update is called once per frame void Update() { List <int> launchedNotes = new List <int>(); List <SyncLine> launchedSyncLines = new List <SyncLine>(); Transform childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { NoteData data = child.gameObject.GetComponent <Notes>().GetNoteData(); launchedNotes.Add(data.index); } childTransform = this.syncLinesParent.transform; foreach (Transform child in childTransform.transform) { SyncLine line = child.gameObject.GetComponent <SyncLine>(); launchedSyncLines.Add(line); } for (int i = 0; i < this.notes.Count; i++) { NoteData note = this.notes[i]; if (this.soundManager.GetTime() >= note.time - this.speed && this.soundManager.GetTime() <= note.time + this.afterTime) { bool doDraw = true; foreach (SyncLine launchedLine in launchedSyncLines) { if (launchedLine.GetNoteData(true).index == note.index || launchedLine.GetNoteData(false).index == note.index) { doDraw = false; break; } } if (doDraw) { foreach (NoteData noteData in this.notes) { if (noteData.index == note.index) { continue; } if (Mathf.Abs(noteData.time - note.time) * 1000 < 1) { foreach (SyncLine launchedLine in launchedSyncLines) { if (launchedLine.GetNoteData(true).index == noteData.index || launchedLine.GetNoteData(false).index == noteData.index) { goto ExitProcess; } } SyncLine syncLine = Instantiate(syncLinesPrefab).gameObject.GetComponent <SyncLine>(); syncLine.transform.parent = syncLinesParent.transform; syncLine.Launch(note.index, this, this.soundManager, note, noteData); launchedSyncLines.Add(syncLine); } } ExitProcess :; } for (int j = 0; j < launchedNotes.Count; j++) { if (note.index == launchedNotes[j]) { launchedNotes.Remove(launchedNotes[j]); goto ThroughProcess; } } LaunchNotes(note); } ThroughProcess :; } childTransform = this.notesParent.transform; foreach (Transform child in childTransform.transform) { if (launchedNotes.Count == 0) { break; } NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData(); foreach (int index in launchedNotes) { if (childData.index == index) { Destroy(child.gameObject); launchedNotes.Remove(index); break; } } } }
void LaunchNotes(NoteData note) { List <int> launchedSlideLines = new List <int>(); Transform childTransform = this.slideLinesParent.transform; foreach (Transform child in childTransform.transform) { SlideLine line = child.gameObject.GetComponent <SlideLine>(); launchedSlideLines.Add(line.index); } bool doDraw; switch (note.type) { case (byte)NoteData.NOTE.SINGLE: Notes fromNote = Instantiate(singlenotesPrefab).gameObject.GetComponent <Notes>(); fromNote.transform.parent = notesParent.transform; fromNote.Launch(this, this.soundManager, this.editManager, note); break; case (byte)NoteData.NOTE.SLIDE_PRESS: fromNote = Instantiate(slidenotesPressPrefab).gameObject.GetComponent <Notes>(); fromNote.transform.parent = notesParent.transform; fromNote.Launch(this, this.soundManager, this.editManager, note); doDraw = true; for (int k = 0; k < launchedSlideLines.Count; k++) { if (note.index == launchedSlideLines[k]) { doDraw = false; } } if (doDraw) { for (int j = 0; j < this.notes.Count; j++) { if (note.chainBehind == notes[j].index) { SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>(); slideLine.transform.parent = slideLinesParent.transform; slideLine.Launch(note.index, this, this.soundManager, note, notes[j]); note.slideLine = slideLine; launchedSlideLines.Add(slideLine.index); break; } } } break; case (byte)NoteData.NOTE.SLIDE_VIA: fromNote = Instantiate(slidenotesViaPrefab).gameObject.GetComponent <Notes>(); fromNote.transform.parent = notesParent.transform; fromNote.Launch(this, this.soundManager, this.editManager, note); doDraw = true; for (int k = 0; k < launchedSlideLines.Count; k++) { if (note.index == launchedSlideLines[k]) { doDraw = false; } } if (doDraw) { for (int j = 0; j < this.notes.Count; j++) { if (note.chainBehind == notes[j].index) { SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>(); slideLine.transform.parent = slideLinesParent.transform; slideLine.Launch(note.index, this, this.soundManager, note, notes[j]); note.slideLine = slideLine; launchedSlideLines.Add(slideLine.index); break; } } } doDraw = true; for (int k = 0; k < launchedSlideLines.Count; k++) { if (note.chainForward == launchedSlideLines[k]) { doDraw = false; } } if (doDraw) { for (int j = 0; j < this.notes.Count; j++) { if (note.chainForward == notes[j].index) { SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>(); slideLine.transform.parent = slideLinesParent.transform; slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note); launchedSlideLines.Add(slideLine.index); break; } } } break; case (byte)NoteData.NOTE.SLIDE_RELEASE: fromNote = Instantiate(slidenotesReleasePrefab).gameObject.GetComponent <Notes>(); fromNote.transform.parent = notesParent.transform; fromNote.Launch(this, this.soundManager, this.editManager, note); doDraw = true; for (int k = 0; k < launchedSlideLines.Count; k++) { if (note.chainForward == launchedSlideLines[k]) { doDraw = false; } } if (doDraw) { for (int j = 0; j < this.notes.Count; j++) { if (note.chainForward == notes[j].index) { SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>(); slideLine.transform.parent = slideLinesParent.transform; slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note); launchedSlideLines.Add(slideLine.index); break; } } } break; case (byte)NoteData.NOTE.FLICK: fromNote = Instantiate(flicknotesPrefab).gameObject.GetComponent <Notes>(); fromNote.transform.parent = notesParent.transform; GameObject grandchild = fromNote.transform.Find("Wrap").transform.Find("Arrow").gameObject; grandchild.GetComponent <LookAtCamera>().targetCamera = mainCamera; fromNote.Launch(this, this.soundManager, this.editManager, note); if (note.chainForward != -1) { doDraw = true; for (int k = 0; k < launchedSlideLines.Count; k++) { if (note.chainForward == launchedSlideLines[k]) { doDraw = false; } } if (doDraw) { for (int j = 0; j < this.notes.Count; j++) { if (note.chainForward == notes[j].index) { SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>(); slideLine.transform.parent = slideLinesParent.transform; slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note); launchedSlideLines.Add(slideLine.index); break; } } } } break; } }