From 087b0a55d309eac8076f74d8d45284594c130b78 Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Wed, 13 Apr 2022 13:58:59 +0200 Subject: [PATCH] feat: #fe announce waves --- frontend/src/js/fight_scene.ts | 12 ++++++++++++ frontend/src/js/hud.ts | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts index e3d1cc0..0ea4f80 100644 --- a/frontend/src/js/fight_scene.ts +++ b/frontend/src/js/fight_scene.ts @@ -200,12 +200,24 @@ export default class FightScene extends Phaser.Scene { ); } + planWaveAnnouncements() { + this.time.delayedCall(0 * 60 * 1000, () => this.hud.announceWave("WAVE 1")); + this.time.delayedCall(3 * 60 * 1000, () => this.hud.announceWave("WAVE 2")); + this.time.delayedCall(6 * 60 * 1000, () => this.hud.announceWave("WAVE 3")); + this.time.delayedCall(9 * 60 * 1000, () => this.hud.announceWave("WAVE 4")); + this.time.delayedCall(12 * 60 * 1000, () => + this.hud.announceWave("FINAL WAVE"), + ); + } + async create(data: { music: Phaser.Sound.BaseSound }) { (this.scene.get("background") as BackgroundScene).atmosphere.play(); this.music = data.music; this.planMusicChanges(); + this.planWaveAnnouncements(); + this.bindPauseShortcut(); this.gameTime = this.time.addEvent({ diff --git a/frontend/src/js/hud.ts b/frontend/src/js/hud.ts index c6e7465..7b7aee6 100644 --- a/frontend/src/js/hud.ts +++ b/frontend/src/js/hud.ts @@ -153,6 +153,31 @@ export default class HUD { }); } + announceWave(input: string) { + const text = this.scene.add + .text( + this.scene.cameras.main.width / 2, + this.scene.cameras.main.height / 4, + input, + { + ...this.inputTextStyle(), + color: "white", + }, + ) + .setOrigin(0.5, 0.5) + .setAlpha(0) + .setScale(0); + this.scene.tweens.add({ + targets: text, + scaleX: 1, + scaleY: 1, + alpha: 1, + ease: "Expo", + yoyo: true, + duration: 500, + }); + } + changeFlash(object: Phaser.GameObjects.Text, color: number) { object.setTintFill(color); this.scene.time.delayedCall(100, () => object.clearTint()); -- GitLab