From b353eba55cb23806daf6fab4a48299f04a9172c8 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 16 Nov 2024 23:23:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=99=BA=E6=85=A7=E5=A1=94=E5=BC=B9?= =?UTF-8?q?=E5=B9=95=E6=88=98=E6=94=BB=E5=87=BB=E9=9F=B3=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin/boss/barrage.ts | 11 +++-------- src/plugin/boss/towerBossProjectile.ts | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) 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<TowerBoss> { direction: ProjectileDirection = ProjectileDirection.Horizontal; private damaged: boolean = false; + private sounded: boolean = false; /** * boss战开始时初始化 @@ -103,6 +104,10 @@ export class ArrowProjectile extends Projectile<TowerBoss> { 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<TowerBoss> { 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<TowerBoss> { } 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<TowerBoss> { ); 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<TowerBoss> { 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<TowerBoss> { 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;