/** * ANTIGRAVITY ENGINE * Core system for NovaFarma */ window.Antigravity = { Config: { Tileset: { Spacing: 0, Margin: 0, TextureFilter: 'NEAREST' } }, /** * SYSTEMS REGISTRY * Central storage for all game systems * Usage: window.Antigravity.Systems.TerrainSystem */ Systems: {}, /** * Register a system * @param {string} name - System name * @param {Object} system - System instance */ registerSystem: function (name, system) { this.Systems[name] = system; console.log(`✅ Registered system: ${name}`); }, /** * Get a registered system * @param {string} name - System name * @returns {Object|null} System instance or null */ getSystem: function (name) { return this.Systems[name] || null; }, Rendering: { /** * Zagotavlja pravilno globinsko razvrščanje (Depth Sorting) vseh spritov * @param {Phaser.Scene} scene */ depthSortSprites: function (scene) { // 1. Player Depth if (scene.player && scene.player.sprite) { scene.player.updateDepth(); } // 2. NPC Depth if (scene.npcs) { scene.npcs.forEach(npc => { if (npc && npc.sprite && npc.sprite.visible) { npc.updateDepth(); // Vsak NPC ima svojo metodo } }); } // 3. Projectiles / Particles (če bi jih imeli ločene) // ... } }, Physics: { checkCollisions: function (scene) { // Placeholder za centraliziran collision logic } }, Camera: { /** * Nastavi kamero, da sledi tarči * @param {Phaser.Scene} scene * @param {Phaser.GameObjects.GameObject} target */ follow: function (scene, target) { if (scene.cameras && scene.cameras.main && target) { // Uporabimo lerp za gladko sledenje (0.1, 0.1) scene.cameras.main.startFollow(target, true, 0.1, 0.1); console.log('📷 Antigravity Camera: Following target'); } }, /** * Nastavi zoom stopnjo kamere * @param {Phaser.Scene} scene * @param {number} zoomLevel */ setZoom: function (scene, zoomLevel) { if (scene.cameras && scene.cameras.main) { scene.cameras.main.setZoom(zoomLevel); console.log(`🔍 Antigravity Camera: Zoom set to ${zoomLevel}`); } } }, UI: { showMessage: function (scene, message, color = '#ffffff') { if (scene.events && scene.player) { scene.events.emit('show-floating-text', { x: scene.player.x, y: scene.player.y - 60, text: message, color: color }); } }, setText: function (scene, elementId, text) { const ui = scene.scene.get('UIScene'); if (ui && ui[elementId]) { ui[elementId].setText(text); } }, setBarValue: function (scene, elementId, percent) { const ui = scene.scene.get('UIScene'); if (ui && ui[elementId] && ui.setBarValue) { ui.setBarValue(ui[elementId], percent); } }, drawRectangle: function (scene, x, y, width, height, color = 0xffffff, alpha = 1, isHUD = false) { const rect = scene.add.rectangle(x, y, width, height, color, alpha); if (isHUD) { rect.setScrollFactor(0); rect.setOrigin(0, 0); rect.setDepth(10000); } return rect; }, strokeRectangle: function (scene, x, y, width, height, color = 0xffffff, thickness = 2, isHUD = false) { const g = scene.add.graphics(); g.lineStyle(thickness, color, 1); if (isHUD) { g.strokeRect(x, y, width, height); g.setScrollFactor(0); g.setDepth(10000); } else { g.strokeRect(x - width / 2, y - height / 2, width, height); } return g; } }, /** * Glavni update loop za Engine * @param {Phaser.Scene} scene * @param {number} delta */ Update: function (scene, delta) { this.Rendering.depthSortSprites(scene); } }; console.log('🌌 Antigravity Engine Initialized', window.Antigravity.Config);