Beispiel #1
0
    //-----------------------------------------------------------------
    //! @summary   ドラッグ時の移動処理
    //!
    //! @parameter [void] なし
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    public void OnMouseDrag()
    {
        // マウス座標の取得
        Vector2 localPoint = Vector2.zero;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(m_musicalScoreTransform, Input.mousePosition, m_canvas.worldCamera, out localPoint);

        float  minDistance = float.MaxValue;
        string scale       = m_noteList[0].m_scale;
        // ワールド座標のマウス座標を取得する
        Vector3 mousePosition = Input.mousePosition;

        mousePosition.z = 10.0f;
        Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);

        // 最も近い音階を調べる
        foreach (KeyValuePair <string, RectTransform> n in m_keyDictionary)
        {
            // コンポーネントの取得
            RectTransform keyTransform = n.Value;

            // 距離を求める
            float distance = Mathf.Abs(worldPosition.x - keyTransform.position.x);

            // 最も近いキーを調べる
            if (minDistance >= distance)
            {
                // 最短距離を更新
                minDistance = distance;
                // 音階を更新する
                scale = n.Key;
            }
        }

        // ノーツの移動
        MoveEditNotes(scale, localPoint.y);

        // ノーツ情報をUIへ反映させる
        if (m_connectNoteSheetController != null)
        {
            m_connectNoteSheetController.DisplayNotes(this);
        }
    }
Beispiel #2
0
    //-----------------------------------------------------------------
    //! @summary   選択されているノーツを設定する
    //!
    //! @parameter [selectNotes] 設定するノーツ
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    public void SetSelectNotes(GameObject selectNotes)
    {
        if (selectNotes != null)
        {
            // Ctrlキーが押されている
            if (Input.GetKey(KeyCode.LeftControl))
            {
                // 登録されているか調べる
                int index = m_selectNotes.IndexOf(selectNotes);

                // 登録されていない場合
                if (index < 0)
                {
                    // 選択されているノーツを追加する
                    m_selectNotes.Add(selectNotes);

                    // 光彩を付ける
                    if (selectNotes.GetComponent <EditNotesController>())
                    {
                        selectNotes.GetComponent <EditNotesController>().SwitchGlow(true);
                    }
                }
                else
                {
                    // 選択リストから外す
                    m_selectNotes.RemoveAt(index);

                    // 選択されたノーツの光彩を切る
                    selectNotes.GetComponent <EditNotesController>().SwitchGlow(false);
                }
            }
            else
            {
                // 選択されている全ての光彩を切る
                if (m_selectNotes.Count != 0)
                {
                    foreach (GameObject note in m_selectNotes)
                    {
                        if (note.GetComponent <EditNotesController>())
                        {
                            note.GetComponent <EditNotesController>().SwitchGlow(false);
                        }
                        else
                        {
                            note.GetComponent <ConnectNoteController>().SwitchGlow(false);
                        }
                    }
                }

                // リストをクリアする
                m_selectNotes.Clear();

                // 選択されているノーツを追加する
                m_selectNotes.Add(selectNotes);

                // 光彩を付ける
                if (selectNotes.GetComponent <EditNotesController>())
                {
                    selectNotes.GetComponent <EditNotesController>().SwitchGlow(true);
                }
                else
                {
                    selectNotes.GetComponent <ConnectNoteController>().SwitchGlow(true);
                }
            }

            // シートの切り替え
            if (m_selectNotes.Count > 1)
            {
                // 複数選択のフラグを立てる
                m_multipleSelectFlag = true;

                // 連結ノーツシートを手前に持ってくる
                m_connectNoteSheetController.SetAsLastSibling();
            }
            else
            {
                if (m_selectNotes.Count == 0)
                {
                    // 複数選択のフラグを倒す
                    m_multipleSelectFlag = false;

                    // 連結ノーツシートを奥に持っていく
                    m_connectNoteSheetController.SetAsFirstSibling();
                }
                else
                {
                    if (m_selectNotes[0].GetComponent <EditNotesController>())
                    {
                        // 複数選択のフラグを倒す
                        m_multipleSelectFlag = false;

                        // 連結ノーツシートを奥に持っていく
                        m_connectNoteSheetController.SetAsFirstSibling();
                    }
                    else
                    {
                        // 複数選択のフラグを立てる
                        m_multipleSelectFlag = true;

                        // 連結ノーツシートを手前に持ってくる
                        m_connectNoteSheetController.SetAsLastSibling();
                    }
                }
            }

            // UIへ情報を反映させる
            if (selectNotes.GetComponent <EditNotesController>())
            {
                m_notesSheetController.DisplayNotes(selectNotes.GetComponent <EditNotesController>());
            }
            else
            {
                m_connectNoteSheetController.DisplayNotes(selectNotes.GetComponent <ConnectNoteController>());
            }
        }
        else
        {
            // 複数選択のフラグを倒す
            m_multipleSelectFlag = false;

            // 連結ノーツシートを奥に持っていく
            m_connectNoteSheetController.SetAsFirstSibling();

            // UIへ情報を反映させる
            m_notesSheetController.DisplayNotes(null);
            m_connectNoteSheetController.DisplayNotes(null);
        }

        // ソートする
        if (m_selectNotes.Count > 1)
        {
            m_selectNotes.Sort((a, b) =>
            {
                if (a.GetComponent <EditNotesController>())
                {
                    if (b.GetComponent <EditNotesController>())
                    {
                        if (a.GetComponent <EditNotesController>().GetNotesData().m_startBeat > b.GetComponent <EditNotesController>().GetNotesData().m_startBeat)
                        {
                            return(1);
                        }
                        else if (a.GetComponent <EditNotesController>().GetNotesData().m_startBeat < b.GetComponent <EditNotesController>().GetNotesData().m_startBeat)
                        {
                            return(-1);
                        }
                    }
                    else
                    {
                        if (a.GetComponent <EditNotesController>().GetNotesData().m_startBeat > b.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat)
                        {
                            return(1);
                        }
                        else if (a.GetComponent <EditNotesController>().GetNotesData().m_startBeat < b.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat)
                        {
                            return(-1);
                        }
                    }
                }
                else
                {
                    if (b.GetComponent <EditNotesController>())
                    {
                        if (a.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat > b.GetComponent <EditNotesController>().GetNotesData().m_startBeat)
                        {
                            return(1);
                        }
                        else if (a.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat < b.GetComponent <EditNotesController>().GetNotesData().m_startBeat)
                        {
                            return(-1);
                        }
                    }
                    else
                    {
                        if (a.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat > b.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat)
                        {
                            return(1);
                        }
                        else if (a.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat < b.GetComponent <ConnectNoteController>().GetNoteData().m_startBeat)
                        {
                            return(-1);
                        }
                    }
                }

                return(0);
            });
        }
    }