fix: boss战中读档

This commit is contained in:
unanmed 2024-11-19 22:43:26 +08:00
parent 16b6337f2a
commit dbbc0f0d76
2 changed files with 18 additions and 3 deletions

View File

@ -2,9 +2,15 @@ import { MotaOffscreenCanvas2D } from '@/core/fx/canvas2d';
import { RenderItem, RenderItemPosition } from '@/core/render/item';
import { Transform } from '@/core/render/transform';
import { IStateDamageable } from '@/game/state/interface';
import EventEmitter from 'eventemitter3';
import { Ticker } from 'mutate-animate';
export abstract class BarrageBoss {
interface BarrageBossEvent {
end: [];
start: [];
}
export abstract class BarrageBoss extends EventEmitter<BarrageBossEvent> {
ticker: Ticker = new Ticker();
/** 这个boss的所有弹幕 */
projectiles: Set<Projectile> = new Set();

View File

@ -1,13 +1,22 @@
import { BarrageBoss } from './barrage';
import { TowerBoss } from './towerBoss';
let boss: BarrageBoss;
let boss: BarrageBoss | null;
export function startTowerBoss() {
boss = new TowerBoss();
boss.start();
boss.once('end', () => {
boss = null;
});
}
export function getBoss<T extends BarrageBoss>(): T {
export function getBoss<T extends BarrageBoss>(): T | null {
return boss as T;
}
Mota.require('var', 'hook').on('reset', () => {
if (boss) {
boss.end();
}
});