Beispiel #1
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの開始の拍数を設定する
    //!
    //! @parameter [startBeat] 設定する開始の拍数
    //-----------------------------------------------------------------
    public void SetStartBeat(float startBeat)
    {
        // 開始位置がマイナスだった場合は処理を終了する
        if (startBeat < 0.0f)
        {
            return;
        }

        // 差分を計算する
        float difference = startBeat - m_noteList[0].m_startBeat;

        // データを更新する
        foreach (PiarhythmDatas.NoteData noteData in m_noteList)
        {
            noteData.m_startBeat += difference;
        }

        // 位置の更新
        PiarhythmDatas.PositionData positionData = m_optionSheetController.ConvertToPositionData(m_noteList[0].m_startBeat, m_noteList[0].m_noteLength);
        m_transform.offsetMin = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);
        for (int i = 1; i < m_noteList.Count; ++i)
        {
            positionData = m_optionSheetController.ConvertToPositionData(m_noteList[i].m_startBeat, m_noteList[i].m_noteLength);
            Vector2 offsetMax = m_transform.offsetMax;
            offsetMax.y          += positionData.m_lenght;
            m_transform.offsetMax = offsetMax;
        }

        // UIを更新
        if (m_connectNoteSheetController)
        {
            m_connectNoteSheetController.DisplayNotes(this);
        }
    }
Beispiel #2
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの移動処理
    //!
    //! @parameter [scale] 音階
    //! @parameter [positionY] Y座標
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    private void MoveEditNotes(string scale, float positionY)
    {
        // ノーツの移動
        m_transform.localPosition = new Vector3(m_transform.localPosition.x, positionY, 0.0f);
        SetNotesScale(scale);

        // 移動制限
        Vector2 offsetMin = m_transform.offsetMin;

        if (offsetMin.y <= 0.0)
        {
            offsetMin.y = 0.0f;
        }
        m_transform.offsetMin = offsetMin;

        // 最新データの作成
        PiarhythmDatas.PositionData positionData = new PiarhythmDatas.PositionData();
        positionData.m_position = m_transform.offsetMin.y;
        positionData.m_lenght   = m_transform.sizeDelta.y;

        // データの更新
        PiarhythmDatas.NoteData notesData = m_optionSheetController.ConvertToNotesData(positionData);
        m_notesData.m_startBeat = notesData.m_startBeat;
        m_notesData.m_scale     = scale;

        // 位置調整
        positionData          = m_optionSheetController.ConvertToPositionData(m_notesData.m_startBeat, m_notesData.m_noteLength);
        m_transform.offsetMin = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);
    }
Beispiel #3
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの長さを設定する
    //!
    //! @parameter [lengthTime] 設定する長さ
    //-----------------------------------------------------------------
    public void SetNotesLengthTime(int lengthTime)
    {
        // データを更新する
        m_notesData.m_noteLength = lengthTime;

        // 長さの更新
        PiarhythmDatas.PositionData positionData = m_optionSheetController.ConvertToPositionData(m_notesData.m_startBeat, m_notesData.m_noteLength);
        m_transform.offsetMin = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);
    }
Beispiel #4
0
    // メンバ関数の定義 =====================================================
    #region 初期化処理
    //-----------------------------------------------------------------
    //! @summary   初期化処理
    //!
    //! @parameter [void] なし
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    private void Start()
    {
        // コンポーネントの取得
        m_transform = GetComponent <RectTransform>();
        m_image     = GetComponent <Image>();

        // 色の初期化
        // #の色を変化させる
        m_image.color = (m_noteData.m_scale.Contains("#"))
                        ? new UnityEngine.Color(m_noteData.m_color.r * PiarhythmDatas.SHARP_COLOR_PERCENTAGE, m_noteData.m_color.g * PiarhythmDatas.SHARP_COLOR_PERCENTAGE, m_noteData.m_color.b * PiarhythmDatas.SHARP_COLOR_PERCENTAGE, 1.0f)
                        : new UnityEngine.Color(m_noteData.m_color.r, m_noteData.m_color.g, m_noteData.m_color.b, 1.0f);

        // スケールの初期化
        m_transform.localScale = Vector3.one;

        // 音階の設定
        // 座標を設定された音階の位置に移動させる
        m_transform.position = new Vector3(m_keyDictionary[m_noteData.m_scale].position.x, m_transform.position.y, m_transform.position.z);

        float width = m_keyDictionary[m_noteData.m_scale].sizeDelta.x
                      * m_keyDictionary[m_noteData.m_scale].parent.GetComponent <RectTransform>().localScale.x;

        m_transform.sizeDelta = new Vector2(width, m_transform.sizeDelta.y);

        // 手前に持ってくる
        Vector3 position = m_transform.localPosition;

        position.z = 0.0f;
        m_transform.localPosition = position;

        // 開始時間と長さの初期化
        PiarhythmDatas.PositionData positionData = m_musicController.ConvertToPositionData(m_noteData.m_startBeat, m_noteData.m_noteLength);
        Vector2 offsetMin = m_transform.offsetMin;

        offsetMin.y           = positionData.m_position;
        m_transform.offsetMin = offsetMin;
        Vector2 offsetMax = m_transform.offsetMax;

        offsetMax.y           = offsetMin.y + positionData.m_lenght;
        m_transform.offsetMax = offsetMax;

        PiarhythmDatas.NoteData noteData = m_noteData.m_nextNoteData;
        while (noteData != null)
        {
            positionData          = m_musicController.ConvertToPositionData(noteData.m_startBeat, noteData.m_noteLength);
            offsetMax             = m_transform.offsetMax;
            offsetMax.y          += positionData.m_lenght;
            m_transform.offsetMax = offsetMax;

            noteData = noteData.m_nextNoteData;
        }
    }
Beispiel #5
0
    // メンバ関数の定義 =====================================================
    #region 初期化処理
    //-----------------------------------------------------------------
    //! @summary   初期化処理
    //!
    //! @parameter [void] なし
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    public void Initialize()
    {
        // コンポーネントの取得
        m_transform             = GetComponent <RectTransform>();
        m_glowImage             = GetComponent <GlowImage>();
        m_musicalScoreTransform = m_transform.parent.GetComponent <RectTransform>();
        m_audioSource           = GetComponent <AudioSource>();

        // データの初期化
        m_notesData = ScriptableObject.CreateInstance <PiarhythmDatas.NoteData>();

        // 色の初期化
        PiarhythmDatas.Color colorData = new PiarhythmDatas.Color();
        colorData.r         = Color.green.r;
        colorData.g         = Color.green.g;
        colorData.b         = Color.green.b;
        colorData.a         = Color.green.a;
        m_notesData.m_color = colorData;
        m_glowImage.color   = m_glowImage.glowColor = Color.green;

        // スケールの初期化
        m_transform.localScale = Vector3.one;

        // 音階の設定
        SetNotesScale("C4");

        // 手前に持ってくる
        Vector3 position = m_transform.localPosition;

        position.z = 0.0f;
        m_transform.localPosition = position;

        // 開始時間と長さの初期化
        PiarhythmDatas.PositionData positionData = new PiarhythmDatas.PositionData();
        positionData.m_position = m_transform.offsetMin.y;
        positionData.m_lenght   = m_transform.sizeDelta.y;
        PiarhythmDatas.NoteData notesData = m_optionSheetController.ConvertToNotesData(positionData);
        m_notesData.m_startBeat  = notesData.m_startBeat;
        m_notesData.m_noteLength = 2;
        positionData             = m_optionSheetController.ConvertToPositionData(m_notesData.m_startBeat, m_notesData.m_noteLength);
        m_transform.offsetMin    = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax    = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);

        // 光彩を切る
        m_glowImage.glowSize = 0.0f;
    }
Beispiel #6
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの開始時間を設定する
    //!
    //! @parameter [startTime] 設定する開始時間
    //-----------------------------------------------------------------
    public void SetNotesStartTime(float startTime)
    {
        // 開始位置がマイナスだった場合は処理を終了する
        if (startTime < 0.0f)
        {
            return;
        }

        // データを更新する
        m_notesData.m_startBeat = PiarhythmUtility.MRound(startTime, 0.25f);

        // 位置の更新
        PiarhythmDatas.PositionData positionData = m_optionSheetController.ConvertToPositionData(m_notesData.m_startBeat, m_notesData.m_noteLength);
        m_transform.offsetMin = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);

        // UIを更新
        m_notesSheetController.DisplayNotes(this);
    }
Beispiel #7
0
    // メンバ関数の定義 =====================================================
    #region 初期化処理
    //-----------------------------------------------------------------
    //! @summary   初期化処理
    //!
    //! @parameter [void] なし
    //!
    //! @return    なし
    //-----------------------------------------------------------------
    public void Initialize()
    {
        // コンポーネントの取得
        m_transform             = GetComponent <RectTransform>();
        m_glowImage             = GetComponent <GlowImage>();
        m_musicalScoreTransform = m_transform.parent.GetComponent <RectTransform>();
        m_audioSource           = GetComponent <AudioSource>();

        // 色の初期化
        UnityEngine.Color color = new UnityEngine.Color(m_noteList[0].m_color.r, m_noteList[0].m_color.g, m_noteList[0].m_color.b, m_noteList[0].m_color.a);
        m_glowImage.color = m_glowImage.glowColor = color;

        // スケールの初期化
        m_transform.localScale = Vector3.one;

        // 音階の設定
        SetNotesScale(m_noteList[0].m_scale);

        // 手前に持ってくる
        Vector3 position = m_transform.localPosition;

        position.z = 0.0f;
        m_transform.localPosition = position;

        // 開始時間と長さの初期化
        PiarhythmDatas.PositionData positionData = m_optionSheetController.ConvertToPositionData(m_noteList[0].m_startBeat, m_noteList[0].m_noteLength);
        m_transform.offsetMin = new Vector2(m_transform.offsetMin.x, positionData.m_position);
        m_transform.offsetMax = new Vector2(m_transform.offsetMax.x, m_transform.offsetMin.y + positionData.m_lenght);
        for (int i = 1; i < m_noteList.Count; ++i)
        {
            positionData = m_optionSheetController.ConvertToPositionData(m_noteList[i].m_startBeat, m_noteList[i].m_noteLength);
            Vector2 offsetMax = m_transform.offsetMax;
            offsetMax.y          += positionData.m_lenght;
            m_transform.offsetMax = offsetMax;
        }

        // 光彩を切る
        m_glowImage.glowSize = 0.0f;
    }
Beispiel #8
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの開始拍と音符から開始座標と長さに変換する
    //!
    //! @parameter [startBeat] 開始の拍数
    //! @parameter [noteLength] 音符の長さ
    //!
    //! @return    変換された座標
    //-----------------------------------------------------------------
    public PiarhythmDatas.PositionData ConvertToPositionData(float startBeat, int noteLenght)
    {
        PiarhythmDatas.PositionData positionData = new PiarhythmDatas.PositionData();
        float elapsedBeat     = 0.0f;
        float elapsedPosition = 0.0f;

        // 所属しているテンポデータを調べる
        PiarhythmDatas.TempoData tempoData = m_tempoDataList[0];
        for (int i = 1; i < m_tempoDataList.Length; ++i)
        {
            if (startBeat >= m_tempoDataList[i].m_startMeasure * 4)
            {
                // 一拍当たりの時間を求める
                float beatPerTempo = 60.0f / tempoData.m_tempo;
                // 時間を座標に変換する
                float beatPosition = PiarhythmUtility.ConvertTimeToPosition(beatPerTempo, m_settingData.m_noteSpeed * 20.0f);

                // テンポデータの終了座標を求める
                elapsedPosition += beatPosition * ((m_tempoDataList[i].m_startMeasure - tempoData.m_startMeasure) * 4);

                // 経過拍数を増やす
                elapsedBeat += (m_tempoDataList[i].m_startMeasure - tempoData.m_startMeasure) * 4;

                tempoData = m_tempoDataList[i];
            }
            else
            {
                break;
            }
        }

        {
            // 一拍当たりの時間を求める
            float beatPerTempo = 60.0f / tempoData.m_tempo;
            // 時間を座標に変換する
            float beatPosition = PiarhythmUtility.ConvertTimeToPosition(beatPerTempo, m_settingData.m_noteSpeed * 20.0f);

            // テンポデータを元に座標と長さを決める
            positionData.m_position = elapsedPosition + (startBeat - elapsedBeat) * beatPosition;

            switch (noteLenght)
            {
            case 0:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.WHOLE_NOTE_SEMIBREVE;
                break;

            case 1:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.HALF_NOTE_MININ;
                break;

            case 2:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.QUARTER_NOTE_CROCHET;
                break;

            case 3:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.EIGHTH_NOTE_QUAVER;
                break;

            case 4:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.SIXTEENTH_NOTE_SEMIQUAVER;
                break;

            case 5:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.WHOLE_DOTTED_NOTE_SEMIBREVE;
                break;

            case 6:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.HALF_DOTTED_NOTE_MININ;
                break;

            case 7:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.QUARTER_DOTTED_NOTE_CROCHET;
                break;

            case 8:
                positionData.m_lenght = beatPosition * PiarhythmDatas.NoteTime.EIGHTH_DOTTED_NOTE_QUAVER;
                break;
            }
        }

        return(positionData);
    }
Beispiel #9
0
    //-----------------------------------------------------------------
    //! @summary   ノーツの開始座標と長さから開始拍と音符に変換する
    //!
    //! @parameter [positionData] 座標データ
    //!
    //! @return    ノーツデータ
    //-----------------------------------------------------------------
    public PiarhythmDatas.NoteData ConvertToNotesData(PiarhythmDatas.PositionData positionData)
    {
        PiarhythmDatas.NoteData notesData = ScriptableObject.CreateInstance <PiarhythmDatas.NoteData>();
        float elapsedBeat     = 0.0f;
        float elapsedPosition = 0.0f;

        // 所属しているテンポデータを調べる
        PiarhythmDatas.TempoData tempoData = m_tempoDataList[0];
        for (int i = 1; i < m_tempoDataList.Count; ++i)
        {
            // 一拍当たりの時間を求める
            float beatPerTempo = 60.0f / tempoData.m_tempo;
            // 時間を座標に変換する
            float beatPosition = PiarhythmUtility.ConvertTimeToPosition(beatPerTempo, NotesManager.NOTES_SPEED);

            // テンポデータの終了座標を求める
            float endPosition = beatPosition * ((m_tempoDataList[i].m_startMeasure - tempoData.m_startMeasure) * 4) + elapsedPosition;

            if (positionData.m_position >= endPosition)
            {
                // 経過座標を更新する
                elapsedPosition = endPosition;

                // 経過拍数を増やす
                elapsedBeat += (m_tempoDataList[i].m_startMeasure - tempoData.m_startMeasure) * 4;

                // 現在のテンポデータを更新する
                tempoData = m_tempoDataList[i];
            }
            else
            {
                break;
            }
        }

        // 現在のテンポデータから正確な位置を確定させる
        {
            float beatPerTempo = 60.0f / tempoData.m_tempo;
            float beatPosition = PiarhythmUtility.ConvertTimeToPosition(beatPerTempo, NotesManager.NOTES_SPEED);

            // 残りの座標を求める
            float residualPosition = positionData.m_position - elapsedPosition;

            // 残りの拍数を求める
            float residualBeat = residualPosition / beatPosition;

            // 残りの拍数を0.25倍に丸める
            residualBeat = PiarhythmUtility.MRound(residualBeat, 0.25f);

            // 経過拍数に加算する
            elapsedBeat += residualBeat;

            // データを保存する
            notesData.m_startBeat = elapsedBeat;


            // 長さを求める
            float noteLength = positionData.m_lenght / beatPosition;

            // 0.25倍に丸める
            noteLength = PiarhythmUtility.MRound(noteLength, 0.25f);

            // 一番近い長さを元に音符を決める
            if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.WHOLE_NOTE_SEMIBREVE))
            {
                notesData.m_noteLength = 0;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.HALF_NOTE_MININ))
            {
                notesData.m_noteLength = 1;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.QUARTER_NOTE_CROCHET))
            {
                notesData.m_noteLength = 2;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.EIGHTH_NOTE_QUAVER))
            {
                notesData.m_noteLength = 3;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.SIXTEENTH_NOTE_SEMIQUAVER))
            {
                notesData.m_noteLength = 4;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.WHOLE_DOTTED_NOTE_SEMIBREVE))
            {
                notesData.m_noteLength = 5;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.HALF_DOTTED_NOTE_MININ))
            {
                notesData.m_noteLength = 6;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.QUARTER_DOTTED_NOTE_CROCHET))
            {
                notesData.m_noteLength = 7;
            }
            else if (Mathf.Approximately(noteLength, PiarhythmDatas.NoteTime.EIGHTH_DOTTED_NOTE_QUAVER))
            {
                notesData.m_noteLength = 8;
            }
            else
            {
                notesData.m_noteLength = 2;
            }
        }

        return(notesData);
    }