This commit is contained in:
2025-12-11 20:41:00 +01:00
parent 6e998d516d
commit 8b37814bd8
11 changed files with 1184 additions and 143 deletions

View File

@@ -44,6 +44,12 @@ class Player {
takeDamage(amount) {
if (this.isDead) return;
// GOD MODE - Invincibility
if (window.godMode) {
console.log('⚡ GOD MODE: Damage blocked!');
return;
}
this.hp -= amount;
console.log(`Player HP: ${this.hp}`);
@@ -523,8 +529,11 @@ class Player {
const success = this.scene.farmingSystem.tillSoil(gridX, gridY);
if (success) {
console.log('✅ Tilled soil!');
// Particle effect - soil spray
this.createSoilParticles(gridX, gridY);
// Tool swing animation
this.swingTool();
// TODO: Play dig sound
// TODO: Tool swing animation
}
return;
}
@@ -536,6 +545,8 @@ class Player {
if (success) {
invSys.removeItem(itemType, 1);
console.log('🌱 Planted seed!');
// Particle effect - seed drop
this.createSeedParticles(gridX, gridY);
// TODO: Play plant sound
}
return;
@@ -546,10 +557,97 @@ class Player {
const success = this.scene.farmingSystem.harvestCrop(gridX, gridY);
if (success) {
console.log('🌾 Harvested crop!');
// Particle effect - harvest sparkle
this.createHarvestParticles(gridX, gridY);
// Camera shake
this.scene.cameras.main.shake(200, 0.003);
// TODO: Play harvest sound
// TODO: Screen shake
}
return;
}
}
swingTool() {
if (!this.handSprite || !this.handSprite.visible) return;
// Save original position
const originalAngle = this.handSprite.angle;
const originalScale = this.handSprite.scaleX;
// Swing animation
this.scene.tweens.add({
targets: this.handSprite,
angle: originalAngle - 45,
scaleX: originalScale * 1.3,
scaleY: originalScale * 1.3,
duration: 100,
yoyo: true,
ease: 'Cubic.easeOut',
onComplete: () => {
this.handSprite.angle = originalAngle;
this.handSprite.scaleX = originalScale;
this.handSprite.scaleY = originalScale;
}
});
}
createSoilParticles(gridX, gridY) {
const screenPos = this.scene.iso.gridToScreen(gridX, gridY);
const x = screenPos.x + this.offsetX;
const y = screenPos.y + this.offsetY;
// Brown soil particles
for (let i = 0; i < 10; i++) {
const particle = this.scene.add.circle(x, y, 3, 0x8B4513);
this.scene.tweens.add({
targets: particle,
x: x + (Math.random() - 0.5) * 30,
y: y - Math.random() * 20,
alpha: 0,
duration: 400,
onComplete: () => particle.destroy()
});
}
}
createSeedParticles(gridX, gridY) {
const screenPos = this.scene.iso.gridToScreen(gridX, gridY);
const x = screenPos.x + this.offsetX;
const y = screenPos.y + this.offsetY;
// Green seed particles
for (let i = 0; i < 5; i++) {
const particle = this.scene.add.circle(x, y - 20, 2, 0x00ff00);
this.scene.tweens.add({
targets: particle,
y: y,
alpha: 0,
duration: 500,
ease: 'Cubic.easeIn',
onComplete: () => particle.destroy()
});
}
}
createHarvestParticles(gridX, gridY) {
const screenPos = this.scene.iso.gridToScreen(gridX, gridY);
const x = screenPos.x + this.offsetX;
const y = screenPos.y + this.offsetY;
// Golden sparkle particles
for (let i = 0; i < 15; i++) {
const particle = this.scene.add.circle(x, y, 4, 0xFFD700);
this.scene.tweens.add({
targets: particle,
x: x + (Math.random() - 0.5) * 40,
y: y - Math.random() * 40,
scaleX: 0,
scaleY: 0,
alpha: 0,
duration: 600,
ease: 'Cubic.easeOut',
onComplete: () => particle.destroy()
});
}
}
}

View File

@@ -91,4 +91,7 @@ window.gameState = {
debugMode: true
};
// God mode disabled by default (can be enabled via console)
window.godMode = false;
console.log('🎮 NovaFarma initialized!');

View File

@@ -169,88 +169,8 @@ class GameScene extends Phaser.Scene {
console.log('👤 Initializing player...');
this.player = new Player(this, 50, 50, this.terrainOffsetX, this.terrainOffsetY);
// Dodaj 3 NPCje (Mixed)
// Dodaj 3 NPCje (Mixed) - Removed zombie
console.log('🧟 Initializing NPCs...');
const npcTypes = ['villager', 'merchant'];
for (let i = 0; i < npcTypes.length; i++) {
const randomX = Phaser.Math.Between(40, 60); // Closer to center
const randomY = Phaser.Math.Between(40, 60);
console.log(`👤 Spawning NPC type: ${npcTypes[i]} at (${randomX}, ${randomY})`);
const npc = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, npcTypes[i]);
this.npcs.push(npc);
}
// Dodaj 10 dodatnih Zombijev! - REMOVED BY REQUEST
/*
for (let i = 0; i < 10; i++) {
const randomX = Phaser.Math.Between(10, 90);
const randomY = Phaser.Math.Between(10, 90);
const zombie = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, 'zombie');
this.npcs.push(zombie);
}
*/
// ZOMBIE WORKER SYSTEM
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);
// SCOOTER REPAIR SYSTEM
console.log('🛵 Initializing Scooter Repair System...');
this.scooterRepairSystem = new ScooterRepairSystem(this);
// EXPANSION SYSTEM
console.log('🗺️ Initializing Expansion System...');
this.expansionSystem = new ExpansionSystem(this);
// BLUEPRINT SYSTEM
console.log('📜 Initializing Blueprint System...');
this.blueprintSystem = new BlueprintSystem(this);
// WORKSTATION SYSTEM
console.log('🏭 Initializing Workstation System...');
this.workstationSystem = new WorkstationSystem(this);
// ELITE ZOMBIE v City območju (1x za testiranje)
console.log('👹 Spawning ELITE ZOMBIE in City...');
const eliteX = Phaser.Math.Between(50, 80); // City area
const eliteY = Phaser.Math.Between(50, 80);
const elite = new NPC(this, eliteX, eliteY, this.terrainOffsetX, this.terrainOffsetY, 'elite_zombie');
this.npcs.push(elite);
// MUTANTS (Troll & Elf)
console.log('👹 Spawning MUTANTS...');
this.npcs.push(new NPC(this, 60, 20, this.terrainOffsetX, this.terrainOffsetY, 'troll')); // Forest
this.npcs.push(new NPC(this, 70, 70, this.terrainOffsetX, this.terrainOffsetY, 'elf')); // City
// ANIMALS (Peaceful + Mutated)
console.log('🐄 Spawning ANIMALS...');
this.npcs.push(new NPC(this, 22, 22, this.terrainOffsetX, this.terrainOffsetY, 'cow'));
this.npcs.push(new NPC(this, 24, 20, this.terrainOffsetX, this.terrainOffsetY, 'chicken'));
this.npcs.push(new NPC(this, 25, 23, this.terrainOffsetX, this.terrainOffsetY, 'chicken'));
this.npcs.push(new NPC(this, 62, 22, this.terrainOffsetX, this.terrainOffsetY, 'cow_mutant')); // Aggressive mutant
// ALL NPCs REMOVED - Solo farming mode
console.log('🌾 Solo farming mode - no NPCs');
// Easter Egg: Broken Scooter
console.log('🛵 Spawning Scooter Easter Egg...');
@@ -614,10 +534,12 @@ class GameScene extends Phaser.Scene {
}
}
// NPC Update
// NPC Update - DISABLED (no NPCs)
/*
for (const npc of this.npcs) {
npc.update(delta);
}
*/
// Vehicles Update
if (this.vehicles) {
@@ -706,6 +628,10 @@ class GameScene extends Phaser.Scene {
}
spawnNightZombie() {
// DISABLED - No NPCs allowed
return;
/*
if (!this.player || this.npcs.length > 50) return;
const playerPos = this.player.getPosition();
@@ -725,6 +651,7 @@ class GameScene extends Phaser.Scene {
zombie.state = 'CHASE';
this.npcs.push(zombie);
}
*/
}
showHordeWarning() {
@@ -763,6 +690,10 @@ class GameScene extends Phaser.Scene {
}
spawnBoss() {
// DISABLED - No NPCs allowed
return;
/*
if (!this.player) return;
console.log('👑 SPANWING ZOMBIE KING!');
const playerPos = this.player.getPosition();
@@ -773,6 +704,7 @@ class GameScene extends Phaser.Scene {
this.npcs.push(boss);
this.showHordeWarning();
this.events.emit('show-floating-text', { x: this.player.x, y: this.player.y - 100, text: "THE KING HAS ARRIVED!", color: '#AA00FF' });
*/
}
saveGame() {

View File

@@ -116,6 +116,9 @@ class PreloadScene extends Phaser.Scene {
this.load.image('fence_vertical', 'assets/fence_vertical.png');
this.load.image('fence_corner', 'assets/fence_corner.png');
// Water frames are generated procedurally in TerrainSystem.createWaterFrames()
// No need to load external files
// Wait for load completion then process transparency
this.load.once('complete', () => {
this.processAllTransparency();

View File

@@ -78,6 +78,12 @@ class BuildSystem {
this.buildMode = !this.buildMode;
console.log(`Build Mode: ${this.buildMode ? 'ON' : 'OFF'}`);
// Show tutorial on first time
if (this.buildMode && !this.tutorialShown) {
this.showTutorial();
this.tutorialShown = true;
}
// Notify UI
const uiScene = this.scene.scene.get('UIScene');
if (uiScene) {
@@ -223,4 +229,64 @@ class BuildSystem {
const building = this.placedBuildings.find(b => b.gridX === gridX && b.gridY === gridY);
return building ? building.collision : false;
}
showTutorial() {
const uiScene = this.scene.scene.get('UIScene');
if (!uiScene) return;
const width = this.scene.cameras.main.width;
const height = this.scene.cameras.main.height;
// Tutorial panel
const panel = uiScene.add.container(width / 2, height / 2);
panel.setDepth(10000);
const bg = uiScene.add.rectangle(0, 0, 500, 300, 0x1a1a2e, 0.95);
bg.setStrokeStyle(3, 0x00ff41);
panel.add(bg);
const title = uiScene.add.text(0, -120, '🏗️ BUILD MODE', {
fontSize: '24px',
fontFamily: 'Courier New',
color: '#00ff41',
fontStyle: 'bold'
}).setOrigin(0.5);
panel.add(title);
const instructions = [
'Controls:',
'1-5: Select building type',
'Mouse: Move preview',
'Click: Place building',
'B: Exit build mode',
'',
'Green = OK | Red = Blocked'
];
const text = uiScene.add.text(0, 0, instructions.join('\n'), {
fontSize: '16px',
fontFamily: 'Courier New',
color: '#ffffff',
align: 'center',
lineSpacing: 8
}).setOrigin(0.5);
panel.add(text);
const closeBtn = uiScene.add.text(0, 120, '[Click to close]', {
fontSize: '14px',
color: '#888888'
}).setOrigin(0.5);
panel.add(closeBtn);
// Auto-dismiss after 5 seconds
uiScene.time.delayedCall(5000, () => {
panel.destroy();
});
// Click to dismiss
bg.setInteractive();
bg.on('pointerdown', () => {
panel.destroy();
});
}
}

154
src/utils/CheatConsole.js Normal file
View File

@@ -0,0 +1,154 @@
// CHEAT CONSOLE - NovaFarma
// Press ` (backtick) to open console
window.cheats = {
// God Mode - Invincibility
godMode: function () {
window.godMode = !window.godMode;
const status = window.godMode ? 'ENABLED ⚡' : 'DISABLED';
console.log(`🎮 GOD MODE: ${status}`);
if (window.godMode) {
// Visual indicator
const gameScene = window.gameScene;
if (gameScene && gameScene.player) {
gameScene.player.sprite.setTint(0xFFD700);
}
} else {
const gameScene = window.gameScene;
if (gameScene && gameScene.player) {
gameScene.player.sprite.clearTint();
}
}
},
// Infinite Resources
resources: function (amount = 9999) {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.inventorySystem) {
console.log('❌ Inventory system not found');
return;
}
gameScene.inventorySystem.addItem('wood', amount);
gameScene.inventorySystem.addItem('stone', amount);
gameScene.inventorySystem.addItem('iron', amount);
console.log(`💰 Added ${amount} of each resource!`);
},
// Speed Boost
speed: function (multiplier = 2) {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.player) {
console.log('❌ Player not found');
return;
}
gameScene.player.moveSpeed = 200 * multiplier;
console.log(`🏃 Speed multiplier: ${multiplier}x`);
},
// Full Health
heal: function () {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.player) {
console.log('❌ Player not found');
return;
}
gameScene.player.hp = gameScene.player.maxHp;
console.log('❤️ Full health restored!');
},
// Teleport to coordinates
teleport: function (x, y) {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.player) {
console.log('❌ Player not found');
return;
}
gameScene.player.gridX = x;
gameScene.player.gridY = y;
gameScene.player.sprite.setPosition(
gameScene.player.scene.iso.gridToScreen(x, y).x + gameScene.player.offsetX,
gameScene.player.scene.iso.gridToScreen(x, y).y + gameScene.player.offsetY
);
console.log(`📍 Teleported to (${x}, ${y})`);
},
// Day/Night time control
setTime: function (hour) {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.timeSystem) {
console.log('❌ Time system not found');
return;
}
gameScene.timeSystem.hour = hour;
console.log(`⏰ Time set to ${hour}:00`);
},
// Instant harvest all crops
harvestAll: function () {
const gameScene = window.gameScene;
if (!gameScene || !gameScene.farmingSystem) {
console.log('❌ Farming system not found');
return;
}
let count = 0;
for (let key in gameScene.farmingSystem.crops) {
const crop = gameScene.farmingSystem.crops[key];
if (crop.stage === 'ripe') {
const [x, y] = key.split(',').map(Number);
gameScene.farmingSystem.harvestCrop(x, y);
count++;
}
}
console.log(`🌾 Harvested ${count} crops!`);
},
// List all cheats
help: function () {
console.log(`
🎮 CHEAT CONSOLE - NovaFarma
=============================
Available Commands:
-------------------
cheats.godMode() - Toggle invincibility
cheats.resources(9999) - Add resources (default: 9999)
cheats.speed(2) - Set speed multiplier (default: 2x)
cheats.heal() - Restore full health
cheats.teleport(x, y) - Teleport to coordinates
cheats.setTime(12) - Set time (0-24)
cheats.harvestAll() - Harvest all ripe crops
cheats.help() - Show this menu
Quick Keys:
-----------
Press \` (backtick) to open console
Type: cheats.godMode()
Example Usage:
--------------
cheats.godMode() // Enable god mode
cheats.resources(1000) // Add 1000 of each resource
cheats.speed(5) // 5x speed boost
cheats.teleport(50, 50) // Go to center
`);
}
};
// Auto-show help on first load
console.log('🎮 Cheat Console Loaded! Type "cheats.help()" for commands.');
// Quick access
window.god = window.cheats.godMode;
window.res = window.cheats.resources;
console.log('💡 Quick shortcuts: god() or res()');