Пример #1
0
        public void Launch(NotesManager notesManager, NoteData noteData)
        {
            this.manager = notesManager;
            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(0, this.y, this.transform.position.z);
            this.transform.eulerAngles = new Vector3(this.angle, 0.0f, 0.0f);
        }
 public void DestroyNote(NoteData data)
 {
     foreach (NoteData note in this.notes)
     {
         if (note.index == data.index)
         {
             Transform childTransform = this.notesParent.transform;
             foreach (Transform child in childTransform.transform)
             {
                 NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData();
                 if (childData.index == note.index)
                 {
                     Destroy(child.gameObject);
                     break;
                 }
             }
             notes.Remove(note);
             break;
         }
     }
 }
        // Update is called once per frame
        void Update()
        {
            List <int> launchedNotes = new List <int>();

            Transform childTransform = this.notesParent.transform;

            foreach (Transform child in childTransform.transform)
            {
                NoteData data = child.gameObject.GetComponent <Notes>().GetNoteData();
                launchedNotes.Add(data.index);
            }

            if (launchedNotes.Count == 0)
            {
                float nextTime = Mathf.Ceil(this.soundManager.time / (60f / this.soundManager.BPM * 4)) * (60f / this.soundManager.BPM * 4);
                this.notes.Add(new NoteData(this.count, nextTime));
                this.count++;
            }

            for (int i = 0; i < this.notes.Count; i++)
            {
                NoteData note = this.notes[i];

                if (this.soundManager.time >= note.time - this.speed && this.soundManager.time <= note.time + this.afterTime)
                {
                    for (int j = 0; j < launchedNotes.Count; j++)
                    {
                        if (note.index == launchedNotes[j])
                        {
                            launchedNotes.Remove(launchedNotes[j]);
                            goto ThroughProcess;
                        }
                    }

                    LaunchNotes(note);
                }

                ThroughProcess :;
            }
        }