popravek zombijo
This commit is contained in:
@@ -316,6 +316,7 @@ class NPC {
|
||||
if (this.attackCooldownTimer > 0) return;
|
||||
this.attackCooldownTimer = 1500;
|
||||
|
||||
// Attack Animation (Jump)
|
||||
if (this.sprite) {
|
||||
this.scene.tweens.add({
|
||||
targets: this.sprite,
|
||||
@@ -324,9 +325,12 @@ class NPC {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.scene.statsSystem) {
|
||||
// Apply Damage to Player
|
||||
if (this.scene.player && this.scene.player.takeDamage) {
|
||||
console.log('🧟 Zombie ATTACKS Player!');
|
||||
this.scene.player.takeDamage(10);
|
||||
} else if (this.scene.statsSystem) {
|
||||
this.scene.statsSystem.takeDamage(10);
|
||||
this.scene.cameras.main.shake(100, 0.005);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,6 +445,52 @@ class NPC {
|
||||
if (idx > -1) this.scene.npcs.splice(idx, 1);
|
||||
}
|
||||
|
||||
tame() {
|
||||
if (this.state === 'TAMED' || this.type !== 'zombie') return;
|
||||
|
||||
this.state = 'TAMED';
|
||||
console.log('🧟❤️ Zombie TAMED!');
|
||||
|
||||
// Visual Feedback
|
||||
const headX = this.sprite.x;
|
||||
const headY = this.sprite.y - 40;
|
||||
|
||||
const heart = this.scene.add.text(headX, headY, '❤️', { fontSize: '20px' });
|
||||
heart.setOrigin(0.5);
|
||||
heart.setDepth(this.sprite.depth + 100);
|
||||
|
||||
this.scene.tweens.add({
|
||||
targets: heart,
|
||||
y: headY - 30,
|
||||
alpha: 0,
|
||||
duration: 1500,
|
||||
onComplete: () => heart.destroy()
|
||||
});
|
||||
|
||||
// Change color slightly to indicate friend
|
||||
this.sprite.setTint(0xAAFFAA);
|
||||
|
||||
// Hide Health Bar if tamed (optional)
|
||||
if (this.healthBarBg) {
|
||||
this.healthBarBg.setVisible(false);
|
||||
this.healthBar.setVisible(false);
|
||||
}
|
||||
|
||||
this.addTamedEyes();
|
||||
}
|
||||
|
||||
addTamedEyes() {
|
||||
if (this.eyesGroup) return;
|
||||
|
||||
this.eyesGroup = this.scene.add.container(this.sprite.x, this.sprite.y);
|
||||
this.eyesGroup.setDepth(this.sprite.depth + 1);
|
||||
|
||||
const eyeL = this.scene.add.rectangle(-4, -54, 4, 4, 0x00FFFF); // Cyan eyes
|
||||
const eyeR = this.scene.add.rectangle(4, -54, 4, 4, 0x00FFFF);
|
||||
|
||||
this.eyesGroup.add([eyeL, eyeR]);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.sprite) this.sprite.destroy();
|
||||
if (this.healthBar) this.healthBar.destroy();
|
||||
|
||||
Reference in New Issue
Block a user