feat: Implement win/lose conditions with animated game over screens and reduce level selection to 4 levels
- Added win/lose game over screens with animated text effects and fade transitions - Implemented victory condition detection after wave completion with 5 second delay - Reduced level selection menu from 10 to 4 levels - Added post-level timer logic for win condition verification
This commit is contained in:
parent
df10eb1abe
commit
567376f8e9
|
|
@ -111,8 +111,101 @@ export class Level extends Phaser.Scene {
|
|||
this.towerManager.update(time, delta);
|
||||
}
|
||||
|
||||
gameOver() {
|
||||
console.log('GAME OVER');
|
||||
gameOver(type = 'defeat') {
|
||||
if (type === 'win') {
|
||||
const winText1 = this.add.text(800, 300, `Congratulations!`, {
|
||||
fontFamily: 'neuropol, arial',
|
||||
fontSize: '128px',
|
||||
fill: '#ffd900ff',
|
||||
stroke: '#c48f00ff',
|
||||
strokeThickness: 2,
|
||||
shadow: {
|
||||
offsetX: 5,
|
||||
offsetY: 5,
|
||||
color: '#000000',
|
||||
blur: 5,
|
||||
stroke: false,
|
||||
fill: true
|
||||
}
|
||||
}).setOrigin(0.5).setScrollFactor(0).setAlpha(0);
|
||||
const winText2 = this.add.text(800, 450, `You have defeated the alien invasion!`, {
|
||||
fontFamily: 'neuropol, arial',
|
||||
fontSize: '56px',
|
||||
fill: '#ffd900ff',
|
||||
stroke: '#c48f00ff',
|
||||
strokeThickness: 2,
|
||||
shadow: {
|
||||
offsetX: 5,
|
||||
offsetY: 5,
|
||||
color: '#000000',
|
||||
blur: 5,
|
||||
stroke: false,
|
||||
fill: true
|
||||
}
|
||||
}).setOrigin(0.5).setScrollFactor(0).setAlpha(0);
|
||||
this.tweens.add({
|
||||
targets: [winText1, winText2],
|
||||
alpha: 1,
|
||||
duration: 6000,
|
||||
ease: 'Bounce',
|
||||
onComplete: () => {
|
||||
this.UIScene.scene.stop();
|
||||
this.cameras.main.fadeOut();
|
||||
this.bgMusic.stop();
|
||||
this.time.delayedCall(5000, () => {
|
||||
this.scene.stop();
|
||||
this.scene.start('Menu');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (type === 'defeat') {
|
||||
const winText1 = this.add.text(800, 300, `Defeat!`, {
|
||||
fontFamily: 'neuropol, arial',
|
||||
fontSize: '128px',
|
||||
fill: '#ff0062ff',
|
||||
stroke: '#5e182fff',
|
||||
strokeThickness: 2,
|
||||
shadow: {
|
||||
offsetX: 5,
|
||||
offsetY: 5,
|
||||
color: '#000000',
|
||||
blur: 5,
|
||||
stroke: false,
|
||||
fill: true
|
||||
}
|
||||
}).setOrigin(0.5).setScrollFactor(0).setAlpha(0);
|
||||
const winText2 = this.add.text(800, 450, `The aliens have destroyed your Power Core!`, {
|
||||
fontFamily: 'neuropol, arial',
|
||||
fontSize: '56px',
|
||||
fill: '#ff0062ff',
|
||||
stroke: '#5e182fff',
|
||||
strokeThickness: 2,
|
||||
shadow: {
|
||||
offsetX: 5,
|
||||
offsetY: 5,
|
||||
color: '#000000',
|
||||
blur: 5,
|
||||
stroke: false,
|
||||
fill: true
|
||||
}
|
||||
}).setOrigin(0.5).setScrollFactor(0).setAlpha(0);
|
||||
this.tweens.add({
|
||||
targets: [winText1, winText2],
|
||||
alpha: 1,
|
||||
duration: 6000,
|
||||
ease: 'Bounce',
|
||||
onComplete: () => {
|
||||
this.UIScene.scene.stop();
|
||||
this.cameras.main.fadeOut();
|
||||
this.bgMusic.stop();
|
||||
this.time.delayedCall(5000, () => {
|
||||
this.scene.stop();
|
||||
this.scene.start('Menu');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
addControls() {
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ export class Menu extends Phaser.Scene {
|
|||
const totalButtonArea = (buttonHeight + spacing) * 10 - spacing; // Total height for all buttons
|
||||
const startY = levelSelectY + (levelSelectHeight - totalButtonArea) / 2;
|
||||
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
const buttonX = levelSelectX + 20;
|
||||
const buttonY = startY + (buttonHeight + spacing) * (i - 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export class WaveManager {
|
|||
this.endY = WAVE_CONFIG[this.level].endY;
|
||||
this.path = null;
|
||||
this.levelActive = true;
|
||||
this.postLevelTimer = 0;
|
||||
this.waveActive = false;
|
||||
|
||||
this.waveTimer = 0;
|
||||
|
|
@ -170,6 +171,16 @@ export class WaveManager {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.levelActive === false) {
|
||||
this.postLevelTimer += delta;
|
||||
if (this.postLevelTimer >= 5000) {
|
||||
this.postLevelTimer = 0;
|
||||
if (this.scene.enemies.children.entries.length === 0) {
|
||||
this.scene.gameOver('win');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spawnSchedule() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue