diff --git a/src/scenes/PrologueScene.js b/src/scenes/PrologueScene.js index 9edfb8b42..8c483d79e 100644 --- a/src/scenes/PrologueScene.js +++ b/src/scenes/PrologueScene.js @@ -31,19 +31,12 @@ class PrologueScene extends Phaser.Scene { } preload() { - this.load.json('prologue_data', 'assets/dialogue/prologue.json'); - - // Dynamically load audio based on JSON content - this.load.on('filecomplete-json-prologue_data', (key, type, data) => { - if (Array.isArray(data)) { - data.forEach(line => { - if (line.id) { - // Assuming .wav format as generated by our script - this.load.audio(line.id, `assets/audio/voiceover/prologue/${line.id}.wav`); - } - }); - } + // Try to load JSON, but we'll use fallback if it doesn't exist + this.load.on('loaderror', (file) => { + console.warn(`⚠️ Failed to load: ${file.key}`); }); + + this.load.json('prologue_data', 'assets/dialogue/prologue.json'); } create() { @@ -51,19 +44,64 @@ class PrologueScene extends Phaser.Scene { const height = this.cameras.main.height; console.log('🎬 Starting Prologue...'); - + // Track current audio to stop it when advancing this.currentVoice = null; // Black background this.add.rectangle(0, 0, width, height, 0x000000).setOrigin(0); - // Initialize dialogue data from JSON + // Initialize dialogue data from JSON OR fallback this.dialogueData = this.cache.json.get('prologue_data'); if (!this.dialogueData) { - console.error('❌ Failed to load prologue dialogue data!'); - this.dialogueData = []; + console.warn('⚠️ Using fallback hardcoded dialogue!'); + // FALLBACK: Hardcoded Slovenian dialogue + this.dialogueData = [ + { + speaker: "NARRATOR", + text: "Leto 2084. Svet je padel.", + background: "lab", + bgColor: 0x1a1a2e, + portrait: null + }, + { + speaker: "NARRATOR", + text: "Zombi virus je uničil civilizacijo. Preživeli se borijo za vsak nov dan.", + background: "ruins", + bgColor: 0x2d1b00, + portrait: null + }, + { + speaker: "KAI", + text: "Ime mi je Kai. Z sestro Ano sva raziskovala virus... potem se je vse spremenilo.", + background: "lab", + bgColor: 0x1a1a2e, + portrait: "kai_neutral" + }, + { + speaker: "KAI", + text: "Zombiji so vdrli v laboratorij. Ana... Ana je izginila.", + background: "lab_chaos", + bgColor: 0x3d0000, + portrait: "kai_worried", + shake: true + }, + { + speaker: "KAI", + text: "Moram jo najti. Karkoli se je zgodilo... ostajam njen brat.", + background: "farm", + bgColor: 0x2d4a1e, + portrait: "kai_determined" + }, + { + speaker: "NARRATOR", + text: "In tako se začne Kaijevo potovanje skozi Mrtvo dolino...", + background: "farm", + bgColor: 0x2d4a1e, + portrait: null + } + ]; } // Create UI elements @@ -178,7 +216,7 @@ class PrologueScene extends Phaser.Scene { const dialogue = this.dialogueData[index]; this.currentDialogueIndex = index; - + // Stop previous audio if playing if (this.currentVoice) { this.currentVoice.stop(); @@ -226,11 +264,11 @@ class PrologueScene extends Phaser.Scene { // Wait for audio to finish OR standard delay? // Ideally wait for audio duration, but fallback to delay let delay = this.autoAdvanceDelay; - if (this.currentVoice && this.currentVoice.duration) { + if (this.currentVoice && this.currentVoice.duration) { // Add a small buffer after speech ends - delay = (this.currentVoice.duration * 1000) + 1000; + delay = (this.currentVoice.duration * 1000) + 1000; } - + this.time.delayedCall(delay, () => { // Check if user hasn't already advanced manually if (this.currentDialogueIndex === index) { @@ -246,11 +284,11 @@ class PrologueScene extends Phaser.Scene { let charIndex = 0; this.dialogueText.setText(''); - + // Safety check for empty text if (!text) { - this.canAdvance = true; - return; + this.canAdvance = true; + return; } const timer = this.time.addEvent({ @@ -359,7 +397,7 @@ class PrologueScene extends Phaser.Scene { this.canAdvance = true; return; } - + // Stop current audio before advancing if (this.currentVoice) { this.currentVoice.stop();