From 144fc7446644316d5c1ee20dd29c5f4f83a6e840 Mon Sep 17 00:00:00 2001 From: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com> Date: Sat, 18 Nov 2023 20:45:15 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=99=82=E6=8A=BC=E3=81=97=E3=82=AC?= =?UTF-8?q?=E3=82=A4=E3=83=89=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/class/ChartPlayer.ts | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/class/ChartPlayer.ts b/src/class/ChartPlayer.ts index c06428d..52fe3b5 100644 --- a/src/class/ChartPlayer.ts +++ b/src/class/ChartPlayer.ts @@ -1,9 +1,10 @@ +import { Band } from "./Band" import { type Chart } from "./Chart" +import { EachLine } from "./EachLine" +import { JudgeMeter } from "./JudgeMeter" import { type KeySoundPlayer } from "./KeySoundPlayer" -import { Note } from "./Note" -import { Band } from "./Band" import { Measure } from "./Measure" -import { JudgeMeter } from "./JudgeMeter" +import { Note } from "./Note" import { type PlayConfig } from "./PlayConfig" @@ -14,6 +15,7 @@ export class ChartPlayer { public lanes: Note[][] = [] public bgmLane: Note[] = [] public measures: Measure[] = [] + public eachLines: EachLine[] = [] public longNoteBands: Band[][] = [] public isHolds = new Array(7).fill(false) @@ -63,6 +65,8 @@ export class ChartPlayer { const isLatestEndLongNote: boolean[] = new Array(7).fill(false) const beatLatestEndLongNote: number[] = new Array(7).fill(-1) + const eachLinePositions: Record = {} + for (const object of chart.bmsChart.objects._objects) { let laneIndex: number = replacementNormalNote[parseInt(object.channel)] const noteValue: number = parseInt(object.value, 36) @@ -200,7 +204,29 @@ export class ChartPlayer { this.lanes[laneIndex].push(note) this.lastBeat = Math.max(this.lastBeat, beat) } + + if (laneIndex >= 0 && laneIndex <= 7) { + if (!eachLinePositions.hasOwnProperty(beat)) { + eachLinePositions[beat] = [positionX, positionX] + } + eachLinePositions[beat][0] = Math.min(eachLinePositions[beat][0], positionX) + eachLinePositions[beat][1] = Math.max(eachLinePositions[beat][1], positionX) + } + } + + // each line + for (const [beat, [leftPosition, rightPosition]] of Object.entries(eachLinePositions)) { + const eachLine: EachLine = new EachLine( + parseFloat(beat), + scene.add + .rectangle(leftPosition, -100, rightPosition - leftPosition, 4, 0xffffff) + .setOrigin(0, 0.5) + .setDepth(-2) + .setVisible(playConfig.noteType !== "rectangle"), + ) + this.eachLines.push(eachLine) } + for (const laneIndex of Array(7).keys()) { this.lanes[laneIndex].sort((a, b) => a.beat - b.beat) } @@ -245,6 +271,13 @@ export class ChartPlayer { } } + for (const eachLine of this.eachLines) { + eachLine.rectangle.y = 640 + (beat - eachLine.beat) * noteSpeed + if (eachLine.rectangle.y >= 640) { + eachLine.rectangle.setVisible(false) + } + } + for (const laneIndex of Array(7).keys()) { for (const band of this.longNoteBands[laneIndex]) { band.image.displayHeight = Math.max(