posodobitev
This commit is contained in:
@@ -41,12 +41,31 @@ class GameScene extends Phaser.Scene {
|
||||
this.expansionSystem = new ExpansionSystem(this);
|
||||
this.blueprintSystem = new BlueprintSystem(this);
|
||||
|
||||
// Farm Stats Tracking for UI
|
||||
this.farmStats = {
|
||||
cropsPlanted: 0,
|
||||
totalHarvested: 0,
|
||||
goldEarned: 0,
|
||||
daysFarmed: 0
|
||||
};
|
||||
|
||||
// PARALLAX BACKGROUND - Clouds & Birds
|
||||
this.createParallaxBackground();
|
||||
|
||||
// Inicializiraj terrain sistem - 100x100 mapa
|
||||
console.log('🌍 Initializing terrain...');
|
||||
try {
|
||||
this.terrainSystem = new TerrainSystem(this, 100, 100);
|
||||
this.terrainSystem.generate();
|
||||
|
||||
// Initialize Farming System
|
||||
this.farmingSystem = new FarmingSystem(this);
|
||||
console.log('🌾 Farming system initialized!');
|
||||
|
||||
// Initialize Build System
|
||||
this.buildSystem = new BuildSystem(this);
|
||||
console.log('🏗️ Build system initialized!');
|
||||
|
||||
// Terrain offset
|
||||
this.terrainOffsetX = width / 2;
|
||||
this.terrainOffsetY = 100;
|
||||
@@ -176,6 +195,24 @@ class GameScene extends Phaser.Scene {
|
||||
console.log('🧟⚒️ Initializing Zombie Worker System...');
|
||||
this.zombieWorkerSystem = new ZombieWorkerSystem(this);
|
||||
|
||||
// SPAWN STARTER ZOMBIE WORKER (8x8 Farm)
|
||||
console.log('🧟 Spawning STARTER Zombie Worker...');
|
||||
const starterZombieX = 48; // Inside 8x8 farm (center is 50,50, farm is 46-54)
|
||||
const starterZombieY = 48;
|
||||
const starterZombie = new NPC(this, starterZombieX, starterZombieY, this.terrainOffsetX, this.terrainOffsetY, 'zombie');
|
||||
// Auto-tame the starter zombie
|
||||
starterZombie.isTamed = true; // Use isTamed (not just tamed)
|
||||
starterZombie.state = 'IDLE';
|
||||
if (starterZombie.showEmote) {
|
||||
starterZombie.showEmote('👋'); // Friendly wave
|
||||
}
|
||||
this.npcs.push(starterZombie);
|
||||
// Assign to farming work
|
||||
if (this.zombieWorkerSystem) {
|
||||
this.zombieWorkerSystem.assignWork(starterZombie, 'FARM', 5); // Farming work, 5 tile radius
|
||||
}
|
||||
console.log('✅ Starter zombie worker spawned and assigned to farming!');
|
||||
|
||||
// GRAVE SYSTEM
|
||||
console.log('🪦 Initializing Grave System...');
|
||||
this.graveSystem = new GraveSystem(this);
|
||||
@@ -495,24 +532,34 @@ class GameScene extends Phaser.Scene {
|
||||
|
||||
// Build Mode Keys
|
||||
this.input.keyboard.on('keydown-B', () => {
|
||||
if (this.buildingSystem) this.buildingSystem.toggleBuildMode();
|
||||
if (this.buildSystem) this.buildSystem.toggleBuildMode();
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-ONE', () => {
|
||||
if (this.buildingSystem && this.buildingSystem.isBuildMode) this.buildingSystem.selectBuilding('fence');
|
||||
if (this.buildSystem && this.buildSystem.buildMode) this.buildSystem.selectBuilding('fence_post');
|
||||
else if (this.scene.get('UIScene')) this.scene.get('UIScene').selectSlot(0);
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-TWO', () => {
|
||||
if (this.buildingSystem && this.buildingSystem.isBuildMode) this.buildingSystem.selectBuilding('wall');
|
||||
if (this.buildSystem && this.buildSystem.buildMode) this.buildSystem.selectBuilding('fence_horizontal');
|
||||
else if (this.scene.get('UIScene')) this.scene.get('UIScene').selectSlot(1);
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-THREE', () => {
|
||||
if (this.buildingSystem && this.buildingSystem.isBuildMode) this.buildingSystem.selectBuilding('house');
|
||||
if (this.buildSystem && this.buildSystem.buildMode) this.buildSystem.selectBuilding('fence_vertical');
|
||||
else if (this.scene.get('UIScene')) this.scene.get('UIScene').selectSlot(2);
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-FOUR', () => {
|
||||
if (this.buildSystem && this.buildSystem.buildMode) this.buildSystem.selectBuilding('fence_corner');
|
||||
else if (this.scene.get('UIScene')) this.scene.get('UIScene').selectSlot(3);
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-FIVE', () => {
|
||||
if (this.buildSystem && this.buildSystem.buildMode) this.buildSystem.selectBuilding('barn');
|
||||
else if (this.scene.get('UIScene')) this.scene.get('UIScene').selectSlot(4);
|
||||
});
|
||||
|
||||
// Soft Reset (F4)
|
||||
this.input.keyboard.on('keydown-F4', () => window.location.reload());
|
||||
|
||||
@@ -530,6 +577,7 @@ class GameScene extends Phaser.Scene {
|
||||
if (this.lootSystem) this.lootSystem.update(delta);
|
||||
if (this.interactionSystem) this.interactionSystem.update(delta);
|
||||
if (this.farmingSystem) this.farmingSystem.update(delta);
|
||||
if (this.buildSystem) this.buildSystem.update(delta);
|
||||
if (this.questSystem) this.questSystem.update(delta);
|
||||
if (this.multiplayerSystem) this.multiplayerSystem.update(delta);
|
||||
|
||||
@@ -816,6 +864,9 @@ class GameScene extends Phaser.Scene {
|
||||
window.Antigravity.Update(this, delta);
|
||||
}
|
||||
|
||||
// Parallax background update
|
||||
this.updateParallax(delta);
|
||||
|
||||
// Terrain system update (za water animacijo)
|
||||
if (this.terrainSystem && this.terrainSystem.update) {
|
||||
this.terrainSystem.update(Date.now(), delta);
|
||||
@@ -823,4 +874,69 @@ class GameScene extends Phaser.Scene {
|
||||
console.warn('⚠️ TerrainSystem.update not available!');
|
||||
}
|
||||
}
|
||||
|
||||
createParallaxBackground() {
|
||||
const width = this.cameras.main.width;
|
||||
const height = this.cameras.main.height;
|
||||
|
||||
// Parallax container
|
||||
this.parallaxContainer = this.add.container(0, 0);
|
||||
this.parallaxContainer.setDepth(-1000); // Always behind everything
|
||||
|
||||
this.clouds = [];
|
||||
this.birds = [];
|
||||
|
||||
// Create 5 clouds
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const cloud = this.add.text(
|
||||
Math.random() * width * 2,
|
||||
Math.random() * height * 0.5,
|
||||
'☁️',
|
||||
{ fontSize: `${30 + Math.random() * 20}px` }
|
||||
);
|
||||
cloud.speed = 0.3 + Math.random() * 0.2; // 0.3-0.5x speed
|
||||
this.parallaxContainer.add(cloud);
|
||||
this.clouds.push(cloud);
|
||||
}
|
||||
|
||||
// Create 3 birds
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const bird = this.add.text(
|
||||
Math.random() * width * 2,
|
||||
100 + Math.random() * 200,
|
||||
'🐦',
|
||||
{ fontSize: '20px' }
|
||||
);
|
||||
bird.speed = 0.5 + Math.random() * 0.3; // 0.5-0.8x speed
|
||||
this.parallaxContainer.add(bird);
|
||||
this.birds.push(bird);
|
||||
}
|
||||
|
||||
console.log('☁️ Parallax background created!');
|
||||
}
|
||||
|
||||
updateParallax(delta) {
|
||||
if (!this.parallaxContainer) return;
|
||||
|
||||
const width = this.cameras.main.width;
|
||||
|
||||
// Update clouds
|
||||
this.clouds.forEach(cloud => {
|
||||
cloud.x -= cloud.speed * (delta / 16);
|
||||
if (cloud.x < -100) {
|
||||
cloud.x = width + 100;
|
||||
cloud.y = Math.random() * this.cameras.main.height * 0.5;
|
||||
}
|
||||
});
|
||||
|
||||
// Update birds
|
||||
this.birds.forEach(bird => {
|
||||
bird.x -= bird.speed * (delta / 16);
|
||||
bird.y += Math.sin(Date.now() / 1000 + bird.x) * 0.5; // Flutter effect
|
||||
if (bird.x < -100) {
|
||||
bird.x = width + 100;
|
||||
bird.y = 100 + Math.random() * 200;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user