diff --git a/public/project/floors/tower7.js b/public/project/floors/tower7.js index 1d4e295..eb98346 100644 --- a/public/project/floors/tower7.js +++ b/public/project/floors/tower7.js @@ -9,7 +9,14 @@ main.floors.tower7= "canFlyFrom": false, "canUseQuickShop": true, "cannotViewMap": true, - "images": [], + "images": [ + { + "name": "tower7.jpeg", + "canvas": "bg", + "x": 0, + "y": 0 + } + ], "ratio": 2, "defaultGround": "T526", "bgm": "tower.mp3", diff --git a/src/plugin/boss/barrage.ts b/src/plugin/boss/barrage.ts index 544c517..76d5352 100644 --- a/src/plugin/boss/barrage.ts +++ b/src/plugin/boss/barrage.ts @@ -324,9 +324,9 @@ export namespace Hitbox { if ( Math.max(x1, x2) < Math.min(x3, x4) || - Math.min(x1, x2) < Math.max(x3, x4) || + Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || - Math.min(y1, y2) < Math.max(y3, y4) + Math.min(y1, y2) > Math.max(y3, y4) ) { return false; } @@ -334,7 +334,7 @@ export namespace Hitbox { const d1 = cross(x1, y1, x2, y2, x3, y3); const d2 = cross(x1, y1, x2, y2, x4, y4); const d3 = cross(x3, y3, x4, y4, x1, y1); - const d4 = cross(x3, y3, x4, y4, x2, y3); + const d4 = cross(x3, y3, x4, y4, x2, y2); return d1 * d2 < 0 && d3 * d4 < 0; } diff --git a/src/plugin/boss/towerBoss.ts b/src/plugin/boss/towerBoss.ts index 2934241..47359be 100644 --- a/src/plugin/boss/towerBoss.ts +++ b/src/plugin/boss/towerBoss.ts @@ -207,6 +207,7 @@ export class TowerBoss extends BarrageBoss { */ attackBoss(damage: number) { this.hp -= damage; + if (this.hp < 0) this.hp = 0; this.healthBar.set(this.hp); // 先用drawAnimate凑活一下,等下个版本提供更好的 api if (this.stage === TowerBossStage.Stage3) { @@ -291,7 +292,7 @@ export class TowerBoss extends BarrageBoss { } if (time > 1500) { - this.changeStage(TowerBossStage.Dialogue1, time); + this.changeStage(TowerBossStage.Dialogue2, time); this.attackTime = 2; this.skill1Time = 1; this.skill2Time = 1; @@ -451,24 +452,25 @@ export class TowerBoss extends BarrageBoss { terrainClose(n: number) { for (let nx = n - 1; nx < 15 - n + 1; nx++) { core.removeBlock(nx, n - 1); - core.removeBlock(nx, 15 - n + 1); + core.removeBlock(nx, 15 - n); core.setBgFgBlock('bg', 0, nx, n - 1); - core.setBgFgBlock('bg', 0, nx, 15 - n + 1); + core.setBgFgBlock('bg', 0, nx, 15 - n); } for (let ny = n; ny < 15 - n; ny++) { core.removeBlock(n - 1, ny); - core.removeBlock(15 - n + 1, ny); + core.removeBlock(15 - n, ny); core.setBgFgBlock('bg', 0, n - 1, ny); - core.setBgFgBlock('bg', 0, 15 - n + 1, ny); + core.setBgFgBlock('bg', 0, 15 - n, ny); } for (let nx = n; nx < 15 - n; nx++) { core.setBlock(527, nx, n); - core.setBlock(527, nx, 15 - n); + core.setBlock(527, nx, 15 - n - 1); } for (let ny = n + 1; ny < 15 - n - 1; ny++) { core.setBlock(527, n, ny); - core.setBlock(527, 15 - n, ny); + core.setBlock(527, 15 - n - 1, ny); } + core.stopAutomaticRoute(); core.setHeroLoc('x', 7); core.setHeroLoc('y', 7); core.setHeroLoc('direction', 'up'); @@ -484,7 +486,7 @@ export class TowerBoss extends BarrageBoss { } releaseSkill6(n: number, last: number) { - const s = 13 - n * 2; + const s = 15 - n * 2; const x = Math.floor(Math.random() * s + n); const y = Math.floor(Math.random() * s + n); const proj = this.createProjectile(BoomProjectile, 0, 0); @@ -494,7 +496,9 @@ export class TowerBoss extends BarrageBoss { async releaseSkill7(n: number) { const count = Math.floor(Math.random() * 6 + 3); const nodes: LocArr[] = []; - const s = 13 - n * 2; + let lastX = -1; + let lastY = -1; + const s = 15 - n * 2; const used = new Set(); let i = 0; while (i < count) { @@ -505,13 +509,13 @@ export class TowerBoss extends BarrageBoss { i++; used.add(index); nodes.push([x, y]); - if (nodes.length > 1) { - const [lx, ly] = nodes[i - 1]; + if (lastX !== -1 && lastY !== -1) { const proj = this.createProjectile(ChainProjectile, 0, 0); - proj.hitbox.setPoint1(lx, ly); - proj.hitbox.setPoint2(x, y); + proj.hitbox.setPoint1(lastX * 32 + 16, lastY * 32 + 16); + proj.hitbox.setPoint2(x * 32 + 16, y * 32 + 16); } - await sleep(200); + lastX = x; + lastY = y; } } @@ -589,7 +593,7 @@ export class TowerBoss extends BarrageBoss { this.attackTime++; } - if (this.hp <= 1000) { + if (this.hp <= 0) { this.changeStage(TowerBossStage.End, time); } } diff --git a/src/plugin/boss/towerBossProjectile.ts b/src/plugin/boss/towerBossProjectile.ts index d87afc4..911091a 100644 --- a/src/plugin/boss/towerBossProjectile.ts +++ b/src/plugin/boss/towerBossProjectile.ts @@ -859,6 +859,7 @@ export class BoomProjectile extends Projectile { ai(boss: TowerBoss, time: number, frame: number): void { if (!this.animated && time > this.last + 1000) { + this.animated = true; core.drawAnimate('explosion1', this.bx, this.by); } if (time > this.last + 1100) { @@ -871,30 +872,35 @@ export class BoomProjectile extends Projectile { const end = this.last + 1000; const r = 12; const mr = 27; + ctx.save(); if (this.time < end) { - const angle = this.time / 30; + const angle = this.time / 500; const sin = Math.sin(angle); const cos = Math.cos(angle); ctx.fillStyle = 'rgb(255,50,50)'; ctx.strokeStyle = 'rgb(255,50,50)'; - ctx.lineWidth = 1; + ctx.lineWidth = 1.5; + ctx.globalAlpha = 0.8; + const cx = this.x + 16; + const cy = this.y + 16; ctx.beginPath(); - ctx.moveTo(this.x + r * cos, this.y + r * sin); - ctx.lineTo(this.x + mr * cos, this.y + mr * sin); - ctx.moveTo(this.x - r * cos, this.y - r * sin); - ctx.lineTo(this.x - mr * cos, this.y - mr * sin); - ctx.arc(this.x, this.y, r, 0, Math.PI * 2); + ctx.arc(cx, cy, r, 0, Math.PI * 2); + ctx.moveTo(cx + r * cos, cy + r * sin); + ctx.lineTo(cx + mr * cos, cy + mr * sin); + ctx.moveTo(cx - r * cos, cy - r * sin); + ctx.lineTo(cx - mr * cos, cy - mr * sin); ctx.stroke(); ctx.beginPath(); - ctx.arc(this.x, this.y, 2, 0, Math.PI * 2); + ctx.arc(cx, cy, 2, 0, Math.PI * 2); ctx.fill(); } if (this.time > end - 500) { const dt = this.time - end + 500; const pos = this.y - (1 - dt / 500) * 480; const img = core.material.images.images['boom.png']; - ctx.drawImage(img, this.x - 16, pos - 80, 36, 80); + ctx.drawImage(img, this.x, pos - 80, 36, 80); } + ctx.restore(); } } @@ -934,22 +940,25 @@ export class ChainProjectile extends Projectile { render(canvas: MotaOffscreenCanvas2D, transform: Transform): void { const ctx = canvas.ctx; + ctx.save(); ctx.beginPath(); ctx.moveTo(this.hitbox.x1, this.hitbox.y1); ctx.lineTo(this.hitbox.x2, this.hitbox.y2); + const progress = (this.time - 1000) / 1000; + if (this.time < 1000) { ctx.globalAlpha = 0.6; ctx.strokeStyle = 'rgb(220,100,255)'; ctx.stroke(); } else { + ctx.lineWidth = 2; ctx.strokeStyle = '#fff'; - ctx.shadowBlur = 3; + ctx.shadowBlur = 12; ctx.shadowColor = '#62c8f4'; - ctx.globalAlpha = 0.6; + ctx.globalAlpha = 1 - progress; ctx.stroke(); - ctx.shadowBlur = 0; - ctx.shadowColor = ''; } + ctx.restore(); } }