Beispiel #1
0
    //キー入力
    public bool hit(KeyCode aKey, float aSecond, Note.HitNoteType aType)
    {
        int tLength = (mTriplet) ? 3 : 4;

        for (int i = 0; i < tLength; i++)
        {
            if (mNotes[i] == null)
            {
                continue;                   //音符なし
            }
            float tSecond = MusicScoreData.quarterBeatToMusicTime(mNotes[i].mCorrectQuarterBeat);
            TypeEvaluation.Evaluation tEvaluation = TypeEvaluation.evaluate(aSecond, tSecond);
            if (tEvaluation == TypeEvaluation.Evaluation.miss)
            {
                continue;                                               //タイミングがあってない
            }
            //タイミングOK
            Note.HitResult tHitResult = mNotes[i].hit(aKey, aType);
            if (tHitResult == Note.HitResult.miss)
            {
                continue;                                   //hitしなかった
            }
            //hitしたメッセージ送信
            Subject.sendMessage(new Message("hittedNote", new Arg(new Dictionary <string, object>()
            {
                { "note", mNotes[i] },
                { "evaluation", tEvaluation },
                { "difference", aSecond - tSecond },
                { "hitResult", tHitResult }
            })));
            return(true);
        }
        return(false);
    }
 public override void getMessage(Message aMessage)
 {
     if (aMessage.name == "clickNote" || aMessage.name == "clickLyrics")
     {
         float tRust = MusicScoreData.quarterBeatToMusicTime(aMessage.getParameter <float>("time"));
         if (tRust < 0)
         {
             AlartCreater.alart("音声再生開始前の位置です");
             return;
         }
         if (parent.mPlayer.mMusicLength <= tRust)
         {
             AlartCreater.alart("音声の再生が終了している位置です");
             return;
         }
         AlartCreater.alart("フォームの値を更新しました");
         mSettingForm.setRustForm(tRust.ToString());
         parent.changeState(new EditState(parent));
         return;
     }
     if (aMessage.name == "selectRustFromScoreButtonPushed") //譜面からサビの開始位置を選択するボタン
     {
         parent.changeState(new EditState(parent));
         return;
     }
 }
Beispiel #3
0
    static public Dictionary <ScoreDifficult, int> calculateDifficult(List <Arg> aNotes)
    {
        float tChild      = 0;
        float tStudent    = 0;
        float tScholar    = 0;
        float tGuru       = 0;
        int   tLength     = aNotes.Count;
        int   tGuruLength = 0;//難易度guruの時の音符の数

        for (int i = 0; i < aNotes.Count - 1; i++)
        {
            Arg    tNote1      = aNotes[i];
            float  tSecond1    = MusicScoreData.quarterBeatToMusicTime(tNote1.get <float>("time"));
            string tConsonant1 = tNote1.get <string>("consonant");
            string tVowel1     = tNote1.get <string>("vowel");
            string tKey1       = (tConsonant1 == " ") ? tVowel1 : tConsonant1;

            Arg    tNote2      = aNotes[i + 1];
            float  tSecond2    = MusicScoreData.quarterBeatToMusicTime(tNote2.get <float>("time"));
            string tConsonant2 = tNote2.get <string>("consonant");
            string tVowel2     = tNote2.get <string>("vowel");
            string tKey2       = (tConsonant1 == " ") ? tVowel2 : tConsonant2;

            tChild   += calculateNoteDifficult(new NoteKey(tSecond1, " "), new NoteKey(tSecond2, " "));
            tStudent += calculateNoteDifficult(new NoteKey(tSecond1, tVowel1), new NoteKey(tSecond2, tVowel2));
            tScholar += calculateNoteDifficult(new NoteKey(tSecond1, tKey1), new NoteKey(tSecond2, tKey2));
            if (tConsonant1 != " " && tVowel1 != " ")
            {
                tGuru += calculateNoteDifficult(new NoteKey(tSecond1, tConsonant1), new NoteKey(tSecond1, tVowel1));
                tGuru += calculateNoteDifficult(new NoteKey(tSecond1, tVowel1), new NoteKey(tSecond2, tKey2));
                //難易度guruの時の音符の数カウント
                tGuruLength += 2;
            }
            else
            {
                tGuru += calculateNoteDifficult(new NoteKey(tSecond1, tKey1), new NoteKey(tSecond2, tKey2));
                //難易度guruの時の音符の数カウント
                tGuruLength++;
            }
        }
        //音符一つ分の難易度の平均をとる
        tChild   /= tLength;
        tStudent /= tLength;
        tScholar /= tLength;
        tGuru    /= tGuruLength;
        //最大難易度を超えた場合に補正
        int tRChild   = (tChild > kDifficultStage) ? kDifficultStage - 1 : (int)tChild;
        int tRStudent = (tStudent > kDifficultStage) ? kDifficultStage - 1 : (int)tStudent;
        int tRScholar = (tScholar > kDifficultStage) ? kDifficultStage - 1 : (int)tScholar;
        int tRGuru    = (tGuru > kDifficultStage) ? kDifficultStage - 1 : (int)tGuru;

        return(new Dictionary <ScoreDifficult, int>()
        {
            { ScoreDifficult.child, tRChild },
            { ScoreDifficult.student, tRStudent },
            { ScoreDifficult.scholar, tRScholar },
            { ScoreDifficult.guru, tRGuru }
        });
    }
Beispiel #4
0
    //現在の譜面時間を取得
    public float getCurrentTime()
    {
        float tCurrentScond = mPlayer.mCurrentSecond;

        if (tCurrentScond <= 0)
        {
            return(MusicScoreData.quarterBeatToMusicTime(mScore.mCurrentQuarterBeat));
        }
        else
        {
            return(tCurrentScond);
        }
    }
Beispiel #5
0
    public void play()
    {
        float tCurrentMusicTime = MusicScoreData.quarterBeatToMusicTime(mScore.mCurrentQuarterBeat);

        mPlayer.mCurrentSecond = tCurrentMusicTime;
        if (tCurrentMusicTime < 0)
        {
            mPlayer.playDelayed(-tCurrentMusicTime);
            mMoveScoreCoroutine = mScore.moveBy(new Vector3(0, (mScore.mStartMusicPosition - mScore.positionY) * (1 - 0.5f / tCurrentMusicTime), 0), -tCurrentMusicTime + 0.5f, () => {
                mMoveScoreCoroutine   = null;
                mAdjustScoreCoroutine = mBehaviour.StartCoroutine(adjustScoreToPlayer());
            });
        }
        else
        {
            mPlayer.play();
            mAdjustScoreCoroutine = mBehaviour.StartCoroutine(adjustScoreToPlayer());
        }
    }
Beispiel #6
0
        public override void getMessage(Message aMessage)
        {
            //logClickPosition(aMessage);
            if (aMessage.name == "editPlayButtonPushed")//編曲再生ボタン
            {
                parent.changeState(new EditPlayState(parent));
                return;
            }
            if (aMessage.name == "testPlayButtonPushed")//テスト再生ボタン
            {
                parent.changeState(new TestPlayState(parent));
                return;
            }
            if (aMessage.name == "measureBpmButtonPushed") //bpm測定ボタン
            {
                parent.changeState(new InitialState(parent));
                MySceneManager.openScene("measureBpm", new Arg(new Dictionary <string, object>()
                {
                    { "second", MusicScoreData.quarterBeatToMusicTime(parent.mScore.mCurrentQuarterBeat) },
                    { "staticBpm", MusicScoreData.getBpm(parent.mScore.mCurrentQuarterBeat) }
                }), null, (obj) => {
                    parent.changeState(new EditState(parent));
                });
                return;
            }
            if (aMessage.name == "editLyricsButtonPushed")//歌詞編集ボタン
            {
                parent.changeState(new InitialState(parent));
                MySceneManager.openScene("editLyrics", null, null, (aArg) => {
                    mCommandList.reset();
                    parent.mScore.resetBars();
                    parent.changeState(new EditState(parent));
                });
                return;
            }
            if (aMessage.name == "configButtonPushed")//File設定ボタン
            {
                parent.changeState(new InitialState(parent));
                MySceneManager.openScene("musicConfig", new Arg(new Dictionary <string, object>()
                {
                    { "new", false },
                    { "title", MusicScoreData.mTitle },
                    { "savePath", MusicScoreData.mSavePath },
                    { "music", MusicScoreData.mMusicFileName },
                    { "thumbnail", MusicScoreData.mThumbnail },
                    { "back", MusicScoreData.mBack },
                    { "movie", MusicScoreData.mMovie },
                    { "loadPath", MusicScoreData.mLoadPath }
                }), null, (aArg) => {
                    if (aArg.get <bool>("ok"))
                    {
                        MusicScoreFileData tData = aArg.get <MusicScoreFileData>("scoreData");
                        if (MusicScoreData.mMusicFileName != tData.music)//音声を変更
                        {
                            MusicPlayer tPlayer = MyBehaviour.create <MusicPlayer>();
                            tPlayer.setAudio(DataFolder.loadMusic(tData.music));
                            parent.mPlayer.changeMusic(tPlayer);
                        }
                        MusicScoreData.mTitle         = tData.title;
                        MusicScoreData.mSavePath      = tData.savePath;
                        MusicScoreData.mMusicFileName = tData.music;
                        MusicScoreData.mThumbnail     = tData.thumbnail;
                        MusicScoreData.mBack          = tData.back;
                        MusicScoreData.mMovie         = tData.movie;
                        //譜面の背景更新
                        parent.resetScoreBackground();
                    }
                    parent.changeState(new EditState(parent));
                });
                return;
            }
            if (aMessage.name == "selectRustFromScoreButtonPushed")//譜面からサビの開始位置を選択するボタン
            {
                parent.changeState(new SelectRustFromScoreState(parent));
                return;
            }
            if (aMessage.name == "applySettingButtonPushed") //設定適用ボタン
            {
                if (mSettingForm.isChanged())                //変更がある時だけ適用
                //marginが不正な値になっていないか
                {
                    if (mSettingForm.mMargin < 0)
                    {
                        AlartCreater.alart("Marginは0未満にできません");
                        return;
                    }
                    if (KeyTime.secondsToQuarterBeat(mSettingForm.mMargin, MusicScoreData.mInitialBpm) >= mSettingForm.mRhythm * 4)
                    {
                        AlartCreater.alart("Marginが第一小節の長さを超えています");
                        return;
                    }
                    //rustが不正な値になっていないか
                    if (mSettingForm.mRust < 0)
                    {
                        AlartCreater.alart("サビの位置は0以上で指定してください");
                        return;
                    }
                    if (parent.mPlayer.mMusicLength <= mSettingForm.mRust)
                    {
                        AlartCreater.alart("サビの位置が音声の長さを超えています");
                        return;
                    }
                    AlartCreater.alart("設定を適用しました");
                    mCommandList.run(new ApplySettingCommand(mSettingForm));
                    parent.mScore.resetBars();
                }
                else
                {
                    AlartCreater.alart("値が変更されていません");
                }
                return;
            }
            if (aMessage.name == "resetSettingButtonPushed")//設定リセットボタン
            {
                mSettingForm.reset();
                return;
            }
            if (aMessage.name == "saveButtonPushed")//保存ボタン
            {
                parent.changeState(new SaveState(parent));
                return;
            }
            //譜面クリック
            switch (mCreateObjectType)
            {
            case CreateObjectType.note:
                if (aMessage.name == "clickNote" || aMessage.name == "clickLyrics")
                {
                    tryCreateNote(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                if (aMessage.name == "RightClickNote" || aMessage.name == "RightClickLyrics")
                {
                    tryDeleteNote(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                break;

            case CreateObjectType.lyrics:
                if (aMessage.name == "clickNote" || aMessage.name == "clickLyrics")
                {
                    tryCreateLyrics(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                if (aMessage.name == "RightClickNote" || aMessage.name == "RightClickLyrics")
                {
                    tryDeleteLyrics(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                break;

            case CreateObjectType.changeBpm:
                if (aMessage.name == "clickNote" || aMessage.name == "clickLyrics")
                {
                    tryCreateChangeBpm(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                if (aMessage.name == "RightClickNote" || aMessage.name == "RightClickLyrics")
                {
                    tryDeleteChangeBpm(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                break;

            case CreateObjectType.triplet:
                if (aMessage.name == "clickNote" || aMessage.name == "clickLyrics")
                {
                    tryCreateTriplet(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                if (aMessage.name == "RightClickNote" || aMessage.name == "RightClickLyrics")
                {
                    tryDeleteTriplet(new KeyTime(aMessage.getParameter <float>("time")));
                    return;
                }
                break;
            }
        }