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

@@ -1,39 +1,50 @@
class ZombieWorkerSystem {
constructor(scene) {
this.scene = scene;
this.workers = []; // Array of tames zombies
this.graves = []; // Array of grave locations
this.workers = []; // Array of tamed zombies (NPC objects)
console.log('🧟 ZombieWorkerSystem: Initialized');
}
// Dodaj zombija med delavce
addWorker(zombieEntity) {
this.workers.push({
entity: zombieEntity,
task: 'IDLE', // FARM, MINE, GUARD, REST
energy: 100, // Decay meter
xp: 0
});
console.log('🧟 New Worker Assigned!');
registerWorker(npc) {
if (!this.workers.includes(npc)) {
this.workers.push(npc);
npc.workerStats = {
energy: 100, // Energija (pada ob delu)
decay: 0, // Razpadanje (0-100%, 100% = smrt)
xp: 0, // Izkušnje zombija
level: 1,
task: 'IDLE' // IDLE, FARM, MINE, GUARD, FOLLOW
};
console.log(`🧟 Zombie ${this.workers.length} registered as Worker!`);
// UI Feedback
this.scene.events.emit('show-floating-text', {
x: npc.sprite.x,
y: npc.sprite.y - 50,
text: "New Worker!",
color: "#00FF00"
});
}
}
// Dodelitev naloge
assignTask(workerIndex, taskType, location) {
if (this.workers[workerIndex]) {
this.workers[workerIndex].task = taskType;
this.workers[workerIndex].targetLocation = location;
unregisterWorker(npc) {
const idx = this.workers.indexOf(npc);
if (idx > -1) {
this.workers.splice(idx, 1);
console.log('🧟 Zombie Worker removed.');
}
}
update(time, delta) {
// Logic for worker AI, decay, and farming automation
this.workers.forEach(worker => {
if (worker.energy > 0) {
worker.energy -= 0.01; // Decay over time
// TODO: Execute Task Logic
} else {
// TODO: Rot / Die logic
}
});
// Update logic for all workers (e.g. decay, energy regen if sleeping)
// This is called every frame, so keep it light.
// Example: Decay tick every 10 seconds (handled by timer, or simplified here)
}
// Assign a task to all idle workers or specific one
assignTask(taskName, targetPos) {
// TODO: Poišči prostega delavca in mu daj nalogo
}
}