posodobitve
This commit is contained in:
@@ -66,6 +66,15 @@ class UIScene extends Phaser.Scene {
|
||||
this.toggleSkillTree();
|
||||
});
|
||||
|
||||
// Q/E za Tool Swap
|
||||
this.input.keyboard.on('keydown-Q', () => {
|
||||
this.swapToolPrevious();
|
||||
});
|
||||
|
||||
this.input.keyboard.on('keydown-E', () => {
|
||||
this.swapToolNext();
|
||||
});
|
||||
|
||||
// Define Recipes
|
||||
this.craftingRecipes = [
|
||||
{ id: 'axe', name: 'Stone Axe', req: { 'wood': 3, 'stone': 3 }, output: 1, type: 'tool', desc: 'Used for chopping trees.' },
|
||||
@@ -94,6 +103,15 @@ class UIScene extends Phaser.Scene {
|
||||
this.createOxygenBar();
|
||||
this.createZombieStatsPanel();
|
||||
this.createFarmStatsPanel();
|
||||
this.createEquipmentPreview(); // Equipment preview (top-left)
|
||||
}
|
||||
|
||||
update() {
|
||||
// Update equipment preview
|
||||
this.updateEquipmentPreview();
|
||||
|
||||
// Update minimap
|
||||
this.updateMinimap();
|
||||
}
|
||||
|
||||
// ... (rest of class) ...
|
||||
@@ -342,6 +360,11 @@ class UIScene extends Phaser.Scene {
|
||||
}
|
||||
|
||||
drawUI() {
|
||||
// Initialize i18n if not available
|
||||
if (!window.i18n) {
|
||||
window.i18n = new LocalizationSystem();
|
||||
}
|
||||
|
||||
const x = 20;
|
||||
const y = 20;
|
||||
const width = 150; // Zmanjšana širina (300 -> 150)
|
||||
@@ -349,27 +372,58 @@ class UIScene extends Phaser.Scene {
|
||||
const padding = 10;
|
||||
|
||||
// 1. Health Bar
|
||||
this.healthBar = this.drawBar(x, y, width, height, 0xff0000, 100, 'HP');
|
||||
this.healthBar = this.drawBar(x, y, width, height, 0xff0000, 100, window.i18n.t('ui.hp', 'HP'));
|
||||
|
||||
// 2. Hunger Bar
|
||||
this.hungerBar = this.drawBar(x, y + height + padding, width, height, 0xff8800, 80, 'HUN');
|
||||
this.hungerBar = this.drawBar(x, y + height + padding, width, height, 0xff8800, 80, window.i18n.t('ui.hun', 'HUN'));
|
||||
|
||||
// 3. Thirst Bar
|
||||
this.thirstBar = this.drawBar(x, y + (height + padding) * 2, width, height, 0x0088ff, 90, 'H2O');
|
||||
this.thirstBar = this.drawBar(x, y + (height + padding) * 2, width, height, 0x0088ff, 90, window.i18n.t('ui.h2o', 'H2O'));
|
||||
|
||||
// 4. XP Bar
|
||||
this.XPBar = this.drawBar(x, y + (height + padding) * 3, width, height, 0xFFD700, 0, 'XP');
|
||||
this.XPBar = this.drawBar(x, y + (height + padding) * 3, width, height, 0xFFD700, 0, window.i18n.t('ui.xp', 'XP'));
|
||||
|
||||
// 5. Level Display
|
||||
this.LevelDisplay = this.add.text(x, y + (height + padding) * 4, 'LV: 1', {
|
||||
this.LevelDisplay = this.add.text(x, y + (height + padding) * 4, window.i18n.t('ui.lv', 'LV') + ': 1', {
|
||||
fontSize: '18px', fontFamily: 'Courier New', fill: '#FFD700', fontStyle: 'bold'
|
||||
});
|
||||
}
|
||||
|
||||
refreshUIBars() {
|
||||
// Destroy existing bars
|
||||
if (this.healthBar) {
|
||||
this.healthBar.bg.destroy();
|
||||
this.healthBar.fill.destroy();
|
||||
if (this.healthBar.label) this.healthBar.label.destroy();
|
||||
}
|
||||
if (this.hungerBar) {
|
||||
this.hungerBar.bg.destroy();
|
||||
this.hungerBar.fill.destroy();
|
||||
if (this.hungerBar.label) this.hungerBar.label.destroy();
|
||||
}
|
||||
if (this.thirstBar) {
|
||||
this.thirstBar.bg.destroy();
|
||||
this.thirstBar.fill.destroy();
|
||||
if (this.thirstBar.label) this.thirstBar.label.destroy();
|
||||
}
|
||||
if (this.XPBar) {
|
||||
this.XPBar.bg.destroy();
|
||||
this.XPBar.fill.destroy();
|
||||
if (this.XPBar.label) this.XPBar.label.destroy();
|
||||
}
|
||||
if (this.LevelDisplay) {
|
||||
this.LevelDisplay.destroy();
|
||||
}
|
||||
|
||||
// Recreate with new translations
|
||||
this.drawUI();
|
||||
}
|
||||
|
||||
drawBar(x, y, width, height, color, initialPercent = 100, label = '') {
|
||||
// Label
|
||||
let labelText = null;
|
||||
if (label) {
|
||||
this.add.text(x, y - 12, label, { fontSize: '12px', fontFamily: 'Courier New', fill: '#ffffff' });
|
||||
labelText = this.add.text(x, y - 12, label, { fontSize: '12px', fontFamily: 'Courier New', fill: '#ffffff' });
|
||||
}
|
||||
|
||||
// Background
|
||||
@@ -387,7 +441,7 @@ class UIScene extends Phaser.Scene {
|
||||
const currentWidth = (maxWidth * initialPercent) / 100;
|
||||
fill.fillRect(x + 2, y + 2, currentWidth, height - 4);
|
||||
|
||||
return { bg, fill, x, y, width, height, color };
|
||||
return { bg, fill, label: labelText, x, y, width, height, color };
|
||||
}
|
||||
|
||||
setBarValue(bar, percent) {
|
||||
@@ -1890,10 +1944,21 @@ class UIScene extends Phaser.Scene {
|
||||
if (!isActive) btn.setBackgroundColor('#222222');
|
||||
});
|
||||
btn.on('pointerdown', () => {
|
||||
console.log('🌍 Changing language to:', lang.code);
|
||||
window.i18n.setLanguage(lang.code);
|
||||
// Refresh settings menu to update colors
|
||||
this.toggleSettingsMenu();
|
||||
|
||||
// Refresh UI bars with new language
|
||||
this.refreshUIBars();
|
||||
|
||||
// Close settings menu
|
||||
this.toggleSettingsMenu();
|
||||
|
||||
// Close pause menu and resume game
|
||||
if (this.pauseMenuActive) {
|
||||
this.togglePauseMenu();
|
||||
}
|
||||
|
||||
console.log('✅ Language changed and game resumed!');
|
||||
});
|
||||
|
||||
this.settingsContainer.add(btn);
|
||||
@@ -1920,8 +1985,11 @@ class UIScene extends Phaser.Scene {
|
||||
}
|
||||
|
||||
togglePauseMenu() {
|
||||
console.log('🎮 Toggle Pause Menu - Active:', this.pauseMenuActive);
|
||||
|
||||
if (this.pauseMenuActive) {
|
||||
// Close pause menu
|
||||
console.log('📴 Closing pause menu...');
|
||||
if (this.pauseMenuContainer) {
|
||||
this.pauseMenuContainer.destroy();
|
||||
this.pauseMenuContainer = null;
|
||||
@@ -1931,15 +1999,18 @@ class UIScene extends Phaser.Scene {
|
||||
// Resume game
|
||||
if (this.gameScene) {
|
||||
this.gameScene.physics.resume();
|
||||
console.log('▶️ Game resumed!');
|
||||
}
|
||||
} else {
|
||||
// Open pause menu
|
||||
console.log('⏸️ Opening pause menu...');
|
||||
this.createPauseMenu();
|
||||
this.pauseMenuActive = true;
|
||||
|
||||
// Pause game
|
||||
if (this.gameScene) {
|
||||
this.gameScene.physics.pause();
|
||||
console.log('⏸️ Game paused!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1957,28 +2028,30 @@ class UIScene extends Phaser.Scene {
|
||||
this.pauseMenuContainer.setScrollFactor(0);
|
||||
this.pauseMenuContainer.setDepth(15000);
|
||||
|
||||
// Semi-transparent background
|
||||
const bg = this.add.rectangle(0, 0, width, height, 0x000000, 0.85);
|
||||
// Warm semi-transparent background (Stardew style)
|
||||
const bg = this.add.rectangle(0, 0, width, height, 0x2d1b00, 0.85);
|
||||
bg.setOrigin(0);
|
||||
this.pauseMenuContainer.add(bg);
|
||||
|
||||
// Panel
|
||||
const panelW = 500;
|
||||
const panelH = 550;
|
||||
// Wooden panel
|
||||
const panelW = 450;
|
||||
const panelH = 500;
|
||||
const panelX = width / 2 - panelW / 2;
|
||||
const panelY = height / 2 - panelH / 2;
|
||||
|
||||
const panel = this.add.rectangle(panelX, panelY, panelW, panelH, 0x1a1a2e, 1);
|
||||
const panel = this.add.rectangle(panelX, panelY, panelW, panelH, 0x6b4423, 1);
|
||||
panel.setOrigin(0);
|
||||
panel.setStrokeStyle(4, 0x00ff41);
|
||||
panel.setStrokeStyle(4, 0xd4a574);
|
||||
this.pauseMenuContainer.add(panel);
|
||||
|
||||
// Title
|
||||
const title = this.add.text(width / 2, panelY + 40, '⏸️ ' + window.i18n.t('pause.title', 'PAUSED'), {
|
||||
fontSize: '48px',
|
||||
fontFamily: 'Courier New',
|
||||
color: '#00ff41',
|
||||
fontStyle: 'bold'
|
||||
const title = this.add.text(width / 2, panelY + 50, window.i18n.t('pause.title', 'PAUSED'), {
|
||||
fontSize: '42px',
|
||||
fontFamily: 'Georgia, serif',
|
||||
color: '#f4e4c1',
|
||||
fontStyle: 'bold',
|
||||
stroke: '#2d1b00',
|
||||
strokeThickness: 4
|
||||
});
|
||||
title.setOrigin(0.5);
|
||||
this.pauseMenuContainer.add(title);
|
||||
@@ -1987,74 +2060,83 @@ class UIScene extends Phaser.Scene {
|
||||
const buttons = [
|
||||
{
|
||||
label: window.i18n.t('pause.resume', '▶ Resume'),
|
||||
color: '#00ff41',
|
||||
color: '#8fbc8f',
|
||||
action: () => this.togglePauseMenu()
|
||||
},
|
||||
{
|
||||
label: window.i18n.t('pause.save', '💾 Save Game'),
|
||||
color: '#4477ff',
|
||||
color: '#87ceeb',
|
||||
action: () => this.saveGame()
|
||||
},
|
||||
{
|
||||
label: window.i18n.t('pause.settings', '⚙️ Settings'),
|
||||
color: '#ffaa00',
|
||||
color: '#daa520',
|
||||
action: () => { this.togglePauseMenu(); this.toggleSettingsMenu(); }
|
||||
},
|
||||
{
|
||||
label: window.i18n.t('pause.quit', '🚪 Quit to Menu'),
|
||||
color: '#ff4444',
|
||||
color: '#cd5c5c',
|
||||
action: () => this.quitToMenu()
|
||||
}
|
||||
];
|
||||
|
||||
const startY = panelY + 150;
|
||||
const spacing = 90;
|
||||
const startY = panelY + 140;
|
||||
const spacing = 80;
|
||||
|
||||
buttons.forEach((btn, index) => {
|
||||
const y = startY + (index * spacing);
|
||||
|
||||
// Button background
|
||||
const btnBg = this.add.rectangle(width / 2, y, 400, 70, 0x2a2a4e, 1);
|
||||
btnBg.setStrokeStyle(3, btn.color);
|
||||
// Wooden button background
|
||||
const btnBg = this.add.rectangle(width / 2, y, 350, 60, 0x4a3520, 1);
|
||||
btnBg.setStrokeStyle(3, 0xd4a574);
|
||||
|
||||
// Inner shadow
|
||||
const innerShadow = this.add.rectangle(width / 2, y + 2, 340, 50, 0x2d1b00, 0.3);
|
||||
|
||||
// Button text
|
||||
const btnText = this.add.text(width / 2, y, btn.label, {
|
||||
fontSize: '28px',
|
||||
fontFamily: 'Courier New',
|
||||
fontSize: '24px',
|
||||
fontFamily: 'Georgia, serif',
|
||||
color: btn.color,
|
||||
fontStyle: 'bold'
|
||||
fontStyle: 'bold',
|
||||
stroke: '#2d1b00',
|
||||
strokeThickness: 3
|
||||
});
|
||||
btnText.setOrigin(0.5);
|
||||
|
||||
// Make interactive
|
||||
btnBg.setInteractive({ useHandCursor: true });
|
||||
btnBg.on('pointerover', () => {
|
||||
btnBg.setFillStyle(0x3a3a6e);
|
||||
btnBg.setFillStyle(0x6b4423);
|
||||
btnText.setScale(1.05);
|
||||
btnBg.setStrokeStyle(4, 0xf4e4c1);
|
||||
});
|
||||
btnBg.on('pointerout', () => {
|
||||
btnBg.setFillStyle(0x2a2a4e);
|
||||
btnBg.setFillStyle(0x4a3520);
|
||||
btnText.setScale(1.0);
|
||||
btnBg.setStrokeStyle(3, 0xd4a574);
|
||||
});
|
||||
btnBg.on('pointerdown', () => {
|
||||
this.tweens.add({
|
||||
targets: btnBg,
|
||||
alpha: 0.5,
|
||||
yoyo: true,
|
||||
targets: [btnBg, btnText, innerShadow],
|
||||
y: y + 3,
|
||||
duration: 100,
|
||||
yoyo: true,
|
||||
onComplete: btn.action
|
||||
});
|
||||
});
|
||||
|
||||
this.pauseMenuContainer.add(innerShadow);
|
||||
this.pauseMenuContainer.add(btnBg);
|
||||
this.pauseMenuContainer.add(btnText);
|
||||
});
|
||||
|
||||
// Hint text
|
||||
const hint = this.add.text(width / 2, panelY + panelH - 30, window.i18n.t('pause.hint', 'Press ESC to resume'), {
|
||||
fontSize: '16px',
|
||||
fontFamily: 'Courier New',
|
||||
color: '#888888'
|
||||
const hint = this.add.text(width / 2, panelY + panelH - 40, window.i18n.t('pause.hint', 'Press ESC to resume'), {
|
||||
fontSize: '14px',
|
||||
fontFamily: 'Georgia, serif',
|
||||
color: '#d4a574',
|
||||
fontStyle: 'italic'
|
||||
});
|
||||
hint.setOrigin(0.5);
|
||||
this.pauseMenuContainer.add(hint);
|
||||
@@ -2099,8 +2181,8 @@ class UIScene extends Phaser.Scene {
|
||||
// ========== NEW: ZOMBIE & FARM STATS PANELS ==========
|
||||
|
||||
createZombieStatsPanel() {
|
||||
const panelWidth = 220;
|
||||
const panelHeight = 140;
|
||||
const panelWidth = 180;
|
||||
const panelHeight = 130;
|
||||
const x = 20;
|
||||
const y = 120; // Below player stats
|
||||
|
||||
@@ -2117,8 +2199,8 @@ class UIScene extends Phaser.Scene {
|
||||
this.zombieStatsContainer.add(bg);
|
||||
|
||||
// Title
|
||||
const title = this.add.text(panelWidth / 2, 15, '🧟 ZOMBIE WORKER', {
|
||||
fontSize: '14px',
|
||||
const title = this.add.text(panelWidth / 2, 12, '🧟 ZOMBIE', {
|
||||
fontSize: '12px',
|
||||
fontFamily: 'Courier New',
|
||||
fill: '#8a2be2',
|
||||
fontStyle: 'bold'
|
||||
@@ -2126,29 +2208,29 @@ class UIScene extends Phaser.Scene {
|
||||
this.zombieStatsContainer.add(title);
|
||||
|
||||
// Stats Text
|
||||
this.zombieNameText = this.add.text(10, 35, 'Name: Worker #1', {
|
||||
fontSize: '12px',
|
||||
this.zombieNameText = this.add.text(8, 30, 'Name: Worker #1', {
|
||||
fontSize: '10px',
|
||||
fill: '#ffffff'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieNameText);
|
||||
|
||||
this.zombieTaskText = this.add.text(10, 55, 'Task: IDLE', {
|
||||
fontSize: '12px',
|
||||
this.zombieTaskText = this.add.text(8, 48, 'Task: IDLE', {
|
||||
fontSize: '10px',
|
||||
fill: '#ffff00'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieTaskText);
|
||||
|
||||
this.zombieLevelText = this.add.text(10, 75, 'Level: 1 (0/100 XP)', {
|
||||
fontSize: '12px',
|
||||
this.zombieLevelText = this.add.text(8, 66, 'Level: 1 (0/100 XP)', {
|
||||
fontSize: '10px',
|
||||
fill: '#00ff00'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieLevelText);
|
||||
|
||||
// Energy Bar
|
||||
const energyLabel = this.add.text(10, 95, 'ENERGY:', { fontSize: '11px', fill: '#aaaaaa' });
|
||||
const energyLabel = this.add.text(8, 84, 'ENERGY:', { fontSize: '9px', fill: '#aaaaaa' });
|
||||
this.zombieStatsContainer.add(energyLabel);
|
||||
|
||||
this.zombieEnergyBar = this.drawMiniBar(10, 110, panelWidth - 20, 15, 0x00aaff, 100);
|
||||
this.zombieEnergyBar = this.drawMiniBar(8, 98, panelWidth - 16, 12, 0x00aaff, 100);
|
||||
this.zombieStatsContainer.add(this.zombieEnergyBar.bg);
|
||||
this.zombieStatsContainer.add(this.zombieEnergyBar.fill);
|
||||
|
||||
@@ -2157,10 +2239,10 @@ class UIScene extends Phaser.Scene {
|
||||
}
|
||||
|
||||
createFarmStatsPanel() {
|
||||
const panelWidth = 220;
|
||||
const panelHeight = 120;
|
||||
const panelWidth = 180;
|
||||
const panelHeight = 110;
|
||||
const x = 20;
|
||||
const y = 280; // Below zombie stats
|
||||
const y = 270; // Below zombie stats
|
||||
|
||||
// Container
|
||||
this.farmStatsContainer = this.add.container(x, y);
|
||||
@@ -2175,8 +2257,8 @@ class UIScene extends Phaser.Scene {
|
||||
this.farmStatsContainer.add(bg);
|
||||
|
||||
// Title
|
||||
const title = this.add.text(panelWidth / 2, 15, '🌾 FARM STATS', {
|
||||
fontSize: '14px',
|
||||
const title = this.add.text(panelWidth / 2, 12, '🌾 FARM', {
|
||||
fontSize: '12px',
|
||||
fontFamily: 'Courier New',
|
||||
fill: '#00ff00',
|
||||
fontStyle: 'bold'
|
||||
@@ -2184,26 +2266,26 @@ class UIScene extends Phaser.Scene {
|
||||
this.farmStatsContainer.add(title);
|
||||
|
||||
// Stats
|
||||
this.farmCropsPlantedText = this.add.text(10, 40, 'Crops Planted: 0', {
|
||||
fontSize: '12px',
|
||||
this.farmCropsPlantedText = this.add.text(8, 32, 'Planted: 0', {
|
||||
fontSize: '10px',
|
||||
fill: '#ffffff'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmCropsPlantedText);
|
||||
|
||||
this.farmCropsHarvestedText = this.add.text(10, 60, 'Total Harvested: 0', {
|
||||
fontSize: '12px',
|
||||
this.farmCropsHarvestedText = this.add.text(8, 50, 'Harvested: 0', {
|
||||
fontSize: '10px',
|
||||
fill: '#ffff00'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmCropsHarvestedText);
|
||||
|
||||
this.farmGoldEarnedText = this.add.text(10, 80, 'Gold Earned: 0g', {
|
||||
fontSize: '12px',
|
||||
this.farmGoldEarnedText = this.add.text(8, 68, 'Gold: 0g', {
|
||||
fontSize: '10px',
|
||||
fill: '#ffd700'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmGoldEarnedText);
|
||||
|
||||
this.farmDaysText = this.add.text(10, 100, 'Days Farmed: 0', {
|
||||
fontSize: '12px',
|
||||
this.farmDaysText = this.add.text(8, 86, 'Days: 0', {
|
||||
fontSize: '10px',
|
||||
fill: '#aaaaaa'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmDaysText);
|
||||
@@ -2252,10 +2334,10 @@ class UIScene extends Phaser.Scene {
|
||||
updateFarmStats(stats) {
|
||||
if (!stats || !this.farmStatsContainer) return;
|
||||
|
||||
if (this.farmCropsPlantedText) this.farmCropsPlantedText.setText(`Crops Planted: ${stats.cropsPlanted || 0}`);
|
||||
if (this.farmCropsHarvestedText) this.farmCropsHarvestedText.setText(`Total Harvested: ${stats.totalHarvested || 0}`);
|
||||
if (this.farmGoldEarnedText) this.farmGoldEarnedText.setText(`Gold Earned: ${stats.goldEarned || 0}g`);
|
||||
if (this.farmDaysText) this.farmDaysText.setText(`Days Farmed: ${stats.daysFarmed || 0}`);
|
||||
if (this.farmCropsPlantedText) this.farmCropsPlantedText.setText(`Planted: ${stats.cropsPlanted || 0}`);
|
||||
if (this.farmCropsHarvestedText) this.farmCropsHarvestedText.setText(`Harvested: ${stats.totalHarvested || 0}`);
|
||||
if (this.farmGoldEarnedText) this.farmGoldEarnedText.setText(`Gold: ${stats.goldEarned || 0}g`);
|
||||
if (this.farmDaysText) this.farmDaysText.setText(`Days: ${stats.daysFarmed || 0}`);
|
||||
}
|
||||
|
||||
createMinimap() {
|
||||
@@ -2365,5 +2447,108 @@ class UIScene extends Phaser.Scene {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Q/E Tool Swap Methods
|
||||
swapToolPrevious() {
|
||||
if (!this.gameScene || !this.gameScene.inventorySystem) return;
|
||||
const inv = this.gameScene.inventorySystem;
|
||||
|
||||
// Cycle backwards
|
||||
let newSlot = inv.selectedSlot - 1;
|
||||
if (newSlot < 0) newSlot = 8;
|
||||
|
||||
this.selectSlot(newSlot);
|
||||
|
||||
// Sound effect
|
||||
if (this.gameScene.soundManager) {
|
||||
this.gameScene.soundManager.beepUIClick();
|
||||
}
|
||||
|
||||
console.log(`🔄 Tool swap: Slot ${newSlot}`);
|
||||
}
|
||||
|
||||
swapToolNext() {
|
||||
if (!this.gameScene || !this.gameScene.inventorySystem) return;
|
||||
const inv = this.gameScene.inventorySystem;
|
||||
|
||||
// Cycle forwards
|
||||
let newSlot = inv.selectedSlot + 1;
|
||||
if (newSlot > 8) newSlot = 0;
|
||||
|
||||
this.selectSlot(newSlot);
|
||||
|
||||
// Sound effect
|
||||
if (this.gameScene.soundManager) {
|
||||
this.gameScene.soundManager.beepUIClick();
|
||||
}
|
||||
|
||||
console.log(`🔄 Tool swap: Slot ${newSlot}`);
|
||||
}
|
||||
|
||||
// Equipment Preview
|
||||
createEquipmentPreview() {
|
||||
const previewX = 20;
|
||||
const previewY = 150;
|
||||
|
||||
// Background
|
||||
this.equipmentBg = this.add.graphics();
|
||||
this.equipmentBg.fillStyle(0x000000, 0.6);
|
||||
this.equipmentBg.fillRoundedRect(previewX, previewY, 80, 80, 8);
|
||||
this.equipmentBg.setScrollFactor(0);
|
||||
this.equipmentBg.setDepth(1000);
|
||||
|
||||
// Label
|
||||
this.equipmentLabel = this.add.text(
|
||||
previewX + 40,
|
||||
previewY - 5,
|
||||
'EQUIPPED',
|
||||
{
|
||||
font: 'bold 10px Arial',
|
||||
fill: '#ffff00'
|
||||
}
|
||||
);
|
||||
this.equipmentLabel.setOrigin(0.5, 1);
|
||||
this.equipmentLabel.setScrollFactor(0);
|
||||
this.equipmentLabel.setDepth(1001);
|
||||
|
||||
// Icon sprite placeholder
|
||||
this.equipmentIcon = this.add.rectangle(previewX + 40, previewY + 40, 32, 32, 0x888888);
|
||||
this.equipmentIcon.setScrollFactor(0);
|
||||
this.equipmentIcon.setDepth(1001);
|
||||
|
||||
// Tool name
|
||||
this.equipmentName = this.add.text(
|
||||
previewX + 40,
|
||||
previewY + 75,
|
||||
'None',
|
||||
{
|
||||
font: 'bold 12px Arial',
|
||||
fill: '#ffffff'
|
||||
}
|
||||
);
|
||||
this.equipmentName.setOrigin(0.5, 0);
|
||||
this.equipmentName.setScrollFactor(0);
|
||||
this.equipmentName.setDepth(1001);
|
||||
|
||||
console.log('🎮 Equipment preview created!');
|
||||
}
|
||||
|
||||
updateEquipmentPreview() {
|
||||
if (!this.gameScene || !this.gameScene.inventorySystem) return;
|
||||
if (!this.equipmentName) return;
|
||||
|
||||
const inv = this.gameScene.inventorySystem;
|
||||
const selectedItem = inv.items[inv.selectedSlot];
|
||||
|
||||
if (selectedItem) {
|
||||
// Update name
|
||||
this.equipmentName.setText(selectedItem.name || selectedItem.id);
|
||||
this.equipmentIcon.setVisible(true);
|
||||
this.equipmentName.setVisible(true);
|
||||
} else {
|
||||
// Hide if no item
|
||||
this.equipmentName.setText('None');
|
||||
this.equipmentIcon.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user