/// <summary> /// 指定の判定スコアを追加する /// </summary> public void AddJudge(MusicNote note, MusicJudgeKind kind) { ++JudgeCount[kind]; gGreatText.text = JudgeCount[kind].ToString(); RefreshScore(); GaugeValue += judgeGaugeValues[kind]; if (GaugeValue > MusicConst.GaugeMaxValue) { GaugeValue = MusicConst.GaugeMaxValue; } RefreshGauge(); // コンボ if (kind == MusicJudgeKind.Bad) { ComboValue = 0; } else { ++ComboValue; } // 判定表示 judgeObjects[MusicTapNotesLocator.Instance.PlaceToJudgePosition[note.Place]].Set(kind, ComboValue); }
/// <summary> /// 指定されたノーツを画面上に生成する /// </summary> public void GenerateObject(MusicNote note, int colorIndex = -1) { // 初期化処理 MusicNoteGameObject noteObject = GetNoteObject(); note.SetGameObject(noteObject); // 画像設定 if (note.Place.IsLeftSide() || note.Place.IsRightSide()) { noteObject.NoteImage.sprite = noteSprites[1]; } else { noteObject.NoteImage.sprite = noteSprites[0]; } // 色設定 if (colorIndex == -1) { noteObject.NoteColor = Color.white; } else { noteObject.NoteColor = MusicConst.NotesColor[colorIndex]; } }
/// <summary> /// 指定された位置で新しく出現するノーツを計算し取得する /// 対象となるノーツがない場合はnullを返す /// </summary> public List <MusicNote> CheckNewAppearNotes(int position) { List <MusicNote> appearNotes = null; foreach (MusicPlaceKind kind in Enum.GetValues(typeof(MusicPlaceKind))) { // 先頭ノーツがない場合は何もしない if (noteTopIndexList[kind] == EndOfNoteIndex) { continue; } // 次のノーツが出現位置を越えた場合は生成する MusicNote note = noteList[kind][noteTopIndexList[kind]]; if (position > note.GlobalPosition) { // 出現リストにこのノーツを追加する if (appearNotes == null) { appearNotes = new List <MusicNote>(); } appearNotes.Add(note); activeNoteList[kind].Add(note); // 次のノーツへ移動し末端に到達しら末端定数を入れる ++noteTopIndexList[kind]; if (noteTopIndexList[kind] >= noteList[kind].Count) { noteTopIndexList[kind] = EndOfNoteIndex; } } } return(appearNotes); }
/// <summary> /// 初期設定 /// </summary> public void Initialize(MusicNote note) { this.note = note; startPosition = MusicTapNotesLocator.Instance.StartPositions[note.Place]; endPosition = MusicTapNotesLocator.Instance.EndPositions[note.Place]; rectTransform.anchoredPosition = startPosition; IsActive = true; gameObject.SetActive(true); }
/// <summary> /// 指定ノーツ同士を繋ぐ同時押し線を生成する /// </summary> public void GenerateTapLine(MusicNote noteA, MusicNote noteB) { // 再利用可能オブジェクトがある場合は使用する MusicTapLineObject line = generatedTapLineObjects.Find(obj => !obj.IsActive); if (line != null) { GenerateTapLine(line, noteA, noteB); return; } // 生成処理 line = Instantiate(tapLinePrefab, noteObjectRoot); GenerateTapLine(line, noteA, noteB); generatedTapLineObjects.Add(line); }
/// <summary> /// 指定位置にエフェクトを生成する /// </summary> public void GenerateEffect(MusicNote effectTargetNote) { // 再利用可能オブジェクトがある場合は使用する MusicTapEffectObject effect = generatedEffectObjects.Find(obj => !obj.IsActive); if (effect != null) { effect.Initialize(MusicTapNotesLocator.Instance.EndPositions[effectTargetNote.Place]); return; } // 生成処理 effect = Instantiate(effectPrefab, noteObjectRoot); effect.Initialize(MusicTapNotesLocator.Instance.EndPositions[effectTargetNote.Place]); generatedEffectObjects.Add(effect); }
/// <summary> /// 毎フレームの譜面位置を監視し生成位置に達したノーツを生成する /// </summary> private void UpdateMusicNotes() { // ハイスピードにより算出された1画面表示量 int displayCount = 0; #if DEBUG displayCount += debugNotesDisplay; #endif List <MusicNote> appearNotes = dataManager.currentSheet.CheckNewAppearNotes(timeManager.MusicPosition + displayCount); // 出現ノーツがある場合は出現処理 if (appearNotes != null) { // 同時押しか単押しで分ける if (appearNotes.Count == 1) { // ノーツ生成処理 objectManager.GenerateObject(appearNotes[0]); } else { // 手前で出現したノーツ MusicNote beforeNote = null; foreach (MusicNote note in appearNotes) { // ノーツ生成処理 objectManager.GenerateObject(note, nextNotesColorIndex); // 同時押し線表示処理 if (beforeNote != null) { objectManager.GenerateTapLine(note, beforeNote); } beforeNote = note; } // 同時押し色のインデックスを移動 nextNotesColorIndex = (++nextNotesColorIndex) % MusicConst.NotesColor.Count; } } // 全てのノーツを動かす dataManager.currentSheet.MoveActiveNotes(timeManager.MusicPosition, displayCount); }
/// <summary> /// 同時押し線を生成する内部処理 /// </summary> private void GenerateTapLine(MusicTapLineObject line, MusicNote noteA, MusicNote noteB) { line.Initialize(noteA.NoteObject, noteB.NoteObject); noteA.LineObjects.Add(line); noteB.LineObjects.Add(line); }