From 48ea5a8c7dfe46783fce950d0cfc30bae4c8de14 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sun, 17 Nov 2024 22:27:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=99=BA=E6=85=A7=E5=A1=94=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E6=88=98=E6=9C=AC=E4=BD=93=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/index.ts | 4 +++- src/module/weather/rain.ts | 8 +++---- src/plugin/boss/towerBoss.ts | 29 ++++++++++++++++++++++---- src/plugin/boss/towerBossProjectile.ts | 17 +++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/module/index.ts b/src/module/index.ts index caf9910..a4a8d52 100644 --- a/src/module/index.ts +++ b/src/module/index.ts @@ -1,7 +1,9 @@ import { controller } from './weather'; +import { RainWeather } from './weather/rain'; import { WeatherController } from './weather/weather'; Mota.register('module', 'Weather', { controller, - WeatherController + WeatherController, + RainWeather }); diff --git a/src/module/weather/rain.ts b/src/module/weather/rain.ts index 44b02f4..9565524 100644 --- a/src/module/weather/rain.ts +++ b/src/module/weather/rain.ts @@ -128,11 +128,11 @@ export class RainWeather implements IWeather { activate(): void { const render = MotaRenderer.get('render-main'); - const layer = render?.getElementById('layer-main'); const draw = render?.getElementById('map-draw') as Container; + const layer = draw.children; if (!layer || !draw) return; const shader = RainWeather.shader; - layer.append(shader); + shader.appendChild(...layer); shader.append(draw); const gl = shader.gl; @@ -158,11 +158,11 @@ export class RainWeather implements IWeather { deactivate(): void { const render = MotaRenderer.get('render-main'); - const layer = render?.getElementById('layer-main'); const draw = render?.getElementById('map-draw') as Container; + const layer = draw.children; if (!layer || !draw) return; const shader = RainWeather.shader; - layer.append(draw); + draw.appendChild(...layer); shader.remove(); } } diff --git a/src/plugin/boss/towerBoss.ts b/src/plugin/boss/towerBoss.ts index 3f91020..9ae9909 100644 --- a/src/plugin/boss/towerBoss.ts +++ b/src/plugin/boss/towerBoss.ts @@ -22,6 +22,7 @@ import { import { IStateDamageable } from '@/game/state/interface'; import { HeroRenderer } from '@/core/render/preset/hero'; import { controller } from '@/module/weather'; +import { PopText } from '../fx/pop'; Mota.require('var', 'loading').once('coreInit', () => { const shader = new Shader(); @@ -75,6 +76,8 @@ export class TowerBoss extends BarrageBoss { private group: LayerGroup; /** 楼层渲染容器 */ private mapDraw: Container; + /** 伤害弹出 */ + pop: PopText; /** 每个阶段的进度,具体定义参考 ai 函数开头 */ private stageProgress: number = 0; @@ -125,6 +128,7 @@ export class TowerBoss extends BarrageBoss { const render = MotaRenderer.get('render-main')!; this.group = render.getElementById('layer-main') as LayerGroup; this.mapDraw = render.getElementById('map-draw') as Container; + this.pop = render.getElementById('pop-main') as PopText; this.healthBar.init(); this.word.init(); @@ -185,6 +189,8 @@ export class TowerBoss extends BarrageBoss { AttackProjectile.end(); TowerBoss.effect.end(); + + Mota.Plugin.require('replay_g').clip('choice:0'); } /** @@ -213,12 +219,16 @@ export class TowerBoss extends BarrageBoss { // 先用drawAnimate凑活一下,等下个版本提供更好的 api if (this.stage === TowerBossStage.Stage3) { core.drawAnimate('hand', 7, 2); + this.pop.addPop((-damage).toString(), 1000, 240, 80, '#dafc1d'); } else if (this.stage === TowerBossStage.Stage4) { core.drawAnimate('hand', 7, 3); + this.pop.addPop((-damage).toString(), 1000, 240, 112, '#dafc1d'); } else if (this.stage === TowerBossStage.Stage5) { core.drawAnimate('hand', 7, 4); + this.pop.addPop((-damage).toString(), 1000, 240, 144, '#dafc1d'); } else { core.drawAnimate('hand', 7, 1); + this.pop.addPop((-damage).toString(), 1000, 240, 172, '#dafc1d'); } } @@ -293,11 +303,12 @@ export class TowerBoss extends BarrageBoss { } if (time > 1500) { - this.changeStage(TowerBossStage.Dialogue2, time); + this.changeStage(TowerBossStage.Stage1, time); this.attackTime = 2; this.skill1Time = 1; this.skill2Time = 1; this.skill3Time = 1; + core.playBgm('towerBoss.mp3'); } } @@ -383,6 +394,8 @@ export class TowerBoss extends BarrageBoss { this.attackTime = 3; this.skill4Time = 5; this.skill5Time = 3; + core.playBgm('towerBoss2.mp3'); + controller.activate('rain', 6); } releaseSkill4() { @@ -428,8 +441,6 @@ export class TowerBoss extends BarrageBoss { const skill5Release = this.skill5Time * this.skill5Interval; const attack = this.attackTime * this.attackInterval; - controller.activate('rain', 6); - if (time > skill4Release) { this.releaseSkill4(); this.skill4Time++; @@ -486,6 +497,7 @@ export class TowerBoss extends BarrageBoss { this.terrainClose(1); this.skill6Time = 30; this.skill7Time = 2; + core.playBgm('towerBoss3.mp3'); } releaseSkill6(n: number, last: number) { @@ -601,7 +613,16 @@ export class TowerBoss extends BarrageBoss { } } - private aiEnd(time: number, frame: number) {} + private aiEnd(time: number, frame: number) { + this.end(); + core.insertAction([ + { type: 'openDoor', loc: [13, 6], floorId: 'MT19' }, + { type: 'setValue', name: 'flag:boss1', value: 'true' }, + { type: 'changeFloor', floorId: 'MT20', loc: [7, 9] }, + { type: 'forbidSave' }, + { type: 'showStatusBar' } + ]); + } } class BossEffect extends BossSprite { diff --git a/src/plugin/boss/towerBossProjectile.ts b/src/plugin/boss/towerBossProjectile.ts index 911091a..9bf89ab 100644 --- a/src/plugin/boss/towerBossProjectile.ts +++ b/src/plugin/boss/towerBossProjectile.ts @@ -17,6 +17,17 @@ export const enum ProjectileDirection { BottomToTop } +function popDamage(damage: number, boss: TowerBoss, color: string) { + const { x, y } = core.status.hero.loc; + boss.pop.addPop( + (-damage).toString(), + 1000, + x * 32 + 16, + y * 32 + 16, + color + ); +} + export class AttackProjectile extends Projectile { static easeIn?: TimingFn; static easeOut?: TimingFn; @@ -187,6 +198,7 @@ export class ArrowProjectile extends Projectile { target.hp -= this.damage; this.damaged = true; core.drawHeroAnimate('hand'); + popDamage(this.damage, this.boss, '#ff8180'); return true; } @@ -395,6 +407,7 @@ export class IceProjectile extends Projectile { if (!this.damaged) return false; target.hp -= this.damage; this.damaged = true; + popDamage(this.damage, this.boss, '#6bf8ff'); return true; } @@ -506,6 +519,7 @@ export class ThunderProjectile extends Projectile { if (this.damaged) return false; this.damaged = true; target.hp -= this.damage; + popDamage(this.damage, this.boss, '#cfe6fc'); return true; } @@ -665,6 +679,7 @@ export class ThunderBallProjectile extends Projectile { this.damaged = true; target.hp -= this.damage; core.playSound('electron.mp3'); + popDamage(this.damage, this.boss, '#cfe6fc'); return true; } @@ -854,6 +869,7 @@ export class BoomProjectile extends Projectile { if (this.damaged) return false; target.hp -= this.damage; this.damaged = true; + popDamage(this.damage, this.boss, '#e08aff'); return true; } @@ -929,6 +945,7 @@ export class ChainProjectile extends Projectile { target.hp -= this.damage; this.damaged = true; core.playSound('electron.mp3'); + popDamage(this.damage, this.boss, '#8affd6'); return true; }