Ensure enemies only lock onto player once they have line of sight
This commit is contained in:
@@ -324,4 +324,8 @@ export class DungeonRenderer {
|
||||
showLevelUp(x: number, y: number) {
|
||||
this.fxRenderer.showLevelUp(x, y);
|
||||
}
|
||||
|
||||
showAlert(x: number, y: number) {
|
||||
this.fxRenderer.showAlert(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,4 +188,35 @@ export class FxRenderer {
|
||||
onComplete: () => text.destroy()
|
||||
});
|
||||
}
|
||||
|
||||
showAlert(x: number, y: number) {
|
||||
const screenX = x * TILE_SIZE + TILE_SIZE / 2;
|
||||
const screenY = y * TILE_SIZE - 8;
|
||||
|
||||
const text = this.scene.add.text(screenX, screenY, "!", {
|
||||
fontSize: "24px",
|
||||
color: "#ffaa00",
|
||||
stroke: "#000",
|
||||
strokeThickness: 3,
|
||||
fontStyle: "bold"
|
||||
}).setOrigin(0.5, 1).setDepth(210);
|
||||
|
||||
// Exclamation mark stays visible for alert duration
|
||||
this.scene.tweens.add({
|
||||
targets: text,
|
||||
y: screenY - 8,
|
||||
duration: 200,
|
||||
yoyo: true,
|
||||
repeat: 3, // Bounce a few times
|
||||
ease: "Sine.inOut"
|
||||
});
|
||||
|
||||
this.scene.tweens.add({
|
||||
targets: text,
|
||||
alpha: 0,
|
||||
delay: 900, // Start fading out near end of alert period
|
||||
duration: 300,
|
||||
onComplete: () => text.destroy()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user