diff --git a/apps/client/src/scenes/game/GameInputManager.ts b/apps/client/src/scenes/game/GameInputManager.ts index 9017d1e..3fde571 100644 --- a/apps/client/src/scenes/game/GameInputManager.ts +++ b/apps/client/src/scenes/game/GameInputManager.ts @@ -5,9 +5,12 @@ /** ジョイスティック入力をゲーム管理へ橋渡しするマネージャー */ export class GameInputManager { private onJoystickInput: (x: number, y: number) => void; - private onPlaceBomb: () => void; + private onPlaceBomb: () => boolean; - constructor(onJoystickInput: (x: number, y: number) => void, onPlaceBomb: () => void) { + constructor( + onJoystickInput: (x: number, y: number) => void, + onPlaceBomb: () => boolean, + ) { this.onJoystickInput = onJoystickInput; this.onPlaceBomb = onPlaceBomb; } @@ -16,7 +19,7 @@ this.onJoystickInput(x, y); }; - public handlePlaceBomb = () => { - this.onPlaceBomb(); + public handlePlaceBomb = (): boolean => { + return this.onPlaceBomb(); }; } diff --git a/apps/client/src/scenes/game/GameView.tsx b/apps/client/src/scenes/game/GameView.tsx index 904118f..56381f9 100644 --- a/apps/client/src/scenes/game/GameView.tsx +++ b/apps/client/src/scenes/game/GameView.tsx @@ -11,7 +11,7 @@ startCountdownText: string | null; pixiContainerRef: React.RefObject; onJoystickInput: (x: number, y: number) => void; - onPlaceBomb: () => void; + onPlaceBomb: () => boolean; }; const ROOT_STYLE: React.CSSProperties = { diff --git a/apps/client/src/scenes/game/hooks/useGameSceneController.ts b/apps/client/src/scenes/game/hooks/useGameSceneController.ts index f2ddb49..67bc2fe 100644 --- a/apps/client/src/scenes/game/hooks/useGameSceneController.ts +++ b/apps/client/src/scenes/game/hooks/useGameSceneController.ts @@ -39,7 +39,7 @@ manager.setJoystickInput(x, y); }, () => { - manager.placeBomb(); + return manager.placeBomb() !== null; }, ); @@ -67,8 +67,8 @@ inputManagerRef.current?.handleJoystickInput(x, y); }, []); - const handlePlaceBomb = useCallback(() => { - inputManagerRef.current?.handlePlaceBomb(); + const handlePlaceBomb = useCallback((): boolean => { + return inputManagerRef.current?.handlePlaceBomb() ?? false; }, []); return { diff --git a/apps/client/src/scenes/game/input/GameInputOverlay.tsx b/apps/client/src/scenes/game/input/GameInputOverlay.tsx index da31f27..09c2626 100644 --- a/apps/client/src/scenes/game/input/GameInputOverlay.tsx +++ b/apps/client/src/scenes/game/input/GameInputOverlay.tsx @@ -11,7 +11,7 @@ /** 入力UIレイヤーの入力プロパティ */ type GameInputOverlayProps = { onJoystickInput: (x: number, y: number) => void; - onPlaceBomb: () => void; + onPlaceBomb: () => boolean; }; const UI_LAYER_STYLE: React.CSSProperties = { @@ -83,7 +83,11 @@ return; } - onPlaceBomb(); + const placed = onPlaceBomb(); + if (!placed) { + return; + } + setLastBombPressedAt(Date.now()); setNowMs(Date.now()); }; diff --git a/apps/client/src/scenes/game/input/bomb/BombButton.tsx b/apps/client/src/scenes/game/input/bomb/BombButton.tsx index 3be3c10..ad71a55 100644 --- a/apps/client/src/scenes/game/input/bomb/BombButton.tsx +++ b/apps/client/src/scenes/game/input/bomb/BombButton.tsx @@ -85,8 +85,13 @@ onPress(); }; + const handlePointerDown = (event: React.PointerEvent) => { + event.preventDefault(); + handleActivate(); + }; + return ( -
+