diff --git a/src/plugin/boss/barrage.ts b/src/plugin/boss/barrage.ts index e520ea3..78a7070 100644 --- a/src/plugin/boss/barrage.ts +++ b/src/plugin/boss/barrage.ts @@ -319,14 +319,9 @@ export namespace Hitbox { * 检查两条线段是否有交叉 */ export function checkLineLine(line1: Line, line2: Line) { - const x1 = line1.x1; - const y1 = line1.y1; - const x2 = line1.x2; - const y2 = line1.y2; - const x3 = line2.x1; - const y3 = line2.y1; - const x4 = line2.x2; - const y4 = line2.y2; + const { x1, y1, x2, y2 } = line1; + const { x1: x3, y1: y3, x2: x4, y2: y4 } = line2; + if ( Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) < Math.max(x3, x4) || diff --git a/src/plugin/boss/towerBossProjectile.ts b/src/plugin/boss/towerBossProjectile.ts index 2a2f2a6..0872153 100644 --- a/src/plugin/boss/towerBossProjectile.ts +++ b/src/plugin/boss/towerBossProjectile.ts @@ -31,6 +31,7 @@ export class ArrowProjectile extends Projectile { direction: ProjectileDirection = ProjectileDirection.Horizontal; private damaged: boolean = false; + private sounded: boolean = false; /** * boss战开始时初始化 @@ -103,6 +104,10 @@ export class ArrowProjectile extends Projectile { ai(boss: TowerBoss, time: number, frame: number): void { if (time > 3000) { + if (!this.sounded) { + core.playSound('arrow.mp3'); + this.sounded = true; + } const progress = (time - 3000) / 2000; const res = ArrowProjectile.easing!(progress); const dx = res * 640; @@ -319,6 +324,7 @@ export class ThunderProjectile extends Projectile { private power: number = 0; private damaged: boolean = false; private cached: boolean = false; + private sounded: boolean = false; private effect?: PointEffect; private effectId?: number; @@ -380,6 +386,12 @@ export class ThunderProjectile extends Projectile { } ai(boss: TowerBoss, time: number, frame: number): void { + if (time > 1000) { + if (!this.sounded) { + core.playSound('thunder.mp3'); + this.sounded = true; + } + } if (time > 2000) { this.destroy(); } @@ -413,7 +425,11 @@ export class ThunderProjectile extends Projectile { ); effect.setEffect(id, void 0, [effectRatio, 0, 0, 0]); } - ctx.globalAlpha = 1 - progress; + if (progress < 0.5) { + ctx.globalAlpha = 1; + } else { + ctx.globalAlpha = 1 - (progress - 0.5) * 2; + } ctx.drawImage(ThunderProjectile.cache.canvas, x - 60, 0); ctx.globalAlpha = before; } @@ -457,6 +473,7 @@ export class ThunderBallProjectile extends Projectile { private cx: number = 0; private cy: number = 0; private damaged: boolean = false; + private sounded: boolean = false; /** * boss战开始时初始化 @@ -528,6 +545,10 @@ export class ThunderBallProjectile extends Projectile { ai(boss: TowerBoss, time: number, frame: number): void { if (time > 3000) { + if (!this.sounded) { + core.playSound('electron.mp3'); + this.sounded = true; + } const dt = time - 3000; const dis = dt * 0.2; const cx = this.cx * 32 + 16;