Implement tile discarding, blocked doors, and correct corridor exits
- Updated TileDefinitions.js: Added 4-way exits to corridor_straight and corridor_steps (N/S y=3,4; E/W x=3,4). - Updated DungeonGenerator.js: Added cancelPlacement() logic and onDoorBlocked callback. - Updated GameRenderer.js: Implemented blockDoor() to visualize blocked passages, and improved isPlayerAdjacentToDoor. - Updated UIManager.js: Added custom showModal/showConfirm and Discard button for tile placement. - Updated main.js: Handled blocked door clicks and hooked up UI events. - Updated GameEngine.js: Improved door adjacency checks. - Updated CameraManager.js: Preserved camera rotation on centerOn. - Added door1_blocked.png asset.
This commit is contained in:
49
src/main.js
49
src/main.js
@@ -83,6 +83,10 @@ generator.onPlacementUpdate = (preview) => {
|
||||
}
|
||||
};
|
||||
|
||||
generator.onDoorBlocked = (exitData) => {
|
||||
renderer.blockDoor(exitData);
|
||||
};
|
||||
|
||||
// 6. Handle Clicks
|
||||
const handleClick = (x, y, doorMesh) => {
|
||||
// PRIORITY 1: Tile Placement Mode - ignore all clicks
|
||||
@@ -92,26 +96,33 @@ const handleClick = (x, y, doorMesh) => {
|
||||
}
|
||||
|
||||
// PRIORITY 2: Door Click (must be adjacent to player)
|
||||
if (doorMesh && doorMesh.userData.isDoor && !doorMesh.userData.isOpen) {
|
||||
const doorExit = doorMesh.userData.cells[0];
|
||||
|
||||
if (game.isPlayerAdjacentToDoor(doorExit)) {
|
||||
|
||||
|
||||
// Open door visually
|
||||
renderer.openDoor(doorMesh);
|
||||
|
||||
// Get proper exit data with direction
|
||||
const exitData = doorMesh.userData.exitData;
|
||||
if (exitData) {
|
||||
generator.selectDoor(exitData);
|
||||
} else {
|
||||
console.error('[Main] Door missing exitData');
|
||||
}
|
||||
} else {
|
||||
|
||||
if (doorMesh && doorMesh.userData.isDoor) {
|
||||
if (doorMesh.userData.isBlocked) {
|
||||
ui.showModal('¡Derrumbe!', 'Esta puerta está bloqueada por un derrumbe. No se puede pasar.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!doorMesh.userData.isOpen) {
|
||||
const doorExit = doorMesh.userData.cells[0];
|
||||
|
||||
if (game.isPlayerAdjacentToDoor(doorMesh.userData.cells)) {
|
||||
|
||||
|
||||
// Open door visually
|
||||
renderer.openDoor(doorMesh);
|
||||
|
||||
// Get proper exit data with direction
|
||||
const exitData = doorMesh.userData.exitData;
|
||||
if (exitData) {
|
||||
generator.selectDoor(exitData);
|
||||
} else {
|
||||
console.error('[Main] Door missing exitData');
|
||||
}
|
||||
} else {
|
||||
// Optional: Message if too far?
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// PRIORITY 3: Normal cell click (player selection/movement)
|
||||
|
||||
Reference in New Issue
Block a user