This commit is contained in:
2025-12-08 10:47:53 +01:00
parent 5de27d0b04
commit b79b70dcc1
11 changed files with 1001 additions and 21 deletions

View File

@@ -78,6 +78,17 @@ class FarmingSystem {
}
}
// 4. WATERING
if (toolType === 'watering_can') {
if (tile.hasCrop) {
const crop = terrain.cropsMap.get(`${gridX},${gridY}`);
if (crop && !crop.isWatered) {
this.waterCrop(gridX, gridY);
return true;
}
}
}
return false;
}
@@ -139,6 +150,7 @@ class FarmingSystem {
if (data.regrow) {
crop.stage = data.regrowStage;
crop.timer = 0;
crop.isWatered = false; // Reset watering status
terrain.updateCropVisual(x, y, crop.stage);
console.log(`🔄 ${crop.type} regrowing...`);
} else {
@@ -146,6 +158,37 @@ class FarmingSystem {
}
}
waterCrop(x, y) {
const terrain = this.scene.terrainSystem;
const crop = terrain.cropsMap.get(`${x},${y}`);
if (!crop) return;
crop.isWatered = true;
crop.growthBoost = 2.0; // 2x faster growth!
// Visual feedback - tint slightly blue
const key = `${x},${y}`;
if (terrain.visibleCrops.has(key)) {
const sprite = terrain.visibleCrops.get(key);
sprite.setTint(0xAADDFF); // Light blue tint
}
// Sound effect
if (this.scene.soundManager) {
this.scene.soundManager.playPlant(); // Re-use plant sound for now
}
// Floating text
this.scene.events.emit('show-floating-text', {
x: x * 48,
y: y * 48,
text: '💧 Watered!',
color: '#00AAFF'
});
console.log(`💧 Watered crop at ${x},${y}`);
}
update(delta) {
this.growthTimer += delta;
if (this.growthTimer < 1000) return;
@@ -160,10 +203,26 @@ class FarmingSystem {
if (!data) continue;
if (crop.stage < data.stages) {
crop.timer += secondsPassed;
// Apply growth boost if watered
const growthMultiplier = crop.growthBoost || 1.0;
crop.timer += secondsPassed * growthMultiplier;
if (crop.timer >= data.growthTime) {
crop.stage++;
crop.timer = 0;
// Clear watering boost after growth
if (crop.isWatered) {
crop.isWatered = false;
crop.growthBoost = 1.0;
// Remove blue tint
if (terrain.visibleCrops.has(key)) {
const sprite = terrain.visibleCrops.get(key);
sprite.clearTint();
}
}
terrain.updateCropVisual(crop.gridX, crop.gridY, crop.stage);
}
}

View File

@@ -29,6 +29,16 @@ class InteractionSystem {
const candidates = this.scene.spatialGrid ? this.scene.spatialGrid.query(playerPos.x, playerPos.y) : this.scene.npcs;
if (this.scene.vehicles) {
for (const v of this.scene.vehicles) {
const d = Phaser.Math.Distance.Between(playerPos.x, playerPos.y, v.gridX, v.gridY);
if (d < minDist) {
minDist = d;
nearest = v;
}
}
}
for (const npc of candidates) {
const d = Phaser.Math.Distance.Between(playerPos.x, playerPos.y, npc.gridX, npc.gridY);
if (d < minDist) {
@@ -39,7 +49,10 @@ class InteractionSystem {
if (nearest) {
console.log('E Interacted with:', nearest.type);
if (nearest.type === 'zombie') {
if (nearest.type === 'scooter') {
nearest.interact(this.scene.player);
}
else if (nearest.type === 'zombie') {
// Always Tame on E key (Combat is Space/Click)
nearest.tame();
} else {
@@ -82,6 +95,20 @@ class InteractionSystem {
return;
}
// 3.4 Check for Vehicles (Scooter)
if (!isAttack && this.scene.vehicles) {
for (const vehicle of this.scene.vehicles) {
// If mounted, dismount (interact with self/vehicle at same pos)
// If unmounted, check proximity
if (Math.abs(vehicle.gridX - gridX) < 1.5 && Math.abs(vehicle.gridY - gridY) < 1.5) {
if (vehicle.interact) {
vehicle.interact(this.scene.player);
return; // Stop other interactions
}
}
}
}
// 3.5 Check for NPC Interaction
const candidates = this.scene.spatialGrid ? this.scene.spatialGrid.query(gridX, gridY) : this.scene.npcs;

View File

@@ -16,6 +16,7 @@ class InventorySystem {
this.addItem('axe', 1); // 🪓 Sekira
this.addItem('pickaxe', 1); // ⛏️ Kramp
this.addItem('hoe', 1);
this.addItem('watering_can', 1); // 💧 Zalivalka
this.addItem('seeds', 5); // Zmanjšano število semen
// Removed default wood/stone so player has to gather them

View File

@@ -305,14 +305,73 @@ class TerrainSystem {
}
}
// DECORATIONS REMOVED BY REQUEST
// Drevesa, kamni, rože in ruševine so odstranjeni.
// DECORATIONS - Enhanced World Details
console.log('🌸 Adding enhanced decorations...');
// Ostalo je samo generiranje ploščic (tiles) in fixnih con (farm, city floor).
// Natural Path Stones (along roads and random areas)
let pathStoneCount = 0;
for (let i = 0; i < 50; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
this.addDecoration(pos.x, pos.y, 'path_stone');
pathStoneCount++;
}
}
console.log(`✅ Teren generiran (CLEAN): ${treeCount} dreves, ${rockCount} kamnov.`);
// Small decorative rocks
let smallRockCount = 0;
for (let i = 0; i < 80; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
const rockType = Math.random() > 0.5 ? 'small_rock_1' : 'small_rock_2';
this.addDecoration(pos.x, pos.y, rockType);
smallRockCount++;
}
}
console.log(`✅ Teren generiran: ${treeCount} dreves, ${rockCount} kamnov.`);
// Flower clusters
flowerCount = 0;
for (let i = 0; i < 100; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
const flowers = ['flower_red', 'flower_yellow', 'flower_blue'];
const flowerType = flowers[Math.floor(Math.random() * flowers.length)];
this.addDecoration(pos.x, pos.y, flowerType);
flowerCount++;
}
}
// Mushrooms (spooky atmosphere)
let mushroomCount = 0;
for (let i = 0; i < 60; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
const mushroomType = Math.random() > 0.5 ? 'mushroom_red' : 'mushroom_brown';
this.addDecoration(pos.x, pos.y, mushroomType);
mushroomCount++;
}
}
// Fallen Logs (forest debris)
let logCount = 0;
for (let i = 0; i < 25; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
this.addDecoration(pos.x, pos.y, 'fallen_log');
logCount++;
}
}
// Puddles (will appear during rain)
this.puddlePositions = [];
for (let i = 0; i < 40; i++) {
const pos = validPositions[Math.floor(Math.random() * validPositions.length)];
if (pos && !this.decorationsMap.has(`${pos.x},${pos.y}`)) {
this.puddlePositions.push({ x: pos.x, y: pos.y });
}
}
console.log(`✅ Decorations: ${pathStoneCount} paths, ${smallRockCount} rocks, ${flowerCount} flowers, ${mushroomCount} mushrooms, ${logCount} logs.`);
}
damageDecoration(x, y, amount) {
@@ -534,7 +593,16 @@ class TerrainSystem {
// Determine if decoration is SOLID (blocking movement)
const typeLower = type.toLowerCase();
const isSolid = typeLower.includes('tree') ||
// Small decorations are NOT solid (can walk through)
const isSmallDecor = typeLower.includes('flower') ||
typeLower.includes('small_rock') ||
typeLower.includes('path_stone') ||
typeLower.includes('mushroom') ||
typeLower.includes('puddle');
const isSolid = !isSmallDecor && (
typeLower.includes('tree') ||
typeLower.includes('sapling') ||
typeLower.includes('rock') ||
typeLower.includes('stone') ||
@@ -548,7 +616,9 @@ class TerrainSystem {
typeLower.includes('arena') ||
typeLower.includes('house') ||
typeLower.includes('gravestone') ||
typeLower.includes('bush');
typeLower.includes('bush') ||
typeLower.includes('fallen_log')
);
const decorData = {
gridX: gridX,
@@ -655,7 +725,22 @@ class TerrainSystem {
neededTileKeys.add(key);
if (!this.visibleTiles.has(key)) {
const sprite = this.tilePool.get();
sprite.setTexture(tile.type);
// Use water texture with animation support
if (tile.type === 'water') {
// Check if water frames exist
if (this.scene.textures.exists('water_frame_0')) {
sprite.setTexture('water_frame_0');
// Mark sprite for animation
sprite.isWater = true;
sprite.waterFrame = 0;
} else {
sprite.setTexture('water');
}
} else {
sprite.setTexture(tile.type);
}
const screenPos = this.iso.toScreen(x, y);
sprite.setPosition(Math.round(screenPos.x + this.offsetX), Math.round(screenPos.y + this.offsetY));
sprite.setDepth(this.iso.getDepth(x, y, this.iso.LAYER_FLOOR)); // Tiles = Floor
@@ -751,6 +836,20 @@ class TerrainSystem {
}
update(delta) {
// Water animation (250ms per frame = 4 FPS)
this.waterAnimTimer = (this.waterAnimTimer || 0) + delta;
if (this.waterAnimTimer > 250) {
this.waterAnimTimer = 0;
this.waterCurrentFrame = ((this.waterCurrentFrame || 0) + 1) % 4;
// Update all water tiles
for (const [key, sprite] of this.visibleTiles) {
if (sprite.isWater) {
sprite.setTexture(`water_frame_${this.waterCurrentFrame}`);
}
}
}
this.growthTimer = (this.growthTimer || 0) + delta;
if (this.growthTimer < 5000) return;
this.growthTimer = 0;