Example #1
0
        /// if left/right mouse click are pressed, adds or removes an editor note, respectively.
        public void SetEditorNotes(Instrument instrumentIN)
        {
            if (Input.GetKeyDown("mouse 0"))
            {
                /// remove notes if needed
                EditorNote noteToRemove = mNoteToggler.GetEditorNoteToRemove();
                if (noteToRemove != null)
                {
                    RemoveNote(noteToRemove);
                    return;
                }

                mNoteToggler.CheckRaycast();
                int note     = 0;
                int timestep = 0;

                Vector2 pos    = new Vector2(0, 0);
                bool    isOver = false;
                for (int i = 0; i < mHoverObjects.Count; i++)
                {
                    if (mHoverObjects[i].isOver)
                    {
                        pos.y  = mStaffLines[i].transform.position.y;
                        note   = i;
                        isOver = true;
                    }
                }

                if (isOver == false)
                {
                    return;
                }

                float   nearest  = 100000;
                Vector2 mousePos = Input.mousePosition;
                for (int j = 0; j < mMeasureEditor.mCurrentInstSet.mTimeSignature.mStepsPerMeasure; j++)
                {
                    Vector2 screenPos = RectTransformUtility.WorldToScreenPoint(Camera.main, mBarLines[j].position);
                    float   dist      = Mathf.Abs(mousePos.x - screenPos.x);
                    if (dist < nearest)
                    {
                        nearest  = dist;
                        pos.x    = mBarLines[j].position.x;
                        timestep = j;
                    }
                }

                if (instrumentIN.AddClipNote(timestep, note, mMeasureEditor.mCurrentMeasure.value))
                {
                    mPlacedEditorNotes[mCurrentPlacedEditorNote].transform.position = pos;
                    mPlacedEditorNotes[mCurrentPlacedEditorNote].mBaseImage.color   = mColors[(int)instrumentIN.mData.mStaffPlayerColor];
                    mPlacedEditorNotes[mCurrentPlacedEditorNote].index = new Vector2(timestep, note);
                    IncreaseCurrentNoteCount(ref mCurrentPlacedEditorNote, mMaxPlayedNotes);
                    mMeasureEditor.UIToggleAllInstruments();
                }
            }
        }
Example #2
0
        public void RemoveNote(EditorNote note)
        {
            Instrument instrument = mInstrumentPanel.mInstrument;

            if (instrument.RemoveClipNote((int)note.index.x, (int)note.index.y, mMeasureEditor.mCurrentMeasure.value))
            {
                note.transform.position = new Vector2(-10000, -10000);
                note.gameObject.SetActive(false);
                mMeasureEditor.UIToggleAllInstruments(true);
            }
        }