posodobitev
This commit is contained in:
160
tools/ui_panels_code.js
Normal file
160
tools/ui_panels_code.js
Normal file
@@ -0,0 +1,160 @@
|
||||
// ZOMBIE & FARM STATS PANELS - Add to UIScene.js
|
||||
|
||||
// Call this in create() method:
|
||||
createZombieStatsPanel() {
|
||||
const panelWidth = 220;
|
||||
const panelHeight = 140;
|
||||
const x = 20;
|
||||
const y = 120; // Below player stats
|
||||
|
||||
// Container
|
||||
this.zombieStatsContainer = this.add.container(x, y);
|
||||
this.zombieStatsContainer.setDepth(1000);
|
||||
|
||||
// Background
|
||||
const bg = this.add.graphics();
|
||||
bg.fillStyle(0x1a1a2e, 0.9);
|
||||
bg.fillRect(0, 0, panelWidth, panelHeight);
|
||||
bg.lineStyle(2, 0x8a2be2, 0.8); // Purple border (zombie theme)
|
||||
bg.strokeRect(0, 0, panelWidth, panelHeight);
|
||||
this.zombieStatsContainer.add(bg);
|
||||
|
||||
// Title
|
||||
const title = this.add.text(panelWidth / 2, 15, '🧟 ZOMBIE WORKER', {
|
||||
fontSize: '14px',
|
||||
fontFamily: 'Courier New',
|
||||
fill: '#8a2be2',
|
||||
fontStyle: 'bold'
|
||||
}).setOrigin(0.5);
|
||||
this.zombieStatsContainer.add(title);
|
||||
|
||||
// Stats Text
|
||||
this.zombieNameText = this.add.text(10, 35, 'Name: Worker #1', {
|
||||
fontSize: '12px',
|
||||
fill: '#ffffff'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieNameText);
|
||||
|
||||
this.zombieTaskText = this.add.text(10, 55, 'Task: IDLE', {
|
||||
fontSize: '12px',
|
||||
fill: '#ffff00'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieTaskText);
|
||||
|
||||
this.zombieLevelText = this.add.text(10, 75, 'Level: 1 (0/100 XP)', {
|
||||
fontSize: '12px',
|
||||
fill: '#00ff00'
|
||||
});
|
||||
this.zombieStatsContainer.add(this.zombieLevelText);
|
||||
|
||||
// Energy Bar
|
||||
this.add.text(10, 95, 'ENERGY:', { fontSize: '11px', fill: '#aaaaaa' });
|
||||
this.zombieEnergyBar = this.drawMiniBar(10, 110, panelWidth - 20, 15, 0x00aaff, 100);
|
||||
this.zombieStatsContainer.add(this.zombieEnergyBar.bg);
|
||||
this.zombieStatsContainer.add(this.zombieEnergyBar.fill);
|
||||
|
||||
// Initially hidden - shows when zombie is selected/nearby
|
||||
this.zombieStatsContainer.setVisible(false);
|
||||
}
|
||||
|
||||
createFarmStatsPanel() {
|
||||
const panelWidth = 220;
|
||||
const panelHeight = 120;
|
||||
const x = 20;
|
||||
const y = 280; // Below zombie stats
|
||||
|
||||
// Container
|
||||
this.farmStatsContainer = this.add.container(x, y);
|
||||
this.farmStatsContainer.setDepth(1000);
|
||||
|
||||
// Background
|
||||
const bg = this.add.graphics();
|
||||
bg.fillStyle(0x1a2e1a, 0.9);
|
||||
bg.fillRect(0, 0, panelWidth, panelHeight);
|
||||
bg.lineStyle(2, 0x00ff00, 0.8); // Green border (farm theme)
|
||||
bg.strokeRect(0, 0, panelWidth, panelHeight);
|
||||
this.farmStatsContainer.add(bg);
|
||||
|
||||
// Title
|
||||
const title = this.add.text(panelWidth / 2, 15, '🌾 FARM STATS', {
|
||||
fontSize: '14px',
|
||||
fontFamily: 'Courier New',
|
||||
fill: '#00ff00',
|
||||
fontStyle: 'bold'
|
||||
}).setOrigin(0.5);
|
||||
this.farmStatsContainer.add(title);
|
||||
|
||||
// Stats
|
||||
this.farmCropsPlantedText = this.add.text(10, 40, 'Crops Planted: 0', {
|
||||
fontSize: '12px',
|
||||
fill: '#ffffff'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmCropsPlantedText);
|
||||
|
||||
this.farmCropsHarvestedText = this.add.text(10, 60, 'Total Harvested: 0', {
|
||||
fontSize: '12px',
|
||||
fill: '#ffff00'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmCropsHarvestedText);
|
||||
|
||||
this.farmGoldEarnedText = this.add.text(10, 80, 'Gold Earned: 0g', {
|
||||
fontSize: '12px',
|
||||
fill: '#ffd700'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmGoldEarnedText);
|
||||
|
||||
this.farmDaysText = this.add.text(10, 100, 'Days Farmed: 0', {
|
||||
fontSize: '12px',
|
||||
fill: '#aaaaaa'
|
||||
});
|
||||
this.farmStatsContainer.add(this.farmDaysText);
|
||||
}
|
||||
|
||||
drawMiniBar(x, y, width, height, color, initialPercent = 100) {
|
||||
// Background
|
||||
const bg = this.add.graphics();
|
||||
bg.fillStyle(0x000000, 0.5);
|
||||
bg.fillRect(x, y, width, height);
|
||||
bg.lineStyle(1, 0xffffff, 0.3);
|
||||
bg.strokeRect(x, y, width, height);
|
||||
|
||||
// Fill
|
||||
const fill = this.add.graphics();
|
||||
fill.fillStyle(color, 1);
|
||||
const maxWidth = width - 4;
|
||||
const currentWidth = (maxWidth * initialPercent) / 100;
|
||||
fill.fillRect(x + 2, y + 2, currentWidth, height - 4);
|
||||
|
||||
return { bg, fill, x, y, width, height, color };
|
||||
}
|
||||
|
||||
setMiniBarValue(bar, percent) {
|
||||
percent = Phaser.Math.Clamp(percent, 0, 100);
|
||||
bar.fill.clear();
|
||||
bar.fill.fillStyle(bar.color, 1);
|
||||
const maxWidth = bar.width - 4;
|
||||
const currentWidth = (maxWidth * percent) / 100;
|
||||
bar.fill.fillRect(bar.x + 2, bar.y + 2, currentWidth, bar.height - 4);
|
||||
}
|
||||
|
||||
// Update methods (call from update())
|
||||
updateZombieStats(zombie) {
|
||||
if (!zombie || !this.zombieStatsContainer) return;
|
||||
|
||||
this.zombieStatsContainer.setVisible(true);
|
||||
this.zombieNameText.setText(`Name: ${zombie.name || 'Worker #1'}`);
|
||||
this.zombieTaskText.setText(`Task: ${zombie.task || 'IDLE'}`);
|
||||
this.zombieLevelText.setText(`Level: ${zombie.level || 1} (${zombie.xp || 0}/100 XP)`);
|
||||
|
||||
const energy = zombie.energy !== undefined ? zombie.energy : 100;
|
||||
this.setMiniBarValue(this.zombieEnergyBar, energy);
|
||||
}
|
||||
|
||||
updateFarmStats(stats) {
|
||||
if (!stats || !this.farmStatsContainer) return;
|
||||
|
||||
this.farmCropsPlantedText.setText(`Crops Planted: ${stats.cropsPlanted || 0}`);
|
||||
this.farmCropsHarvestedText.setText(`Total Harvested: ${stats.totalHarvested || 0}`);
|
||||
this.farmGoldEarnedText.setText(`Gold Earned: ${stats.goldEarned || 0}g`);
|
||||
this.farmDaysText.setText(`Days Farmed: ${stats.daysFarmed || 0}`);
|
||||
}
|
||||
Reference in New Issue
Block a user