zacetek je dolg

This commit is contained in:
2025-12-08 03:25:58 +01:00
parent 4c3ee03007
commit 5de27d0b04
4 changed files with 79 additions and 101 deletions

View File

@@ -51,73 +51,7 @@ class NPC {
}
}
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
if (this.healthBarBg) {
this.healthBarBg.setVisible(false);
this.healthBar.setVisible(false);
}
// Change Eyes to Friendly (Cyan)
this.addTamedEyes();
}
addTamedEyes() {
if (this.eyesGroup) return;
// Container for eyes
// Coordinates relative to sprite center bottom (0.5, 1)
// Head is roughly at y - height.
// Assuming sprite height ~50-60px visual.
this.eyesGroup = this.scene.add.container(this.sprite.x, this.sprite.y);
// Eyes
const eyeL = this.scene.add.rectangle(-5, -55, 3, 3, 0x00FFFF);
const eyeR = this.scene.add.rectangle(5, -55, 3, 3, 0x00FFFF);
this.eyesGroup.add([eyeL, eyeR]);
this.eyesGroup.setDepth(this.sprite.depth + 2);
}
toggleState() {
if (this.state === 'WANDER') {
this.tame();
} else {
// Command to stay/follow
this.state = this.state === 'FOLLOW' ? 'STAY' : 'FOLLOW';
console.log(`Command: ${this.state}`);
// Visual feedback for command
const txt = this.scene.add.text(this.sprite.x, this.sprite.y - 60, this.state, { fontSize: '12px', color: '#FFF' });
txt.setOrigin(0.5);
this.scene.tweens.add({ targets: txt, y: txt.y - 20, alpha: 0, duration: 1000, onComplete: () => txt.destroy() });
}
}
// Methods moved/consolidated below
createSprite() {
let texKey = `npc_${this.type}`;
@@ -697,17 +631,22 @@ class NPC {
this.state = 'TAMED';
console.log('🧟❤️ Zombie TAMED!');
// Register to ZombieWorkerSystem
if (this.scene.zombieSystem) {
this.scene.zombieSystem.registerWorker(this);
}
// Visual Feedback
const headX = this.sprite.x;
const headY = this.sprite.y - 40;
const headY = this.sprite.y - 50;
const heart = this.scene.add.text(headX, headY, '❤️', { fontSize: '20px' });
const heart = this.scene.add.text(headX, headY, '❤️', { fontSize: '24px' });
heart.setOrigin(0.5);
heart.setDepth(this.sprite.depth + 100);
heart.setDepth(this.sprite.depth + 200);
this.scene.tweens.add({
targets: heart,
y: headY - 30,
y: headY - 40,
alpha: 0,
duration: 1500,
onComplete: () => heart.destroy()
@@ -716,7 +655,7 @@ class NPC {
// Change color slightly to indicate friend
this.sprite.setTint(0xAAFFAA);
// Hide Health Bar if tamed (optional)
// Hide Health Bar if tamed
if (this.healthBarBg) {
this.healthBarBg.setVisible(false);
this.healthBar.setVisible(false);
@@ -728,12 +667,30 @@ class NPC {
interact() {
console.log('🗣️ Inteacting with NPC:', this.type);
// Quest Check
// ZOMBIE LOGIC
if (this.type === 'zombie') {
if (this.state !== 'TAMED') {
// Try tame (For now instant)
this.tame();
} else {
// Command: Toggle FOLLOW / STAY
if (this.state === 'FOLLOW') {
this.state = 'STAY';
this.showEmote('🛑'); // Stop
if (this.workerStats) this.workerStats.task = 'IDLE';
} else {
this.state = 'FOLLOW';
this.showEmote('👣'); // Footprints
if (this.workerStats) this.workerStats.task = 'FOLLOW';
}
}
return;
}
// NPC QUEST LOGIC
if (this.scene.questSystem) {
const availableQuest = this.scene.questSystem.getAvailableQuest(this.type);
if (availableQuest) {
console.log('Quest Available from NPC!');
// Open Dialog UI
const ui = this.scene.scene.get('UIScene');
if (ui && ui.showQuestDialog) {
ui.showQuestDialog(availableQuest, () => {
@@ -746,7 +703,6 @@ class NPC {
// Default behavior (Emote)
this.showEmote('👋');
// Small jump or animation?
if (this.sprite) {
this.scene.tweens.add({ targets: this.sprite, y: this.sprite.y - 10, yoyo: true, duration: 100 });
}