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);
}
}