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:
@@ -89,14 +89,23 @@ export class GameEngine {
|
||||
|
||||
}
|
||||
|
||||
isPlayerAdjacentToDoor(doorExit) {
|
||||
isPlayerAdjacentToDoor(doorCells) {
|
||||
if (!this.player) return false;
|
||||
|
||||
const dx = Math.abs(this.player.x - doorExit.x);
|
||||
const dy = Math.abs(this.player.y - doorExit.y);
|
||||
// doorCells should be an array of {x, y} objects
|
||||
// If it sends a single object, wrap it
|
||||
const cells = Array.isArray(doorCells) ? doorCells : [doorCells];
|
||||
|
||||
// Adjacent means distance of 1 in one direction and 0 in the other
|
||||
return (dx === 1 && dy === 0) || (dx === 0 && dy === 1);
|
||||
for (const cell of cells) {
|
||||
const dx = Math.abs(this.player.x - cell.x);
|
||||
const dy = Math.abs(this.player.y - cell.y);
|
||||
|
||||
// Adjacent means distance of 1 in one direction and 0 in the other
|
||||
if ((dx === 1 && dy === 0) || (dx === 0 && dy === 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
update(time) {
|
||||
|
||||
Reference in New Issue
Block a user