import Phaser from 'phaser'; import * as utils from '../utils'; /** * Game Complete UI Scene - All Levels Completed Screen * This file is a STANDARD TEMPLATE * * Displayed when player completes the final level * Returns to title screen on Enter/Space/Click * * TODO for AI: Customize createDOMUI() to match game theme */ export class GameCompleteUIScene extends Phaser.Scene { private currentLevelKey: string | null; private isTransitioning: boolean; private uiContainer: Phaser.GameObjects.DOMElement | null; private enterKey?: Phaser.Input.Keyboard.Key; private spaceKey?: Phaser.Input.Keyboard.Key; constructor() { super({ key: 'GameCompleteUIScene', }); this.currentLevelKey = null; this.isTransitioning = false; this.uiContainer = null; } /** * Receive current level key from game scene */ init(data: { currentLevelKey?: string }) { this.currentLevelKey = data.currentLevelKey || 'Level1Scene'; // Reset transition flag this.isTransitioning = false; } create(): void { // Create DOM UI this.createDOMUI(); // Setup input controls this.setupInputs(); } /** * TODO: Customize the game complete screen appearance * This is the celebration screen for completing the entire game! * Keep the overall structure but modify: * - Colors and styles (typically celebratory/golden theme) * - Animations (more elaborate than regular victory) * - Text content */ createDOMUI(): void { const uiHTML = `
GAME COMPLETE!
Congratulations!
You have completed all levels!
PRESS ENTER TO RETURN TO MENU
`; // Add DOM element to scene - MUST use utils.initUIDom this.uiContainer = utils.initUIDom(this, uiHTML); } /** * Standard input setup - DO NOT MODIFY */ setupInputs(): void { // Clear previous event listeners this.input.off('pointerdown'); // Create keyboard input this.enterKey = this.input.keyboard!.addKey( Phaser.Input.Keyboard.KeyCodes.ENTER, ); this.spaceKey = this.input.keyboard!.addKey( Phaser.Input.Keyboard.KeyCodes.SPACE, ); // Listen for mouse click events this.input.on('pointerdown', () => this.returnToMenu()); // Listen for key events this.enterKey.on('down', () => this.returnToMenu()); this.spaceKey.on('down', () => this.returnToMenu()); } /** * Return to title screen - DO NOT MODIFY structure */ returnToMenu(): void { // Prevent multiple triggers if (this.isTransitioning) return; this.isTransitioning = true; console.log('Returning to title screen'); // Stop current level's background music const currentScene = this.scene.get(this.currentLevelKey!) as any; if (currentScene?.backgroundMusic) { currentScene.backgroundMusic.stop(); } // Clear event listeners this.input.off('pointerdown'); if (this.enterKey) { this.enterKey.off('down'); } if (this.spaceKey) { this.spaceKey.off('down'); } // Stop all game-related scenes this.scene.stop('UIScene'); this.scene.stop(this.currentLevelKey!); // Start title screen this.scene.start('TitleScreen'); } update(): void { // Game Complete UI scene doesn't need special update logic } }