stanje 4am
This commit is contained in:
@@ -85,24 +85,41 @@ class StatsSystem {
|
||||
|
||||
die() {
|
||||
console.log('💀 Player died!');
|
||||
// Zaenkrat samo respawn / reset
|
||||
this.health = 100;
|
||||
this.hunger = 100;
|
||||
this.thirst = 100;
|
||||
|
||||
// Teleport to spawn
|
||||
const spawnX = this.scene.terrainOffsetX + 500; // Dummy
|
||||
const spawnY = this.scene.terrainOffsetY + 100; // Dummy
|
||||
// Reset player pos...
|
||||
// V pravi implementaciji bi klicali GameScene.respawnPlayer()
|
||||
// Trigger Player Animation
|
||||
if (this.scene.player) {
|
||||
this.scene.player.dieAnimation();
|
||||
}
|
||||
|
||||
// Show notification
|
||||
// Show Notification & Overlay in UI Scene
|
||||
const uiScene = this.scene.scene.get('UIScene');
|
||||
if (uiScene) {
|
||||
const txt = uiScene.add.text(uiScene.width / 2, uiScene.height / 2, 'YOU DIED', {
|
||||
// Full screen overlay using scale dimensions
|
||||
const width = uiScene.scale.width;
|
||||
const height = uiScene.scale.height;
|
||||
|
||||
const bg = uiScene.add.rectangle(width / 2, height / 2, width, height, 0x000000, 0.8);
|
||||
|
||||
const txt = uiScene.add.text(width / 2, height / 2, 'YOU DIED', {
|
||||
fontSize: '64px', color: '#ff0000', fontStyle: 'bold'
|
||||
}).setOrigin(0.5);
|
||||
uiScene.time.delayedCall(2000, () => txt.destroy());
|
||||
|
||||
// Wait and Respawn
|
||||
uiScene.time.delayedCall(3000, () => {
|
||||
if (bg) bg.destroy();
|
||||
if (txt) txt.destroy();
|
||||
|
||||
// Reset Stats
|
||||
this.health = 100;
|
||||
this.hunger = 100;
|
||||
this.thirst = 100;
|
||||
this.updateUI();
|
||||
|
||||
// Reset Player
|
||||
if (this.scene.player) {
|
||||
this.scene.player.respawn();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user