Add boss hit feedback with flash and floating damage numbers
This commit is contained in:
+23
-1
@@ -27,6 +27,7 @@ import { Boomerang } from './Boomerang';
|
||||
import { Trap } from './Trap';
|
||||
import { GasCloud } from './GasCloud';
|
||||
import { Trapper } from './Trapper';
|
||||
import { DamageNumber } from './DamageNumber';
|
||||
|
||||
const SPAWN_TIME = 10;
|
||||
|
||||
@@ -50,6 +51,7 @@ export class Game {
|
||||
projectiles: EnemyProjectile[] = [];
|
||||
traps: Trap[] = [];
|
||||
gasClouds: GasCloud[] = [];
|
||||
private damageNumbers: DamageNumber[] = [];
|
||||
private aura: Aura | null = null;
|
||||
private boomerang: Boomerang | null = null;
|
||||
private trapper = new Trapper();
|
||||
@@ -687,6 +689,9 @@ export class Game {
|
||||
for (const cloud of this.gasClouds) cloud.dispose();
|
||||
this.gasClouds = [];
|
||||
|
||||
for (const num of this.damageNumbers) num.dispose(this.scene);
|
||||
this.damageNumbers = [];
|
||||
|
||||
if (this.aura) {
|
||||
this.aura.dispose(this.scene);
|
||||
this.aura = null;
|
||||
@@ -743,10 +748,19 @@ export class Game {
|
||||
this.updateUI();
|
||||
}
|
||||
|
||||
onDamageDealt(damage: number) {
|
||||
onDamageDealt(damage: number, target?: Enemy) {
|
||||
if (this.state === 'playing' && this.player.stats.lifesteal > 0) {
|
||||
this.player.heal(damage * this.player.stats.lifesteal);
|
||||
}
|
||||
// Treffer-Feedback: Schadenszahl bei Bossen einblenden
|
||||
if (target?.isBoss && !target.dead) {
|
||||
this.spawnDamageNumber(Math.round(damage), target.body.position);
|
||||
}
|
||||
}
|
||||
|
||||
spawnDamageNumber(damage: number, pos: THREE.Vector3, color?: string) {
|
||||
const num = new DamageNumber(this.scene, `${damage}`, pos, color);
|
||||
this.damageNumbers.push(num);
|
||||
}
|
||||
|
||||
private openLevelUp() {
|
||||
@@ -1314,6 +1328,14 @@ export class Game {
|
||||
|
||||
this.updateBloodParticles(dt);
|
||||
|
||||
// Schadenszahlen aktualisieren
|
||||
for (let i = this.damageNumbers.length - 1; i >= 0; i--) {
|
||||
if (!this.damageNumbers[i].update(dt)) {
|
||||
this.damageNumbers[i].dispose(this.scene);
|
||||
this.damageNumbers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.aura) this.aura.update(dt, this);
|
||||
if (this.boomerang) this.boomerang.update(dt, this);
|
||||
this.updateTraps(dt);
|
||||
|
||||
Reference in New Issue
Block a user