mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-31 23:29:27 +08:00
feat: 智慧塔弹幕战攻击音效
This commit is contained in:
parent
b5b435d133
commit
b353eba55c
@ -319,14 +319,9 @@ export namespace Hitbox {
|
|||||||
* 检查两条线段是否有交叉
|
* 检查两条线段是否有交叉
|
||||||
*/
|
*/
|
||||||
export function checkLineLine(line1: Line, line2: Line) {
|
export function checkLineLine(line1: Line, line2: Line) {
|
||||||
const x1 = line1.x1;
|
const { x1, y1, x2, y2 } = line1;
|
||||||
const y1 = line1.y1;
|
const { x1: x3, y1: y3, x2: x4, y2: y4 } = line2;
|
||||||
const x2 = line1.x2;
|
|
||||||
const y2 = line1.y2;
|
|
||||||
const x3 = line2.x1;
|
|
||||||
const y3 = line2.y1;
|
|
||||||
const x4 = line2.x2;
|
|
||||||
const y4 = line2.y2;
|
|
||||||
if (
|
if (
|
||||||
Math.max(x1, x2) < Math.min(x3, x4) ||
|
Math.max(x1, x2) < Math.min(x3, x4) ||
|
||||||
Math.min(x1, x2) < Math.max(x3, x4) ||
|
Math.min(x1, x2) < Math.max(x3, x4) ||
|
||||||
|
@ -31,6 +31,7 @@ export class ArrowProjectile extends Projectile<TowerBoss> {
|
|||||||
direction: ProjectileDirection = ProjectileDirection.Horizontal;
|
direction: ProjectileDirection = ProjectileDirection.Horizontal;
|
||||||
|
|
||||||
private damaged: boolean = false;
|
private damaged: boolean = false;
|
||||||
|
private sounded: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boss战开始时初始化
|
* boss战开始时初始化
|
||||||
@ -103,6 +104,10 @@ export class ArrowProjectile extends Projectile<TowerBoss> {
|
|||||||
|
|
||||||
ai(boss: TowerBoss, time: number, frame: number): void {
|
ai(boss: TowerBoss, time: number, frame: number): void {
|
||||||
if (time > 3000) {
|
if (time > 3000) {
|
||||||
|
if (!this.sounded) {
|
||||||
|
core.playSound('arrow.mp3');
|
||||||
|
this.sounded = true;
|
||||||
|
}
|
||||||
const progress = (time - 3000) / 2000;
|
const progress = (time - 3000) / 2000;
|
||||||
const res = ArrowProjectile.easing!(progress);
|
const res = ArrowProjectile.easing!(progress);
|
||||||
const dx = res * 640;
|
const dx = res * 640;
|
||||||
@ -319,6 +324,7 @@ export class ThunderProjectile extends Projectile<TowerBoss> {
|
|||||||
private power: number = 0;
|
private power: number = 0;
|
||||||
private damaged: boolean = false;
|
private damaged: boolean = false;
|
||||||
private cached: boolean = false;
|
private cached: boolean = false;
|
||||||
|
private sounded: boolean = false;
|
||||||
|
|
||||||
private effect?: PointEffect;
|
private effect?: PointEffect;
|
||||||
private effectId?: number;
|
private effectId?: number;
|
||||||
@ -380,6 +386,12 @@ export class ThunderProjectile extends Projectile<TowerBoss> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ai(boss: TowerBoss, time: number, frame: number): void {
|
ai(boss: TowerBoss, time: number, frame: number): void {
|
||||||
|
if (time > 1000) {
|
||||||
|
if (!this.sounded) {
|
||||||
|
core.playSound('thunder.mp3');
|
||||||
|
this.sounded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (time > 2000) {
|
if (time > 2000) {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
@ -413,7 +425,11 @@ export class ThunderProjectile extends Projectile<TowerBoss> {
|
|||||||
);
|
);
|
||||||
effect.setEffect(id, void 0, [effectRatio, 0, 0, 0]);
|
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.drawImage(ThunderProjectile.cache.canvas, x - 60, 0);
|
||||||
ctx.globalAlpha = before;
|
ctx.globalAlpha = before;
|
||||||
}
|
}
|
||||||
@ -457,6 +473,7 @@ export class ThunderBallProjectile extends Projectile<TowerBoss> {
|
|||||||
private cx: number = 0;
|
private cx: number = 0;
|
||||||
private cy: number = 0;
|
private cy: number = 0;
|
||||||
private damaged: boolean = false;
|
private damaged: boolean = false;
|
||||||
|
private sounded: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boss战开始时初始化
|
* boss战开始时初始化
|
||||||
@ -528,6 +545,10 @@ export class ThunderBallProjectile extends Projectile<TowerBoss> {
|
|||||||
|
|
||||||
ai(boss: TowerBoss, time: number, frame: number): void {
|
ai(boss: TowerBoss, time: number, frame: number): void {
|
||||||
if (time > 3000) {
|
if (time > 3000) {
|
||||||
|
if (!this.sounded) {
|
||||||
|
core.playSound('electron.mp3');
|
||||||
|
this.sounded = true;
|
||||||
|
}
|
||||||
const dt = time - 3000;
|
const dt = time - 3000;
|
||||||
const dis = dt * 0.2;
|
const dis = dt * 0.2;
|
||||||
const cx = this.cx * 32 + 16;
|
const cx = this.cx * 32 + 16;
|
||||||
|
Loading…
Reference in New Issue
Block a user