private void save(bool aCompletion) { //楽曲リスト更新 if (aCompletion) { //完成 if (MusicScoreData.isSaved) { MusicList.update(MusicScoreData.mLoadPath, MusicScoreData.mTitle, MusicScoreData.mSavePath); } else { MusicList.addScore(MusicScoreData.mTitle, MusicScoreData.mSavePath); MusicList.updateLastPlay(MusicList.mLength - 1, MusicList.mLastPlayDifficult);//追加した曲を最後に遊んだ曲とする } } else { //未完成 MusicList.remove(MusicScoreData.mLoadPath); } //楽曲情報更新 //難易度 foreach (KeyValuePair <ScoreDifficult, int> tPare in DifficultCalculator.calculateDifficult(MusicScoreData.mNotes)) { MusicScoreData.setDifficult(tPare.Key, tPare.Value); } MusicScoreData.save(); }
public override void undo() { //もともとあるデータを削除 foreach (float tTime in new float[3] { mTime.mQuarterBeat + 0.1f, mTime.mQuarterBeat + 1.3f, mTime.mQuarterBeat + 2.6f }) { MusicScoreData.deleteChangeBpm(tTime); MusicScoreData.deleteLyrics(tTime); MusicScoreData.deleteNote(tTime); } //生成し直し for (int i = 0; i < 4; i++) { if (mBpmData[i] != null) { mBpmData[i].set("time", mTime.mQuarterBeat + i); MusicScoreData.addChangeBpm(mBpmData[i]); } if (mLyricsData[i] != null) { mLyricsData[i].set("time", mTime.mQuarterBeat + i); MusicScoreData.addLyrics(mLyricsData[i]); } if (mNoteData[i] != null) { mNoteData[i].set("time", mTime.mQuarterBeat + i); MusicScoreData.addNote(mNoteData[i]); } } }
public override void run() { mPreRhythm = MusicScoreData.mRhythm; mPreMargin = MusicScoreData.mMargin; mPreRust = MusicScoreData.mRust; MusicScoreData.mRhythm = mRhythm; MusicScoreData.mMargin = mMargin; MusicScoreData.mRust = mRust; mForm.reset(); //音源再生位置より手前のbpm変更イベント削除 float mPlayMusicQuarterBeat = MusicScoreData.mStartPlayMusicTime.mQuarterBeat; mBpms = new List <Arg>(); //削除するbpm変更イベントを探す List <Arg> tBpms = MusicScoreData.getChangeBpmInBar(new KeyTime(0)); foreach (Arg tData in tBpms) { if (tData.get <float>("time") < 1) { continue; //先頭のbpm変更イベントはそのままにする } if (mPlayMusicQuarterBeat <= tData.get <float>("time")) { continue; //音源再生位置以降 } mBpms.Add(tData); } //見つけたbpm変更イベントを削除 foreach (Arg tData in mBpms) { MusicScoreData.deleteChangeBpm(tData.get <float>("time")); } }
//bpm変更イベントを削除 protected bool tryDeleteChangeBpm(KeyTime aTime) { if (aTime.mQuarterBeat < 0) { return(false); } if (aTime.mQuarterBeat < 1) { AlartCreater.alart("先頭のBPMは削除できません"); return(false); } List <Arg> tList = MusicScoreData.getChangeBpmInBar(aTime); foreach (Arg tData in tList) { if (tData.get <float>("time") != aTime.mQuarterBeat) { continue; } //削除するイベントが見つかった mCommandList.run(new DeleteChangeBpmCommand(aTime)); parent.mScore.resetBars(); 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; } }
//小節生成 private Bar createBar(KeyTime aBarNum) { Bar tBar = MyBehaviour.createObjectFromPrefab <Bar>("score/bar" + MusicScoreData.mRhythm.ToString()); tBar.mTime = aBarNum; //音符追加 List <Arg> tNotes = MusicScoreData.getNotesInBar(aBarNum); foreach (Arg tNoteData in tNotes) { tBar.addNote(tNoteData); } //歌詞追加 List <Arg> tLyrics = MusicScoreData.getLyricsInBar(aBarNum); foreach (Arg tLyricsData in tLyrics) { tBar.addLyrics(tLyricsData); } //bpm変化を示すオブジェクト追加 List <Arg> tBpms = MusicScoreData.getChangeBpmInBar(aBarNum); foreach (Arg tBpm in tBpms) { tBar.addChangeBpm(tBpm); } //位置調整 tBar.transform.parent = gameObject.transform; tBar.transform.localPosition = new Vector3(0, convertToPositionY(tBar.mTime.mBarNum), 0); tBar.transform.localScale = new Vector3(1f, 1f, 1f); tBar.name = "bar:" + aBarNum.mBarNum; return(tBar); }
void Start() { tLyricsText = GameObject.Find("lyricsForm").GetComponent <InputField>(); Arg tArg = MySceneManager.getArg("editLyrics"); tLyricsText.text = MusicScoreData.mAllLyrics; Subject.addObserver(new Observer("editLyricsMain", (message) => { if (message.name == "closeLyricsEditorButtonPushed") { MySceneManager.closeScene("editLyrics", null); return; } if (message.name == "applyLyricsButtonPushed") { MusicScoreData.mAllLyrics = tLyricsText.text; List <Arg> tNotes; List <Arg> tLyrics; string tError = LyricsStringConverter.convert(tLyricsText.text, out tNotes, out tLyrics); if (tError != "") { AlartCreater.alart(tError); return; } tError = MusicScoreData.applyLyrics(tNotes, tLyrics); if (tError != "") { AlartCreater.alart(tError); return; } AlartCreater.alart("歌詞を適用しました"); return; } })); }
public override void undo() { if (mData != null) { MusicScoreData.addChangeBpm(mData); } }
//キー入力 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 run() { //もともとあるデータを削除して記憶 float[] tTripletTimes = new float[3] { mTime.mQuarterBeat + 0.1f, mTime.mQuarterBeat + 1.3f, mTime.mQuarterBeat + 2.6f }; for (int i = 0; i < 3; i++) { mBpmData[i] = MusicScoreData.deleteChangeBpm(tTripletTimes[i]); mLyricsData[i] = MusicScoreData.deleteLyrics(tTripletTimes[i]); mNoteData[i] = MusicScoreData.deleteNote(tTripletTimes[i]); } //生成し直し float[] tNewTime = new float[3] { mTime.mQuarterBeat + 0, mTime.mQuarterBeat + 1, mTime.mCorrectQuarterBeat + 3 }; for (int i = 0; i < 3; i++) { if (mBpmData[i] != null) { mBpmData[i].set("time", tNewTime[i]); MusicScoreData.addChangeBpm(mBpmData[i]); } if (mLyricsData[i] != null) { mLyricsData[i].set("time", tNewTime[i]); MusicScoreData.addLyrics(mLyricsData[i]); } if (mNoteData[i] != null) { mNoteData[i].set("time", tNewTime[i]); MusicScoreData.addNote(mNoteData[i]); } } }
public override void undo() { if (mLyricsData != null) { MusicScoreData.addLyrics(mLyricsData); } }
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 } }); }
public override void undo() { MusicScoreData.deleteNote(mTime.mQuarterBeat); if (mSuccesAddLyrics) { MusicScoreData.deleteLyrics(mTime.mQuarterBeat); } }
public override void run() { MusicScoreData.addLyrics(new Arg(new Dictionary <string, object>() { { "char", " " }, { "time", mTime.mQuarterBeat } })); }
public override void undo() { MusicScoreData.deleteChangeBpm(mTime.mQuarterBeat); if (mPreData != null) { MusicScoreData.addChangeBpm(mPreData); } }
public override void run() { mPreData = MusicScoreData.deleteChangeBpm(mTime.mQuarterBeat); MusicScoreData.addChangeBpm(new Arg(new Dictionary <string, object>() { { "bpm", mBpm }, { "time", mTime.mQuarterBeat } })); }
public override void update() { //キー入力 foreach (KeyCode tKey in KeyMonitor.getInputKey()) { tryCreateNote(new KeyTime(MusicScoreData.musicTimeToQuarterBeat(parent.getCurrentTime()))); //SoundPlayer.playSe("tambourine"); } }
public override void undo() { MusicScoreData.mRhythm = mPreRhythm; MusicScoreData.mMargin = mPreMargin; MusicScoreData.mRust = mPreRust; mForm.reset(); //bpm変更イベントを元に戻す foreach (Arg tData in mBpms) { MusicScoreData.addChangeBpm(tData); } }
//現在の譜面時間を取得 public float getCurrentTime() { float tCurrentScond = mPlayer.mCurrentSecond; if (tCurrentScond <= 0) { return(MusicScoreData.quarterBeatToMusicTime(mScore.mCurrentQuarterBeat)); } else { return(tCurrentScond); } }
public override void run() { MusicScoreData.addNote(new Arg(new Dictionary <string, object>() { { "type", "note" }, { "time", mTime.mQuarterBeat }, { "consonant", " " }, { "vowel", "a" }, })); mSuccesAddLyrics = MusicScoreData.addLyrics(new Arg(new Dictionary <string, object>() { { "char", " " }, { "time", mTime.mQuarterBeat } })); }
public void set(MusicScoreFileData aData, ScoreDifficult aDifficult) { //譜面 mScore = MyBehaviour.create <MusicScore>(); //曲情報ロード MusicScoreData.set(aData); MusicScoreData.mSelectedDifficult = aDifficult; //ミュージックプレイヤー MusicPlayer tPlayer = MyBehaviour.create <MusicPlayer>(); tPlayer.setAudio(DataFolder.loadMusic(MusicScoreData.mMusicFileName)); //譜面と曲を同期させるシステム mPlayer = new KeyNotePlayer(mScore, tPlayer); //背景 resetScoreBackground(); }
//miss判定 public void missHit(float aSecond) { KeyTime tTime = new KeyTime(MusicScoreData.musicTimeToQuarterBeat(aSecond)); int tLength = mBars.Count; int i; Bar tBar; for (i = 1; i < tLength; i++) { tBar = mBars[i]; if (tTime.mQuarterBeat < tBar.mTime.mTopQuarterBeatInBar) { break; } } tBar = mBars[i - 1]; tBar.missHit(tTime); }
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()); } }
//bpm変更イベントを生成 protected bool tryCreateChangeBpm(KeyTime aTime) { if (aTime.mQuarterBeat < 0) { return(false); } if (1 <= aTime.mQuarterBeat && aTime.mQuarterBeat < MusicScoreData.mStartPlayMusicTime.mQuarterBeat) { AlartCreater.alart("音声再生位置より前には配置できません"); return(false); } //編集画面の操作を無効にする parent.changeState(new InitialState(parent)); //変更前の値があるなら取得する float tPreBpm = -1; List <Arg> tList = MusicScoreData.getChangeBpmInBar(aTime); foreach (Arg tData in tList) { if (tData.get <float>("time") != aTime.mQuarterBeat) { continue; } //イベントが見つかった tPreBpm = tData.get <float>("bpm"); break; } //bpm値の入力を受け付ける MySceneManager.openScene("inputChangeBpmValueForm", new Arg(new Dictionary <string, object>() { { "defaultValue", tPreBpm } }), null, (aArg) => { if (aArg.get <bool>("change")) { mCommandList.run(new CreateChangeBpmCommand(aTime, aArg.get <float>("bpm"))); parent.mScore.resetBars(); } parent.changeState(new EditState(parent)); }); return(true); }
public override void run() { //もともとあるデータを削除して記憶 for (int i = 0; i < 4; i++) { mBpmData[i] = MusicScoreData.deleteChangeBpm(mTime.mQuarterBeat + i); mLyricsData[i] = MusicScoreData.deleteLyrics(mTime.mQuarterBeat + i); mNoteData[i] = MusicScoreData.deleteNote(mTime.mQuarterBeat + i); } //生成し直し float[] tNewTime = new float[4] { mTime.mQuarterBeat + 0.1f, mTime.mQuarterBeat + 1.3f, 0, mTime.mQuarterBeat + 2.6f }; for (int i = 0; i < 4; i++) { if (i == 2) { continue; } if (mBpmData[i] != null) { mBpmData[i].set("time", tNewTime[i]); MusicScoreData.addChangeBpm(mBpmData[i]); } if (mLyricsData[i] != null) { mLyricsData[i].set("time", tNewTime[i]); MusicScoreData.addLyrics(mLyricsData[i]); } if (mNoteData[i] != null) { mNoteData[i].set("time", tNewTime[i]); MusicScoreData.addNote(mNoteData[i]); } } }
public override void run() { mData = MusicScoreData.deleteChangeBpm(mTime.mQuarterBeat); }
//音声の再生位置に合わせてpozitionを変更 public void adjustPozitionToMusicTime(float aMusicTime) { show(MusicScoreData.musicTimeToQuarterBeat(aMusicTime)); }
public override void run() { mNoteData = MusicScoreData.deleteNote(mTime.mQuarterBeat); mLyricsData = MusicScoreData.deleteLyrics(mTime.mQuarterBeat); }
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; } }
public override void undo() { MusicScoreData.deleteLyrics(mTime.mQuarterBeat); }