diff --git a/src/game/scenes/BattleScene.ts b/src/game/scenes/BattleScene.ts index e8ca916..f146c83 100644 --- a/src/game/scenes/BattleScene.ts +++ b/src/game/scenes/BattleScene.ts @@ -220,6 +220,8 @@ export class BattleScene extends Phaser.Scene { private commandButtons: CommandButton[] = []; private commandMenuObjects: Array = []; private mapMenuObjects: Array = []; + private alertObjects: Phaser.GameObjects.GameObject[] = []; + private alertDismissEvent?: Phaser.Time.TimerEvent; private turnPromptObjects: Phaser.GameObjects.GameObject[] = []; private combatCutInObjects: Phaser.GameObjects.GameObject[] = []; private unitViews = new Map(); @@ -636,6 +638,11 @@ export class BattleScene extends Phaser.Scene { return; } if (choicePointer.leftButtonDown()) { + if (command === 'strategy' || command === 'item') { + this.showUnavailableCommandAlert(command); + return; + } + if (command !== 'wait') { this.beginDamageTargeting(unit, command); return; @@ -676,6 +683,72 @@ export class BattleScene extends Phaser.Scene { this.commandButtons = []; } + private showUnavailableCommandAlert(command: Extract) { + const message = command === 'strategy' ? '사용할 수 있는 책략이 없습니다.' : '사용할 수 있는 도구가 없습니다.'; + this.showBattleAlert(message); + } + + private showBattleAlert(message: string) { + this.hideBattleAlert(); + soundDirector.playSelect(); + + const depth = 90; + const width = 430; + const height = 158; + const left = Math.floor((this.scale.width - width) / 2); + const top = Math.floor((this.scale.height - height) / 2); + + const shade = this.add.rectangle(0, 0, this.scale.width, this.scale.height, 0x020406, 0.28); + shade.setOrigin(0); + shade.setDepth(depth); + shade.setInteractive(); + + const panel = this.add.rectangle(left, top, width, height, 0x101821, 0.98); + panel.setOrigin(0); + panel.setDepth(depth + 1); + panel.setStrokeStyle(3, palette.gold, 0.9); + + const text = this.add.text(left + width / 2, top + 45, message, { + fontFamily: '"Malgun Gothic", "Noto Sans KR", sans-serif', + fontSize: '21px', + color: '#f2e3bf', + fontStyle: '700', + align: 'center' + }); + text.setOrigin(0.5, 0); + text.setDepth(depth + 2); + + const okButton = this.add.rectangle(left + width / 2, top + 112, 112, 34, 0x253748, 0.96); + okButton.setDepth(depth + 2); + okButton.setStrokeStyle(1, palette.blue, 0.78); + okButton.setInteractive({ useHandCursor: true }); + + const okText = this.add.text(left + width / 2, top + 112, '확인', { + fontFamily: '"Malgun Gothic", "Noto Sans KR", sans-serif', + fontSize: '17px', + color: '#ffffff', + fontStyle: '700' + }); + okText.setOrigin(0.5); + okText.setDepth(depth + 3); + okText.setInteractive({ useHandCursor: true }); + + const close = () => this.hideBattleAlert(); + shade.on('pointerdown', close); + okButton.on('pointerdown', close); + okText.on('pointerdown', close); + this.alertDismissEvent = this.time.delayedCall(1400, close); + + this.alertObjects.push(shade, panel, text, okButton, okText); + } + + private hideBattleAlert() { + this.alertDismissEvent?.remove(false); + this.alertDismissEvent = undefined; + this.alertObjects.forEach((object) => object.destroy()); + this.alertObjects = []; + } + private completeUnitAction(unit: UnitData, command: BattleCommand) { if (this.phase !== 'command' || this.selectedUnit?.id !== unit.id || this.actedUnitIds.has(unit.id)) { return;