Phase 37: Micro Farm & Expansion System Complete
MICRO FARM SYSTEM (8x8): - Initial 8x8 farm boundary (center spawn) - White boundary visualization - Corner markers for clear boundaries - Locked tile tracking (Set-based) VISUAL FEEDBACK: - Locked tile overlay (30% black) - Clear visual distinction (farm vs locked) - Dynamic rendering (15 tile radius) - Depth-sorted overlays FARMING RESTRICTIONS: - Block tilling outside farm boundary - Error messages (floating text) - Farm boundary validation - FarmingSystem integration EXPANSION SYSTEM: - 4-direction unlock buttons (N/S/E/W) - Cost system (50 gold per expansion) - 2x2 tile unlock increments - Visual updates (boundaries + overlay) UI INTEGRATION: - Interactive expansion buttons - Hover effects (color + scale) - Cost labels (gold display) - Success/error feedback MINIMAP INTEGRATION: - Farm boundary in minimap - White box indicator - Player-relative rendering - Fixed terrain system compatibility TECHNICAL FIXES: - Added decorationsMap to Flat2DTerrainSystem - Fixed variable scope issues - UIScene minimap compatibility - TerrainSystem.getTile() integration FILES CREATED/MODIFIED: - src/systems/MicroFarmSystem.js (NEW!) - src/systems/FarmingSystem.js - src/systems/Flat2DTerrainSystem.js - src/scenes/GameScene.js - src/scenes/UIScene.js - index.html Session: 1h (00:50-01:19) Date: 15.12.2024 Status: PHASE 37 COMPLETE!
This commit is contained in:
@@ -84,6 +84,11 @@ class GameScene extends Phaser.Scene {
|
||||
this.buildSystem = new BuildSystem(this);
|
||||
console.log('🏗️ Build system initialized!');
|
||||
|
||||
// 🌱 Initialize Micro Farm System (PHASE 37!)
|
||||
this.microFarmSystem = new MicroFarmSystem(this);
|
||||
console.log('🌱 Micro Farm system initialized!');
|
||||
|
||||
|
||||
// ========================================================
|
||||
// 🏗️ TESTNI PRIMERI - Postavitev Ograj (ONEMOGOČENO)
|
||||
// ========================================================
|
||||
|
||||
@@ -2689,7 +2689,7 @@ class UIScene extends Phaser.Scene {
|
||||
*/
|
||||
updateMinimapContent() {
|
||||
if (!this.minimapExpanded) return;
|
||||
if (!this.gameScene || !this.gameScene.terrain) return;
|
||||
if (!this.gameScene) return;
|
||||
|
||||
this.minimapGraphics.clear();
|
||||
|
||||
@@ -2698,38 +2698,60 @@ class UIScene extends Phaser.Scene {
|
||||
const scale = (mapSize * 2) / worldSize;
|
||||
|
||||
// Get player position
|
||||
const playerPos = this.gameScene.player.getPosition();
|
||||
const centerX = playerPos.x;
|
||||
const centerY = playerPos.y;
|
||||
const player = this.gameScene.player;
|
||||
if (!player) return;
|
||||
|
||||
const centerX = Math.floor(player.gridX || 0);
|
||||
const centerY = Math.floor(player.gridY || 0);
|
||||
|
||||
// View radius around player
|
||||
const viewRadius = 25;
|
||||
|
||||
// Draw terrain tiles
|
||||
for (let y = Math.max(0, centerY - viewRadius); y < Math.min(worldSize, centerY + viewRadius); y++) {
|
||||
for (let x = Math.max(0, centerX - viewRadius); x < Math.min(worldSize, centerX + viewRadius); x++) {
|
||||
const tile = this.gameScene.terrain[y] && this.gameScene.terrain[y][x];
|
||||
if (!tile) continue;
|
||||
if (this.gameScene.terrainSystem && this.gameScene.terrainSystem.tiles) {
|
||||
for (let y = Math.max(0, centerY - viewRadius); y < Math.min(worldSize, centerY + viewRadius); y++) {
|
||||
for (let x = Math.max(0, centerX - viewRadius); x < Math.min(worldSize, centerX + viewRadius); x++) {
|
||||
const tile = this.gameScene.terrainSystem.getTile(x, y);
|
||||
if (!tile) continue;
|
||||
|
||||
// Calculate position relative to player
|
||||
const relX = (x - centerX) * scale;
|
||||
const relY = (y - centerY) * scale;
|
||||
// Calculate position relative to player
|
||||
const relX = (x - centerX) * scale;
|
||||
const relY = (y - centerY) * scale;
|
||||
|
||||
// Only draw if within circle
|
||||
const dist = Math.sqrt(relX * relX + relY * relY);
|
||||
if (dist > mapSize) continue;
|
||||
// Only draw if within circle
|
||||
const dist = Math.sqrt(relX * relX + relY * relY);
|
||||
if (dist > mapSize) continue;
|
||||
|
||||
// Color based on tile type
|
||||
let color = 0x228B22; // Default green
|
||||
if (tile.type === 'water') color = 0x4488ff;
|
||||
else if (tile.type === 'sand') color = 0xf4a460;
|
||||
else if (tile.type === 'stone') color = 0x808080;
|
||||
else if (tile.type === 'grass') color = 0x228B22;
|
||||
// Color based on tile type
|
||||
let color = 0x228B22; // Default green
|
||||
if (tile.type === 'water') color = 0x4488ff;
|
||||
else if (tile.type === 'sand') color = 0xf4a460;
|
||||
else if (tile.type === 'stone') color = 0x808080;
|
||||
else if (tile.type === 'grass') color = 0x228B22;
|
||||
|
||||
this.minimapGraphics.fillStyle(color, 0.8);
|
||||
this.minimapGraphics.fillRect(relX - scale / 2, relY - scale / 2, scale, scale);
|
||||
this.minimapGraphics.fillStyle(color, 0.8);
|
||||
this.minimapGraphics.fillRect(relX - scale / 2, relY - scale / 2, scale, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 🌱 DRAW MICRO FARM BOUNDARY!
|
||||
if (this.gameScene.microFarmSystem) {
|
||||
const farmCenterX = this.gameScene.microFarmSystem.farmCenterX;
|
||||
const farmCenterY = this.gameScene.microFarmSystem.farmCenterY;
|
||||
const farmSize = this.gameScene.microFarmSystem.farmSize;
|
||||
const halfSize = Math.floor(farmSize / 2);
|
||||
|
||||
// Farm boundary in minimap coords
|
||||
const farmX1 = (farmCenterX - halfSize - centerX) * scale;
|
||||
const farmY1 = (farmCenterY - halfSize - centerY) * scale;
|
||||
const farmW = farmSize * scale;
|
||||
const farmH = farmSize * scale;
|
||||
|
||||
// Draw white farm boundary
|
||||
this.minimapGraphics.lineStyle(2, 0xFFFFFF, 0.9);
|
||||
this.minimapGraphics.strokeRect(farmX1, farmY1, farmW, farmH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user