feat: 智慧塔特殊战本体完成

This commit is contained in:
unanmed 2024-11-17 22:27:18 +08:00
parent ae5a8f6363
commit 48ea5a8c7d
4 changed files with 49 additions and 9 deletions

View File

@ -1,7 +1,9 @@
import { controller } from './weather'; import { controller } from './weather';
import { RainWeather } from './weather/rain';
import { WeatherController } from './weather/weather'; import { WeatherController } from './weather/weather';
Mota.register('module', 'Weather', { Mota.register('module', 'Weather', {
controller, controller,
WeatherController WeatherController,
RainWeather
}); });

View File

@ -128,11 +128,11 @@ export class RainWeather implements IWeather {
activate(): void { activate(): void {
const render = MotaRenderer.get('render-main'); const render = MotaRenderer.get('render-main');
const layer = render?.getElementById('layer-main');
const draw = render?.getElementById('map-draw') as Container; const draw = render?.getElementById('map-draw') as Container;
const layer = draw.children;
if (!layer || !draw) return; if (!layer || !draw) return;
const shader = RainWeather.shader; const shader = RainWeather.shader;
layer.append(shader); shader.appendChild(...layer);
shader.append(draw); shader.append(draw);
const gl = shader.gl; const gl = shader.gl;
@ -158,11 +158,11 @@ export class RainWeather implements IWeather {
deactivate(): void { deactivate(): void {
const render = MotaRenderer.get('render-main'); const render = MotaRenderer.get('render-main');
const layer = render?.getElementById('layer-main');
const draw = render?.getElementById('map-draw') as Container; const draw = render?.getElementById('map-draw') as Container;
const layer = draw.children;
if (!layer || !draw) return; if (!layer || !draw) return;
const shader = RainWeather.shader; const shader = RainWeather.shader;
layer.append(draw); draw.appendChild(...layer);
shader.remove(); shader.remove();
} }
} }

View File

@ -22,6 +22,7 @@ import {
import { IStateDamageable } from '@/game/state/interface'; import { IStateDamageable } from '@/game/state/interface';
import { HeroRenderer } from '@/core/render/preset/hero'; import { HeroRenderer } from '@/core/render/preset/hero';
import { controller } from '@/module/weather'; import { controller } from '@/module/weather';
import { PopText } from '../fx/pop';
Mota.require('var', 'loading').once('coreInit', () => { Mota.require('var', 'loading').once('coreInit', () => {
const shader = new Shader(); const shader = new Shader();
@ -75,6 +76,8 @@ export class TowerBoss extends BarrageBoss {
private group: LayerGroup; private group: LayerGroup;
/** 楼层渲染容器 */ /** 楼层渲染容器 */
private mapDraw: Container; private mapDraw: Container;
/** 伤害弹出 */
pop: PopText;
/** 每个阶段的进度,具体定义参考 ai 函数开头 */ /** 每个阶段的进度,具体定义参考 ai 函数开头 */
private stageProgress: number = 0; private stageProgress: number = 0;
@ -125,6 +128,7 @@ export class TowerBoss extends BarrageBoss {
const render = MotaRenderer.get('render-main')!; const render = MotaRenderer.get('render-main')!;
this.group = render.getElementById('layer-main') as LayerGroup; this.group = render.getElementById('layer-main') as LayerGroup;
this.mapDraw = render.getElementById('map-draw') as Container; this.mapDraw = render.getElementById('map-draw') as Container;
this.pop = render.getElementById('pop-main') as PopText;
this.healthBar.init(); this.healthBar.init();
this.word.init(); this.word.init();
@ -185,6 +189,8 @@ export class TowerBoss extends BarrageBoss {
AttackProjectile.end(); AttackProjectile.end();
TowerBoss.effect.end(); TowerBoss.effect.end();
Mota.Plugin.require('replay_g').clip('choice:0');
} }
/** /**
@ -213,12 +219,16 @@ export class TowerBoss extends BarrageBoss {
// 先用drawAnimate凑活一下等下个版本提供更好的 api // 先用drawAnimate凑活一下等下个版本提供更好的 api
if (this.stage === TowerBossStage.Stage3) { if (this.stage === TowerBossStage.Stage3) {
core.drawAnimate('hand', 7, 2); core.drawAnimate('hand', 7, 2);
this.pop.addPop((-damage).toString(), 1000, 240, 80, '#dafc1d');
} else if (this.stage === TowerBossStage.Stage4) { } else if (this.stage === TowerBossStage.Stage4) {
core.drawAnimate('hand', 7, 3); core.drawAnimate('hand', 7, 3);
this.pop.addPop((-damage).toString(), 1000, 240, 112, '#dafc1d');
} else if (this.stage === TowerBossStage.Stage5) { } else if (this.stage === TowerBossStage.Stage5) {
core.drawAnimate('hand', 7, 4); core.drawAnimate('hand', 7, 4);
this.pop.addPop((-damage).toString(), 1000, 240, 144, '#dafc1d');
} else { } else {
core.drawAnimate('hand', 7, 1); 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) { if (time > 1500) {
this.changeStage(TowerBossStage.Dialogue2, time); this.changeStage(TowerBossStage.Stage1, time);
this.attackTime = 2; this.attackTime = 2;
this.skill1Time = 1; this.skill1Time = 1;
this.skill2Time = 1; this.skill2Time = 1;
this.skill3Time = 1; this.skill3Time = 1;
core.playBgm('towerBoss.mp3');
} }
} }
@ -383,6 +394,8 @@ export class TowerBoss extends BarrageBoss {
this.attackTime = 3; this.attackTime = 3;
this.skill4Time = 5; this.skill4Time = 5;
this.skill5Time = 3; this.skill5Time = 3;
core.playBgm('towerBoss2.mp3');
controller.activate('rain', 6);
} }
releaseSkill4() { releaseSkill4() {
@ -428,8 +441,6 @@ export class TowerBoss extends BarrageBoss {
const skill5Release = this.skill5Time * this.skill5Interval; const skill5Release = this.skill5Time * this.skill5Interval;
const attack = this.attackTime * this.attackInterval; const attack = this.attackTime * this.attackInterval;
controller.activate('rain', 6);
if (time > skill4Release) { if (time > skill4Release) {
this.releaseSkill4(); this.releaseSkill4();
this.skill4Time++; this.skill4Time++;
@ -486,6 +497,7 @@ export class TowerBoss extends BarrageBoss {
this.terrainClose(1); this.terrainClose(1);
this.skill6Time = 30; this.skill6Time = 30;
this.skill7Time = 2; this.skill7Time = 2;
core.playBgm('towerBoss3.mp3');
} }
releaseSkill6(n: number, last: number) { 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<TowerBoss> { class BossEffect extends BossSprite<TowerBoss> {

View File

@ -17,6 +17,17 @@ export const enum ProjectileDirection {
BottomToTop 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<TowerBoss> { export class AttackProjectile extends Projectile<TowerBoss> {
static easeIn?: TimingFn; static easeIn?: TimingFn;
static easeOut?: TimingFn; static easeOut?: TimingFn;
@ -187,6 +198,7 @@ export class ArrowProjectile extends Projectile<TowerBoss> {
target.hp -= this.damage; target.hp -= this.damage;
this.damaged = true; this.damaged = true;
core.drawHeroAnimate('hand'); core.drawHeroAnimate('hand');
popDamage(this.damage, this.boss, '#ff8180');
return true; return true;
} }
@ -395,6 +407,7 @@ export class IceProjectile extends Projectile<TowerBoss> {
if (!this.damaged) return false; if (!this.damaged) return false;
target.hp -= this.damage; target.hp -= this.damage;
this.damaged = true; this.damaged = true;
popDamage(this.damage, this.boss, '#6bf8ff');
return true; return true;
} }
@ -506,6 +519,7 @@ export class ThunderProjectile extends Projectile<TowerBoss> {
if (this.damaged) return false; if (this.damaged) return false;
this.damaged = true; this.damaged = true;
target.hp -= this.damage; target.hp -= this.damage;
popDamage(this.damage, this.boss, '#cfe6fc');
return true; return true;
} }
@ -665,6 +679,7 @@ export class ThunderBallProjectile extends Projectile<TowerBoss> {
this.damaged = true; this.damaged = true;
target.hp -= this.damage; target.hp -= this.damage;
core.playSound('electron.mp3'); core.playSound('electron.mp3');
popDamage(this.damage, this.boss, '#cfe6fc');
return true; return true;
} }
@ -854,6 +869,7 @@ export class BoomProjectile extends Projectile<TowerBoss> {
if (this.damaged) return false; if (this.damaged) return false;
target.hp -= this.damage; target.hp -= this.damage;
this.damaged = true; this.damaged = true;
popDamage(this.damage, this.boss, '#e08aff');
return true; return true;
} }
@ -929,6 +945,7 @@ export class ChainProjectile extends Projectile<TowerBoss> {
target.hp -= this.damage; target.hp -= this.damage;
this.damaged = true; this.damaged = true;
core.playSound('electron.mp3'); core.playSound('electron.mp3');
popDamage(this.damage, this.boss, '#8affd6');
return true; return true;
} }