dodatki
This commit is contained in:
@@ -7,66 +7,90 @@ class StoryScene extends Phaser.Scene {
|
||||
const width = this.cameras.main.width;
|
||||
const height = this.cameras.main.height;
|
||||
|
||||
// Black background
|
||||
this.add.rectangle(0, 0, width, height, 0x000000).setOrigin(0);
|
||||
// Dark background with gradient
|
||||
const bg = this.add.rectangle(0, 0, width, height, 0x0a0a0a);
|
||||
bg.setOrigin(0);
|
||||
|
||||
const storyText =
|
||||
`LETO 2084.
|
||||
SVET JE PADEL V TEMO.
|
||||
|
||||
Virus je večino spremenil v pošasti.
|
||||
Mesta so grobnice.
|
||||
|
||||
Toda našel si upanje.
|
||||
Zapuščeno kmetijo na robu divjine.
|
||||
Zadnje varno zatočišče.
|
||||
|
||||
Tvoja naloga:
|
||||
1. Obnovi kmetijo in preživi.
|
||||
2. Zgradi obrambo pred hordo.
|
||||
3. Najdi zdravilo in reši svet.
|
||||
|
||||
Pripravi se... NOČ PRIHAJA.`;
|
||||
|
||||
const textObj = this.add.text(width / 2, height, storyText, {
|
||||
// Title
|
||||
const title = this.add.text(width / 2, 80, 'NOVAFARMA', {
|
||||
fontSize: '72px',
|
||||
fontFamily: 'Courier New',
|
||||
fontSize: '28px',
|
||||
fill: '#00ff41',
|
||||
align: 'center',
|
||||
lineSpacing: 15,
|
||||
color: '#00ff41',
|
||||
fontStyle: 'bold',
|
||||
stroke: '#000000',
|
||||
strokeThickness: 4
|
||||
strokeThickness: 6
|
||||
});
|
||||
textObj.setOrigin(0.5, 0);
|
||||
title.setOrigin(0.5);
|
||||
|
||||
// Scroll animation
|
||||
this.tweens.add({
|
||||
targets: textObj,
|
||||
y: 50,
|
||||
duration: 15000, // 15s scroll
|
||||
ease: 'Linear',
|
||||
onComplete: () => {
|
||||
this.time.delayedCall(2000, () => {
|
||||
this.scene.start('GameScene');
|
||||
});
|
||||
}
|
||||
// Subtitle
|
||||
const subtitle = this.add.text(width / 2, 150, '2084 - Survival Farm', {
|
||||
fontSize: '20px',
|
||||
fontFamily: 'Courier New',
|
||||
color: '#888888'
|
||||
});
|
||||
subtitle.setOrigin(0.5);
|
||||
|
||||
// Skip instructions
|
||||
const skip = this.add.text(width - 20, height - 20, '[SPACE] Skip', {
|
||||
fontSize: '16px', fill: '#666'
|
||||
}).setOrigin(1);
|
||||
// Main Menu Buttons
|
||||
this.createMainMenu(width, height);
|
||||
|
||||
// LANGUAGE SELECTOR
|
||||
// Language selector (bottom)
|
||||
this.createLanguageSelector(width, height);
|
||||
|
||||
// Input to skip
|
||||
this.input.keyboard.on('keydown-SPACE', () => {
|
||||
this.scene.start('GameScene');
|
||||
// Version info
|
||||
const version = this.add.text(10, height - 30, 'v0.9.0 ALPHA', {
|
||||
fontSize: '14px',
|
||||
color: '#444444',
|
||||
fontFamily: 'Courier New'
|
||||
});
|
||||
}
|
||||
|
||||
this.input.on('pointerdown', () => {
|
||||
this.scene.start('GameScene');
|
||||
createMainMenu(width, height) {
|
||||
const buttons = [
|
||||
{ label: '▶ NEW GAME', color: '#00ff41', action: () => this.startNewGame() },
|
||||
{ label: '📁 LOAD GAME', color: '#4477ff', action: () => this.loadGame() },
|
||||
{ label: '⚙️ SETTINGS', color: '#ffaa00', action: () => this.showSettings() },
|
||||
{ label: '❌ EXIT', color: '#ff4444', action: () => this.exitGame() }
|
||||
];
|
||||
|
||||
const startY = 250;
|
||||
const spacing = 80;
|
||||
|
||||
buttons.forEach((btn, index) => {
|
||||
const y = startY + (index * spacing);
|
||||
|
||||
// Button background
|
||||
const bg = this.add.rectangle(width / 2, y, 400, 60, 0x1a1a2e, 1);
|
||||
bg.setStrokeStyle(3, 0x00ff41);
|
||||
|
||||
// Button text
|
||||
const text = this.add.text(width / 2, y, btn.label, {
|
||||
fontSize: '28px',
|
||||
fontFamily: 'Courier New',
|
||||
color: btn.color,
|
||||
fontStyle: 'bold'
|
||||
});
|
||||
text.setOrigin(0.5);
|
||||
|
||||
// Make interactive
|
||||
bg.setInteractive({ useHandCursor: true });
|
||||
bg.on('pointerover', () => {
|
||||
bg.setFillStyle(0x2a2a4e);
|
||||
text.setScale(1.1);
|
||||
});
|
||||
bg.on('pointerout', () => {
|
||||
bg.setFillStyle(0x1a1a2e);
|
||||
text.setScale(1.0);
|
||||
});
|
||||
bg.on('pointerdown', () => {
|
||||
// Flash effect
|
||||
this.tweens.add({
|
||||
targets: bg,
|
||||
alpha: 0.5,
|
||||
yoyo: true,
|
||||
duration: 100,
|
||||
onComplete: btn.action
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,6 +100,45 @@ Pripravi se... NOČ PRIHAJA.`;
|
||||
window.i18n = new LocalizationSystem();
|
||||
}
|
||||
|
||||
// Globe button (bottom-right)
|
||||
const globeBtn = this.add.text(width - 80, height - 60, '🌍', {
|
||||
fontSize: '48px'
|
||||
});
|
||||
globeBtn.setOrigin(0.5);
|
||||
globeBtn.setInteractive({ useHandCursor: true });
|
||||
|
||||
let langMenuOpen = false;
|
||||
let langMenu = null;
|
||||
|
||||
globeBtn.on('pointerover', () => {
|
||||
globeBtn.setScale(1.2);
|
||||
});
|
||||
globeBtn.on('pointerout', () => {
|
||||
if (!langMenuOpen) globeBtn.setScale(1.0);
|
||||
});
|
||||
globeBtn.on('pointerdown', () => {
|
||||
if (langMenuOpen) {
|
||||
// Close menu
|
||||
if (langMenu) langMenu.destroy();
|
||||
langMenu = null;
|
||||
langMenuOpen = false;
|
||||
globeBtn.setScale(1.0);
|
||||
} else {
|
||||
// Open menu
|
||||
langMenuOpen = true;
|
||||
langMenu = this.createLanguageMenu(width, height, () => {
|
||||
langMenuOpen = false;
|
||||
globeBtn.setScale(1.0);
|
||||
if (langMenu) langMenu.destroy();
|
||||
langMenu = null;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
createLanguageMenu(width, height, onClose) {
|
||||
const container = this.add.container(0, 0);
|
||||
|
||||
const languages = [
|
||||
{ code: 'slo', flag: '🇸🇮', name: 'SLO' },
|
||||
{ code: 'en', flag: '🇬🇧', name: 'ENG' },
|
||||
@@ -84,65 +147,73 @@ Pripravi se... NOČ PRIHAJA.`;
|
||||
{ code: 'cn', flag: '🇨🇳', name: '中文' }
|
||||
];
|
||||
|
||||
const startX = 20;
|
||||
const startY = 20;
|
||||
const spacing = 80;
|
||||
const menuX = width - 220;
|
||||
const menuY = height - 350;
|
||||
const menuW = 200;
|
||||
const menuH = 280;
|
||||
|
||||
// Title
|
||||
this.add.text(startX, startY, '🌍 Language:', {
|
||||
fontSize: '18px',
|
||||
fill: '#ffffff',
|
||||
fontFamily: 'Courier New'
|
||||
});
|
||||
// Panel background
|
||||
const panel = this.add.rectangle(menuX, menuY, menuW, menuH, 0x1a1a2e, 0.98);
|
||||
panel.setStrokeStyle(3, 0x00ff41);
|
||||
container.add(panel);
|
||||
|
||||
// Language buttons
|
||||
languages.forEach((lang, index) => {
|
||||
const x = startX;
|
||||
const y = startY + 40 + (index * spacing);
|
||||
const btnY = menuY - 100 + (index * 55);
|
||||
const isActive = window.i18n.getCurrentLanguage() === lang.code;
|
||||
|
||||
// Background
|
||||
const bg = this.add.rectangle(x, y, 200, 60, 0x333333, 0.8);
|
||||
bg.setOrigin(0, 0);
|
||||
|
||||
// Flag + Name
|
||||
const text = this.add.text(x + 100, y + 30, `${lang.flag} ${lang.name}`, {
|
||||
fontSize: '24px',
|
||||
fill: window.i18n.getCurrentLanguage() === lang.code ? '#00ff41' : '#ffffff',
|
||||
fontFamily: 'Courier New'
|
||||
}).setOrigin(0.5);
|
||||
|
||||
// Make interactive
|
||||
bg.setInteractive({ useHandCursor: true });
|
||||
bg.on('pointerover', () => {
|
||||
bg.setFillStyle(0x555555, 0.9);
|
||||
text.setScale(1.1);
|
||||
const btn = this.add.text(menuX, btnY, `${lang.flag} ${lang.name}`, {
|
||||
fontSize: '20px',
|
||||
fontFamily: 'Courier New',
|
||||
color: isActive ? '#00ff41' : '#ffffff',
|
||||
backgroundColor: isActive ? '#333333' : '#1a1a2e',
|
||||
padding: { x: 15, y: 8 }
|
||||
});
|
||||
bg.on('pointerout', () => {
|
||||
bg.setFillStyle(0x333333, 0.8);
|
||||
text.setScale(1.0);
|
||||
btn.setOrigin(0.5);
|
||||
btn.setInteractive({ useHandCursor: true });
|
||||
|
||||
btn.on('pointerover', () => {
|
||||
btn.setScale(1.05);
|
||||
if (!isActive) btn.setBackgroundColor('#2a2a4e');
|
||||
});
|
||||
bg.on('pointerdown', () => {
|
||||
// Set language
|
||||
btn.on('pointerout', () => {
|
||||
btn.setScale(1.0);
|
||||
if (!isActive) btn.setBackgroundColor('#1a1a2e');
|
||||
});
|
||||
btn.on('pointerdown', () => {
|
||||
window.i18n.setLanguage(lang.code);
|
||||
|
||||
// Update all text colors
|
||||
languages.forEach((l, i) => {
|
||||
const langText = this.children.list.find(child =>
|
||||
child.text && child.text.includes(l.flag)
|
||||
);
|
||||
if (langText) {
|
||||
langText.setColor(window.i18n.getCurrentLanguage() === l.code ? '#00ff41' : '#ffffff');
|
||||
}
|
||||
});
|
||||
|
||||
// Visual feedback
|
||||
this.tweens.add({
|
||||
targets: bg,
|
||||
alpha: 0.5,
|
||||
yoyo: true,
|
||||
duration: 100
|
||||
});
|
||||
onClose();
|
||||
});
|
||||
|
||||
container.add(btn);
|
||||
});
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
startNewGame() {
|
||||
console.log('🎮 Starting New Game...');
|
||||
this.scene.start('GameScene');
|
||||
}
|
||||
|
||||
loadGame() {
|
||||
console.log('📁 Loading Game...');
|
||||
// TODO: Implement save/load system
|
||||
alert('Load Game - Coming Soon!');
|
||||
}
|
||||
|
||||
showSettings() {
|
||||
console.log('⚙️ Opening Settings...');
|
||||
// TODO: Settings menu
|
||||
alert('Settings - Use ⚙️ button in-game!');
|
||||
}
|
||||
|
||||
exitGame() {
|
||||
console.log('❌ Exiting...');
|
||||
if (window.close) {
|
||||
window.close();
|
||||
} else {
|
||||
alert('Close the window to exit.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user